HTML5 simple speech synthesis

Jimmy

New member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
569
Here's a very simple example of speech for the HTML target.
MIDI and softsynth is coming next!

code_language.cerberus:
Import mojo2

Import "commands.js"
Extern
Class Speak = "Speak"
    Method Speak(phrase:String)
End Class
Public

Function Main()
    New MyApp
End

Class MyApp Extends App

    Field canvas:Canvas
    Field speechtest:Speak = New Speak
   
    Method OnCreate()
        canvas = New Canvas
       SetSwapInterval 1 ;    SetUpdateRate 0            
          speechtest.Speak("Helloo")
          speechtest.Speak("How are you doing?")
    End

    Method OnUpdate()
        If KeyHit(KEY_ESCAPE) Then EndApp
    End
     
    Method OnRender()  
        canvas.Flush
    End
   
End

[CODE lang="javascript" title="commands.js"]class Speak{
Speak(phrase){
var s = new SpeechSynthesisUtterance();
s.text = phrase;
speechSynthesis.speak(s);
}
}[/CODE]
 
Top Bottom