pythonespeak

How to fix executing espeak in python using subprocess


I am trying to execute espeak using python using an MBROLA voice "us1".

from subprocess import call

call(["espeak","-v mb-us1","Hello, I am espeak"])

and the following error appear'

Failed to read voice ' mb-us1'

but it works fine with:

os.system("espeak -v mb-us1 'hello, I am espeak'")

Solution

  • You hava to split "-v mb-us1" in two list elements.

    from subprocess import call
    
    call(["espeak", "-v", "mb-us1", "Hello, I am espeak"]) 
    

    The nth element of the list will be treated a the nth argument of the subprocess call.

    In your case "-v mb-us1" was treated as a single argument instead of two seperate arguments.