Firstly I know this question has been asked, Natural Sounding Text to Speech?

I'm after some sort of text to speech engine, but to convert a full ebook / text. Simply put I no longer get enough time to sit and read but travel a lot so enjoy listening to audiobooks and have tried all the suggestions listed...but...

I really like user85321's suggestion and little script, its compact and to the point, but for some reason any text larger than a few paragraphs ends in an error message about to many args:

bash: ./speech.sh: Argument list too long

Is there any way I could alter the script or add to the script to prevent this?

I like the pico2wav voice, there's less lag/pauses as with googleTTs, yes there is the odd spelling issue "T H E" instead of "The", but all in all the speech seems to flow a little better and I prefer it over festival / embrola.

I've even tried the scripts using GoogleTTs as listed in the original post, including the one that has the fallback of using pico2wav as an offline backup. Unfortunately, even after breaking the book down into chunks via split, they stop at random intervals,so trying to piece together random chunks of speech is a royal PITA.

My last port of call was the read text plugin for libreoffice(which uses pico2wav), this seems to have the same issue with args as it keels over after a while.

After trawling over this for the past few months, I am now at a brick wall so any help or suggestions would be much appreciated.

Thanks for reading my scribble.

  • What format is your source file in? – Ian Gibbs Oct 20 '16 at 10:22
  • 2
    Possible duplicate of Natural Sounding Text to Speech? – user68186 Oct 20 '16 at 10:56
  • 1
    What is this script? Please include it in your question. Also tell us how you're running it when you get the "Argument list too long" error. On what input? – terdon Oct 20 '16 at 11:14

For whatever reason, pico2wave only accepts input as arguments. Therefore, the length of text it can process at once is limited by the max argument size. You could perhaps Use xargs to split the text into parts not exceeding this limit. Run that script using xargs this way:

xargs -a input.txt ./speech.sh

Relevant xargs option which you won't need to use:

-s max-chars
      Use at most max-chars characters per command line, including the
      command  and  initial-arguments and the terminating nulls at the
      ends of the argument strings.   The  largest  allowed  value  is
      system-dependent, and is calculated as the argument length limit
      for exec, less the size of your environment, less 2048 bytes  of
      headroom.   If this value is more than 128KiB, 128Kib is used as
      the default value; otherwise, the default value is the  maximum.
      1KiB is 1024 bytes.

I had a similar issue and ran across the following script that worked for me: https://github.com/GwadaLUG/pico-read-speaker This is a python script that will split up the text file into pieces and pass them to pico2wave. It then combines all of the output .wav files into one giant .wav.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.