Add property indicating whether utterance callbacks are supported.

This commit is contained in:
Nolan Darilek 2020-09-29 10:53:35 -05:00
parent 795cc4790c
commit abe9ab3f55
2 changed files with 25 additions and 1 deletions

17
TTS.gd
View File

@ -7,6 +7,7 @@ var tts
signal done
func _init():
if OS.get_name() == "Server" or OS.has_feature("JavaScript"):
return
@ -20,10 +21,10 @@ func _init():
print_debug("TTS not available!")
func _ready():
pause_mode = Node.PAUSE_MODE_PROCESS
func _get_min_rate():
if OS.has_feature('JavaScript'):
return 0.1
@ -155,6 +156,20 @@ func get_is_rate_supported():
var is_rate_supported setget , get_is_rate_supported
func _get_are_utterance_callbacks_supported():
if Engine.has_singleton("GodotTTS"):
return false
elif OS.has_feature('JavaScript'):
return false
elif tts != null:
return tts.are_utterance_callbacks_supported()
else:
return false
var are_utterance_callbacks_supported setget , _get_are_utterance_callbacks_supported
func _get_can_detect_is_speaking():
if Engine.has_singleton("GodotTTS"):
return true

View File

@ -165,6 +165,15 @@ impl TTS {
rate_supported
}
#[export]
fn are_utterance_callbacks_supported(&mut self, _owner: &Node) -> bool {
let Features {
utterance_callbacks: supported,
..
} = self.0.supported_features();
supported
}
#[export]
fn _process(&mut self, owner: &Node, _delta: f32) {
if let Some(msg) = self.1.try_recv().ok() {