Android Question Text To Speech

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

  1. kisoft

    kisoft Active Member Licensed User

    Hi
    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:
    Code:
    Error occurred on line: 123 (Main)
    java.lang.RuntimeException: Error speaking text.
        at anywheresoftware.b4a.obejcts.TTS.Speak(
    TTS.java:45)
        at java.lang.reflect.Method.invoke(Native Method)
        at anywheresoftware.b4a.shell.Shell.runVoidMethod(
    Shell.java:777)
        at anywheresoftware.b4a.shell.Shell.raiseEventImpl(
    Shell.java:354)
        at anywheresoftware.b4a.shell.Shell.raiseEvent(
    Shell.java:255)
        at java.lang.reflect.Method.invoke(Native Method)
        at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:
    144)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
    180)
        at anywheresoftware.b4a.BA.raiseEvent(BA.java:
    176)
        at anywheresoftware.b4a.objects.ViewWrapper$
    1.onClick(ViewWrapper.java:80)
        at android.view.View.performClick(
    View.java:6274)
        at android.view.View$PerformClick.run(
    View.java:24859)
        at android.os.Handler.handleCallback(Handler.java:
    789)
        at android.os.Handler.dispatchMessage(Handler.java:
    98)
        at android.os.Looper.loop(Looper.java:
    164)
        at android.app.ActivityThread.main(ActivityThread.java:
    6710)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:
    240)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:
    770)
     
  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
Loading...
  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