Search code examples
python-3.xespeak

Espeak phrase stops on the first word with os


why espeak can't read long line phrase?

text = "Do Androids Dream of Electric Sheep?"

os.system('.\\espeak.exe %(text)s' % locals())

and I have only "Do...", same here:

os.system(".\\espeak.exe \'Do Androids Dream of Electric Sheep?\' ")

what I have to do?


Solution

  • I tried following way and it works for me. I am using Windows 2013 and Python 2.7.

    We need to join words with '_' (underscore). Somehow the word separation using blank space seems to cause problem.

    text = "Do Androids Dream of Electric Sheep?"  #Your original text
    text = text.replace(" ", "_")                  #join words with underscore
    os.system('.\\espeak.exe %(text)s' % locals()) #speak words
    

    EDIT Actually following works better than just introducing special characters like "," or "_" in between words.

    From eSpeak site

    -g Word gap. This option inserts a pause between words. The value is the length of the pause, in units of 10 mS (at the default speed of 170 wpm).

    Here's working code:

    text = 'Do Androids Dream of Electric Sheep?'
    text = text.replace(' ', '_')
    os.system('.\\espeak.exe  -g 20 %(text)s'  % locals())