Skip to content

Instantly share code, notes, and snippets.

@thinkjson
Created June 3, 2014 12:41
Show Gist options
  • Select an option

  • Save thinkjson/2785b4d88a8e7e893d8c to your computer and use it in GitHub Desktop.

Select an option

Save thinkjson/2785b4d88a8e7e893d8c to your computer and use it in GitHub Desktop.
say REPL
import cmd
import os
import subprocess
import shlex
from pipes import quote
devnull = open(os.devnull, 'w')
class Voice(cmd.Cmd):
"""Simple command processor example."""
prompt = '(say) '
def default(self, line):
subprocess.Popen(shlex.split("say %s" % quote(line)), stdout=devnull, stderr=devnull)
if __name__ == '__main__':
try:
Voice().cmdloop()
except KeyboardInterrupt:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment