B4J Tutorial [ABMaterial] Text2Speech

Discussion in 'B4J Tutorials' started by Mashiane, Apr 24, 2018.

  1. Mashiane

    Mashiane Expert Licensed User


    Been looking for this like forever...


    MashSpeak(page,"I have been developing A.B.M. web apps for a while now. It's an enjoyable experience.",0.7)
    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 = "$
        speech.volume = 1;
        speech.rate = ${
        speech.pitch = 1;

    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
    Last edited: Apr 24, 2018
    Beja, Johan Schoeman, Anser and 3 others like this.
  2. joulongleu

    joulongleu Member

    wow good,good,Chinese also translated ,thank you
    Mashiane and Harris like this.
  3. joulongleu

    joulongleu Member

    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
    Mashiane likes this.
  4. Mashiane

    Mashiane Expert Licensed User

    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.
    joulongleu likes this.
  5. Anser

    Anser Well-Known Member Licensed User

    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 ?


    This is the DefaultWebChromeClient console message that I see on my B4A app
    Uncaught ReferenceError: SpeechSynthesisUtterance is not defined
    Last edited: May 5, 2018
    joulongleu likes this.
  6. Mashiane

    Mashiane Expert Licensed User

    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.
    joulongleu likes this.
  7. Anser

    Anser Well-Known Member Licensed User

    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.
    Mashiane and joulongleu like this.
  8. Mashiane

    Mashiane Expert Licensed User

    Yes, I guess so, but then using a webview for ABM apps is something that I think AB is not recommending.
    joulongleu and Anser like this.
  9. Anser

    Anser Well-Known Member Licensed User

    joulongleu likes this.
  10. Mashiane

    Mashiane Expert Licensed User

    joulongleu likes this.
  11. Beja

    Beja Expert Licensed User

    Hi Mashiane
    Is ABMPage a library or you are calling a service? can you put together a simple project?

    joulongleu likes this.
  12. Anser

    Anser Well-Known Member Licensed User

    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

    'Class module
    Sub Class_Globals
    Private ws As WebSocket 'ignore
        ' will hold our page information
        Public page As ABMPage
           . . . . .
           . . . . .
    joulongleu and Mashiane like this.
  13. Mashiane

    Mashiane Expert Licensed User

    Just copy the method to ABMShared and call it anywhere, there is no need to create a simple project...

    joulongleu likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice