Merge branch 'missing_library_fix' into 'master'

Only initialize TTS outside the editor if system libraries are available

Closes #3

See merge request lightsoutgames/godot-tts!1
This commit is contained in:
Nolan Darilek 2019-10-16 12:39:22 +00:00
commit 8fc2321050

29
TTS.gd
View File

@ -3,24 +3,41 @@ extends Node
const TTS = preload("godot-tts.gdns")
var tts = TTS.new()
var tts = null
func _ready():
# Only initialize TTS if it's available or if we're in the editor.
if TTS.can_instance() or Engine.editor_hint:
print("Attempting to load TTS.")
tts = TTS.new()
else:
print("TTS not available!")
func set_rate(rate):
tts.rate = rate
if tts != null:
tts.rate = rate
func get_rate():
return tts.rate
if tts != null:
return tts.rate
else:
return 0
var rate setget set_rate, get_rate
func speak(text, interrupt := true):
tts.speak(text, interrupt)
if tts != null:
tts.speak(text, interrupt)
func stop():
tts.stop()
if tts != null:
tts.stop()
func get_is_rate_supported():
return tts.is_rate_supported()
if tts != null:
return tts.is_rate_supported()
else:
return false
var is_rate_supported setget , get_is_rate_supported