Google API语音识别出现问题

问题描述

由于我与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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...