Skip to content

Instantly share code, notes, and snippets.

@electronut
Last active December 19, 2015 09:29
Show Gist options
  • Save electronut/5933641 to your computer and use it in GitHub Desktop.
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.
###############################################################################
# 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