Last active
December 19, 2015 09:29
-
-
Save electronut/5933641 to your computer and use it in GitHub Desktop.
Testing Raspberry Pi audio using pyttsx - Python Cross-platform text-to-speech wrapper.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################################### | |
# speech-test.py | |
# | |
# Author: electronut.in | |
# | |
# Description: | |
# | |
# Testing Raspberry Pi audio using pyttsx - Python Cross-platform | |
# text-to-speech wrapper | |
# | |
# test run: | |
# | |
# python speech-test.py "hello there" | |
############################################################################### | |
import sys | |
import pyttsx | |
# main() function | |
def main(): | |
# use sys.argv if needed | |
print 'running speech-test.py...' | |
engine = pyttsx.init() | |
str = "I speak. Therefore. I am. " | |
if len(sys.argv) > 1: | |
str = sys.argv[1] | |
engine.say(str) | |
engine.runAndWait() | |
# call main | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment