//speech example
//2022-06-27
//Note: Will only work on android/ios. This is mainly for reference.
//basic setup
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
//init speech
TextToSpeechSetup()
//wait till ready
timeout as integer=120
while GetTextToSpeechReady()<>1 and timeout>0
sync()
timeout=timeout-1
endwhile
//incase never ready
if timeout<=0
print("tts may not work.")
endif
//set language
SetSpeechLanguage("en_US")
//set speed
SetSpeechRate(1)
//wait till ready
timeout=120
while GetTextToSpeechReady()<>1 and timeout>0
sync()
timeout=timeout-1
endwhile
//incase never ready
if timeout<=0
print("tts may not work.")
endif
//demo
Speak("Try creating talking dogs in App Game Kit 2. I hear they are ")
//wait till done
while IsSpeaking()
sync()
endwhile
//change speed
SetSpeechRate(0.1)
//wait till ready
while GetTextToSpeechReady()<>1
sync()
endwhile
//say something slow
Speak("furry nice!")
//wait till done
while IsSpeaking()
sync()
endwhile
//change speed
SetSpeechRate(2)
//wait till ready
while GetTextToSpeechReady()<>1
sync()
endwhile
//say something fast
Speak("Warning: Not all dogs are nice. Other problems may occurr. See command list for details.")
//wait till done
while IsSpeaking()
sync()
endwhile
//change speed
SetSpeechRate(1)
//wait till ready
while GetTextToSpeechReady()<>1
sync()
endwhile
//attempt to say something but...
Speak("This text is secret. So stop saying it now!")
//...stop after a bit
timeout=45
while timeout>0
sync()
timeout=timeout-1
endwhile
StopSpeaking()
//just to prove its stopped
timeout=1200
while timeout>0 and GetPointerPressed()=0
sync()
timeout=timeout-1
endwhile
end
Help make AGK better by submitting an example for this command! (All examples are subject to approval)