PDA

View Full Version : [SOLVED] Need some help with python programing



robro
April 18th, 2011, 08:43 AM
Hello community,
I am trying to make a (rather simple) gui for spd-say (text to speech) and am having some trouble getting it working, here is my code so far:



import os #for running spd-say
import easygui #the gui

speech = easygui.enterbox("Enter something to say:") #making of the gui
os.system('spd-say' , speech) #running spd-say
And here is the output when I run it:



Traceback (most recent call last):
File "test-speech.py", line 6, in <module>
os.system('spd-say' , speech)
TypeError: system() takes exactly 1 argument (2 given)
Thanks for the help :)

unknownPoster
April 18th, 2011, 08:51 AM
That error message explains itself.

http://docs.python.org/library/os.html#os.system

The function takes one parameter, you're passing it two parameters.

kostkon
April 18th, 2011, 08:55 AM
You need to pass the command as one string, e.g.:

os.system("%s %s" % ("spd-say", speech))
but you should learn to use the subprocess module (http://docs.python.org/release/2.6.5/library/subprocess.html).

robro
April 18th, 2011, 09:06 AM
Thanks for the help, it works great now :)