Created
September 10, 2019 17:07
-
-
Save henry16lin/0b1ac1d32e0aba52a52e9d2fef5ba2df to your computer and use it in GitHub Desktop.
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
def speeker(texts,lang='zh-tw'): | |
mixer.init() | |
with tempfile.NamedTemporaryFile(delete=True) as fp: | |
tts = gTTS(text=texts,lang=lang) | |
tts.save("{}.mp3".format(fp.name)) | |
mixer.music.load('{}.mp3'.format(fp.name)) | |
mixer.music.play() | |
def listener(): | |
r = speech_recognition.Recognizer() | |
with speech_recognition.Microphone() as source: | |
audio = r.listen(source) | |
return r.recognize_google(audio,language = 'zh-tw') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment