B4J Tutorial [ABMaterial] Text2Speech

Ola

Been looking for this like forever...

Usage:

Code: Copy
MashSpeak(page,"I have been developing A.B.M. web apps for a while now. It's an enjoyable experience.",0.7)

Code: Copy
Sub MashSpeak(pg As ABMPage, msg As String, rate As Double)
    Dim script As String = $"var speech = new SpeechSynthesisUtterance();
    // Set the text and voice attributes.
    speech.text = "${msg}";
    speech.volume = 1;
    speech.rate = ${rate};
    speech.pitch = 1;
    window.speechSynthesis.speak(speech);"$
    pg.ws.Eval(script,Null)
    pg.ws.flush
End Sub

When this function is called, a robot voice will read out the given string, doing it's best human impression.


Now I just need a way to remove all HTML tags from my text for it to be read properly. The robots are taking over!! :D:D:D
Ta!
 
Last edited:
Hi Mashiane:MashSpeak is very good,Another feature is better SpeechRecognition, would like to quote but I will not use, the following URL reference: https://codepen.io/PJCHENder/pen/mMzYgO
thank you
Eish my friend, at the moment I am caught inbetween AskTeenCoach and Project.Show and only priority issues are taking up my space where ABM is concerned. I had featured these as I thought someone here will find it useful as I needed it for Bible.Show (still shelved). Thanks for the heads up anyway.
 
Observed the following.

On the phone, if the application is directly called from the Phone's internet browser, then it is audible.

I use a B4A app and then via WebView the ABM application URL is called. In this case it is not audible on the phone. So I believe that this is something to do with the B4A's Webview.

Any hint ?

EDIT:-

This is the DefaultWebChromeClient console message that I see on my B4A app
Uncaught ReferenceError: SpeechSynthesisUtterance is not defined
 
Last edited:
Observed the following.

On the phone, if the application is directly called from the Phone's internet browser, then it is audible.

I use a B4A app and then via WebView the ABM application URL is called. In this case it is not audible on the phone. So I believe that this is something to do with the B4A's Webview.

Any hint ?

EDIT:-

This is the DefaultWebChromeClient console message that I see on my B4A app
Uncaught ReferenceError: SpeechSynthesisUtterance is not defined
I guess if we follow AB's recommendations to rather develop an ABM Native app it would work. I haven't explored anything that far as yet and the only trial I did with the webview I didnt go as far as using speech.
 
Whatever the technology is used to create the Web application, finally it is HTML and that's the reason all other internet browser are playing the sound. Wonder why the Android WebView is not able to make it audible. May be there is some extra options available in the WebVew which we may not be aware of.
 
Whatever the technology is used to create the Web application, finally it is HTML and that's the reason all other internet browser are playing the sound. Wonder why the Android WebView is not able to make it audible. May be there is some extra options available in the WebVew which we may not be aware of.
Yes, I guess so, but then using a webview for ABM apps is something that I think AB is not recommending.
 
If I am not wrong, ABMPage is included in the ABM Library itself. If you check ABMPageTemplate.bas you will find the following entry in Sub Class_Globals

Code: Copy
'Class module
Sub Class_Globals
    Private ws As WebSocket 'ignore
    ' will hold our page information
    Public page As ABMPage
       . . . . .
       . . . . .
 
Back
Top