有没有办法通过Python调用Bing Text To Speech API或IBM Text To Speech API?
也许是以Python SpeechRecognition库工作的方式?
答案 0 :(得分:3)
对于Bing翻译,请设置BING_KEY=**your key**
。
然后,您可以按bing_en_US=recognizer.recognize_bing(audio, key=BING_KEY, language="en-US")
进行翻译。
参考:https://pypi.python.org/pypi/SpeechRecognition/
在此处获取您的密钥:https://azure.microsoft.com/en-us/try/cognitive-services/?api=speech-api
答案 1 :(得分:1)
我相信你可以补充:
return recognizer.recognize_ibm(audio)
在下载了您需要的所有内容后,在代码中,包括IBM zip文件:
https://github.com/watson-developer-cloud/speech-to-text-websockets-python
继承了整个代码:
import speech_recognition
while 1:
recognizer = speech_recognition.Recognizer()
def listen():
with speech_recognition.Microphone() as source:
recognizer.adjust_for_ambient_noise(source)
audio = recognizer.listen(source)
try:
# return recognizer.recognize_sphinx(audio)
#return recognizer.recognize_google(audio)
return recognizer.recognize_ibm(audio)
except speech_recognition.UnknownValueError:
print("Could not understand audio")
except speech_recognition.RequestError as e:
print("Recog Error; {0}".format(e))
return ""
listen()
print (listen())