问题描述
由于我与Google的连接有问题,因此我需要找到另一个API。但对于我来说,替换它有点困难,因为需要放置一些我确切不知道的参数。
enter code here
def assistant_speak(audio_string):
tts = gTTS(text=audio_string,lang='en')
r = random.randint(1,10000000)
audio_file = 'audio-' + str(r) + '.mp3'
tts.save(audio_file)
playsound.playsound(audio_file)
print(audio_string)
os.remove(audio_file)
def record_audio(ask = False):
with m as source: r.adjust_for_ambient_noise(source,duration=1)
#print ("set minimum energy threshold to{}".format(r.energy_threshold))
with sr.Microphone() as source:
if ask:
assistant_speak(ask)
audio = r.listen(source)
voice_data = ''
try:
voice_data = r.recognize_google(audio)
except sr.UnkNownValueError:
assistant_speak ('Sorry,your command is unclear!')
except sr.RequestError :
assistant_speak ('Sorry,I cannot Reach the Network')
return voice_data
在这种情况下,除了使用api之外,我还想将我的API语音转换为文本 我想将其更改为另一种。此行代码“ voice_data = r.recognize_google(音频)”
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)