Android Question Text To Speech

Discussion in 'Android Questions' started by kisoft, Jul 25, 2019.

  1. kisoft

    kisoft Active Member Licensed User

    By default, the speech synthesizer plays 4000 characters. Can I handle files with more characters?
    When I try to read a file with 20,000 characters, I get this error:
    Error occurred on line: 123 (Main)
    java.lang.RuntimeException: Error speaking text.
        at anywheresoftware.b4a.obejcts.TTS.Speak(
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Native Method)
        at anywheresoftware.b4a.ShellBA.raiseEvent2(
        at anywheresoftware.b4a.BA.raiseEvent2(
        at anywheresoftware.b4a.BA.raiseEvent(
        at anywheresoftware.b4a.objects.ViewWrapper$
        at android.view.View.performClick(
        at android.view.View$
        at android.os.Handler.handleCallback(
        at android.os.Handler.dispatchMessage(
        at android.os.Looper.loop(
        at java.lang.reflect.Method.invoke(Native Method)
  2. JohnC

    JohnC Well-Known Member Licensed User

    Why don't you break up the text into 1000 or so characters at a time, with the break being at the end of sentences, so the pause will be expected while your app sends the next 1000 characters to the TTS engine?
  3. emexes

    emexes Well-Known Member Licensed User

    Or you can do TTS to audio files, and then play one file whilst preparing the next. This would reduce the inter-batch delay for TTS processing to a small (possibly zero) and constant duration.

    Also, if you break on paragraphs rather than sentences, it might be easier to find suitable break/pause points, since most text formats have a newline at the end of a paragraph and/or a blank line between paragraphs.

    I have a vague recollection of somebody doing that with a book reader or training program, but can't find the thread.
  4. kisoft

    kisoft Active Member Licensed User

    Last edited: Jul 25, 2019
  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