Skip to content

Instantly share code, notes, and snippets.

@bitstein
Created April 1, 2016 01:40
Show Gist options
  • Save bitstein/1af2dca90b7b69f67c9965ea945f9fa3 to your computer and use it in GitHub Desktop.
Save bitstein/1af2dca90b7b69f67c9965ea945f9fa3 to your computer and use it in GitHub Desktop.
ocr2speech21
import base64
import two1.mkt as mkt
image_url = "http://i.imgur.com/U86mtM1.png"
chinese_text = mkt.ocr2txt21.detect(image_url=image_url)['text']
english_text = mkt.translate21.translate(text=chinese_text)['results']
wavfile = mkt.txt2speech21.en({"text": english_text.strip()})['data']
with open('output.wav', 'wb') as file:
file.write(base64.b64decode(wavfile))
file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment