While Mac Osx Has The Say Command To Speak, Or So To Say, Is There Any Command That Is Similar For Python?
While Mac OSX 10.11.5 (El Capitan) has the 'say' command to speak in a system generated voice, or so to say, is there any command that is similar for Python that can be used in Pyt
Solution 1:
You can use subprocess as follows:
importsubprocessmy_message="hello there"
subprocess.call(["say", my_message])
Solution 2:
PyTTSx package will help you with this. PyTTSx is a Python package supporting common text-to-speech engines on Mac OSX, Windows, and Linux. Speaking text
importpyttsxengine= pyttsx.init()
engine.say('Sally sells seashells by the seashore.')
engine.say('The quick brown fox jumped over the lazy dog.')
engine.runAndWait()
See more examples here
Solution 3:
Thank you everyone for the quick replies. I have been playing with the subprocess module, and I have gotten this to work:import subprocess
m=subprocess.Popen(["say","hello"])
print(m)
The .Popen command is also a quick way to get this to work. However, this is only working on my Mac and I need it to work on my Raspberry Pi for an interactive feature in my code. (I am using Pi Cam and Infrared Sensors for a robot that wheels around and when it senses people in front of it, says "Hey! Please move out of my way please!"
Post a Comment for "While Mac Osx Has The Say Command To Speak, Or So To Say, Is There Any Command That Is Similar For Python?"