Use floats for JavaScript rate, hopefully fixing slow speech issues likely caused by rate being 0.

This commit is contained in:
Nolan Darilek 2020-04-12 10:05:18 -05:00
parent ba22fddf37
commit 35a34871a3

6
TTS.gd
View File

@ -43,12 +43,12 @@ func speak(text, interrupt := true):
if tts != null: if tts != null:
tts.speak(text, interrupt) tts.speak(text, interrupt)
elif OS.has_feature('JavaScript'): elif OS.has_feature('JavaScript'):
var scaled_rate var scaled_rate: float
if javascript_rate <= 50: if javascript_rate <= 50:
scaled_rate = javascript_rate / 50 scaled_rate = javascript_rate / 50.0
else: else:
scaled_rate = javascript_rate - 50 scaled_rate = javascript_rate - 50
scaled_rate = 1 + (scaled_rate / 5) scaled_rate = 1 + (scaled_rate / 5.0)
var code = """ var code = """
let utterance = new SpeechSynthesisUtterance("%s") let utterance = new SpeechSynthesisUtterance("%s")
utterance.rate = %s utterance.rate = %s