BigJeffIE
Posts: 26
Joined: Fri May 11, 2012 7:55 pm

espeak and python

Fri Dec 21, 2012 10:06 am

Hi all,

I'm trying to write a program to help my son with his spellings.

I'm having problems hiding the alsa output when I use the espeak command within python.

The code is as follows (not mine, taken from some one elses)...

def say(something):
os.system('espeak -ven+f3 "{0}"'.format(something))

From my reading up on the problem you can hide the output by sending it to null with

2>/dev/null

but I can't get the python syntax right when I add it to my command...

def say(something):
os.system('espeak -ven+f3 "{0}"'.format(something)) 2>/dev/null

I've tried every combination of brackets, commas, quotes etc I can think of but it always fails.

Could someone point me in the right direction please?

Thanks,

Chris

User avatar
davef21370
Posts: 897
Joined: Fri Sep 21, 2012 4:13 pm
Location: Earth But Not Grounded

Re: espeak and python

Fri Dec 21, 2012 3:50 pm

Not tried this myself yet but going to try...

sudo apt-get install espeak python-espeak

in a terminal window then...

espeak.synth("something to say")

in the script.

If you try this before me let me know how it goes and I'll do the same.
Apple say... Monkey do !!

BigJeffIE
Posts: 26
Joined: Fri May 11, 2012 7:55 pm

Re: espeak and python

Fri Dec 21, 2012 5:34 pm

Hi Dave,

The python-espeak seemed to install ok but I'm not having any luck getting it running in a python script.

I'll keep playing around with it to see if I can get it to work.

Regards

Chris

User avatar
fdion
Posts: 307
Joined: Sun Sep 16, 2012 2:33 pm
Location: North Carolina, USA
Contact: Website

Re: espeak and python

Sun Dec 23, 2012 1:50 am

You are probably referring to:
http://raspberry-python.blogspot.com/20 ... speak.html

emyr posted the fix for espeak here:

http://www.raspberrypi.org/phpBB3/viewt ... 15#p228415

Francois
Francois
http://raspberry-python.blogspot.com - http://www.3dFutureTech.info - @f_dion

BigJeffIE
Posts: 26
Joined: Fri May 11, 2012 7:55 pm

Re: espeak and python

Sun Dec 23, 2012 5:05 pm

Yes, that's where the code is from, thanks for the inspiration Francois.

It was you're article that got me started :-)

I'll try the fix and see how I get on.

Regards,

Chris

BigJeffIE
Posts: 26
Joined: Fri May 11, 2012 7:55 pm

Re: espeak and python

Sun Dec 23, 2012 6:18 pm

Hmmm, now I'm confused again.

If I try and find that file I find it in

./pymodules/python2.7/espeak/espeak.py

I'm using Raspian Wheezy.

If I edit it there's nothing about EspeakDriver._defaultVoice = self.getProperty('voice') and it looks nothing like this

http://nullege.com/codes/show/src@pytts ... @espeak.py

which I assume it should do.

I've done apt-get install espeak and python-espeak and they seem to have both installed.

should I be looking in a different location?

Thanks,

Chris

-rst-
Posts: 1316
Joined: Thu Nov 01, 2012 12:12 pm
Location: Dublin, Ireland

Re: espeak and python

Fri Dec 28, 2012 5:04 pm

BigJeffIE wrote:...
def say(something):
os.system('espeak -ven+f3 "{0}"'.format(something))

From my reading up on the problem you can hide the output by sending it to null with

2>/dev/null

but I can't get the python syntax right when I add it to my command...

def say(something):
os.system('espeak -ven+f3 "{0}"'.format(something)) 2>/dev/null

...
As far as I understand, it should all be in the command sent to the system - you could/should try it on the command line manually first - something like this:

Code: Select all

espeak -ven+f3 "hello, world" >/dev/null
...and in your python code:

Code: Select all

    os.system('espeak -ven+f3 "{0}" >/dev/null'.format(something))
...or even better for debugging:

Code: Select all

    cmd_string = 'espeak -ven+f3 "{0}" >/dev/null'.format(something)
    print cmd_string
    os.system(cmd_string)
(comment out the print line when got it right)
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'

BigJeffIE
Posts: 26
Joined: Fri May 11, 2012 7:55 pm

Re: espeak and python

Mon Jan 07, 2013 1:10 pm

Thanks RST, I'll give them a try and report back.

Regards

Chris

Return to “Python”