Skip to content

Instantly share code, notes, and snippets.

@anna-is-cute
Created May 27, 2014 05:00
Show Gist options
  • Save anna-is-cute/ec8c716542a4757ac6dd to your computer and use it in GitHub Desktop.
Save anna-is-cute/ec8c716542a4757ac6dd to your computer and use it in GitHub Desktop.
Google Voice
from os import listdir
from urllib2 import urlopen
from sys import argv
from subprocess import call
if len(argv) < 2:
quit()
words = argv[1:]
for word in words:
files = listdir(".")
if ("%s.mp3" % word) in files: continue
try:
r = urlopen("http://ssl.gstatic.com/dictionary/static/sounds/de/0/%s.mp3" % word).read()
except:
continue
f = open("%s.mp3" % word, "w")
f.write(r)
f.flush()
f.close()
for word in words:
call(["/usr/bin/afplay", "%s.mp3" % word])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment