Reputation: 91
I am new to this kind of programming which involves text to speech or speech to text conversion, that's why I am here for some initial help. I have searched over internet about it and I came across pyttsx for ubuntu, initially I could not get started with it but somehow I managed to do that but now the problem is that I type something like this:
import pyttsx
engine=pyttsx.init()
Its gives a segmentation fault. I need help on that and also tell me if I am using the right tool or not. Thanks in advance!
Upvotes: 4
Views: 11851
Reputation: 1
import pyttsx
engine = pyttsx.init()
engine.setProperty('rate', 75)
for voice in voices:
print "Using voice:", repr(voice)
engine.setProperty('voice', voice.id)
engine.say("How are you doing")
engine.runAndWait()
Upvotes: -1
Reputation: 109
espeak is included in ubuntu by default. Try this one from python.
import os
import datetime
def tts(text):
return os.system("espeak -s 155 -a 200 "+text+" " )
m = datetime.datetime.now().strftime("%I %M %S")
tts("'Sir the time is"+str(int(m[0:2]))+" "+str(int(m[3:5]))+" : ' ")
Upvotes: 10
Reputation: 8036
$ sudo apt-get install sphinx2-bin libsphinx2-dev
# enter your password when prompted
$ python -i
>>> import pyttsx
>>> engine=pyttsx.init()
>>> engine.say('Sally sells seashells by the seashore.')
>>> engine.runAndWait()
Upvotes: 6
Reputation: 13297
You might want to read over the answers in Need text to speech and speech recognition tools for Linux and Speech processing library in Python for speech to text
Why the segmentation fault? This is a a complete guess: you have the API package installed, but you do not have an actual speech engine (like Sphinx) installed. http://pypi.python.org/pypi/pyttsx says:
pyttsx is a Python package supporting common text-to-speech engines on Mac OSX, Windows, and Linux. It currently supports SAPI5, NSSpeechSynthesizer, and espeak. pyttsx requires Mark Hammond's win32com package on Windows.
Do you have one of the supported engines installed?
Upvotes: 2