识别Google在SpeechRecognition API python语音数据中的位置

时间:2018-09-09 09:55:40

标签: api speech

如何让Google通过那里的Google Places API来识别地点,我可以获取Google Places API的API密钥,但是无法在下面的代码中找到有关如何识别地点名称的文档。

import speech_recognition as sr
from threading import Thread
r = sr.Recognizer()  
with sr.Microphone() as source:
    r.adjust_for_ambient_noise(source)
    while True:
        print("Please wait. Calibrating microphone...")
        # listen for 5 seconds and create the ambient noise energy leve
        print("Say something!")
        audio = r.listen(source)
        # recognize speech using Sphinx
        try:
           print("Google thinks you said '" + r.recognize_google(audio) + 
"'")
        except sr.UnknownValueError:
            print("Google could not understand audio")
        except sr.RequestError as e:
            print("Google error; {0}".format(e))

0 个答案:

没有答案