29 lines
565 B
GDScript
29 lines
565 B
GDScript
extends Node
|
|
|
|
var voice_id
|
|
|
|
func _ready():
|
|
var voices = DisplayServer.tts_get_voices_for_language("de")
|
|
if voices.size() > 0:
|
|
voice_id = "German+Robosoft6"
|
|
else:
|
|
voices = DisplayServer.tts_get_voices_for_language("en")
|
|
voice_id = voices[0]
|
|
|
|
# Connect with DialogueManager
|
|
DialogueManager.got_dialogue.connect(_on_dialogue)
|
|
|
|
|
|
func _on_dialogue(line):
|
|
if voice_id == null:
|
|
return
|
|
|
|
# Stop earlier text (important!)
|
|
DisplayServer.tts_stop()
|
|
|
|
# Speak
|
|
DisplayServer.tts_speak(line.text, voice_id, 100)
|
|
|
|
func _stop_dialogue():
|
|
DisplayServer.tts_stop()
|