gpt4 book ai didi

python - ValueError : Unable to find token seed! https ://translate. google.com 是否更改?

转载 作者:行者123 更新时间:2023-12-04 11:30:20 26 4
gpt4 key购买 nike

我正在制作一个使用 gTTS 和 Google Speech 的助手,但出现此错误。语音识别很好,因为它可以无误地识别。我用打印功能进行了测试,但是当我想要文本到语音时,这个错误就来了。
...

import speech_recognition as sr
from time import ctime
import time
import playsound
import os
import random
from gtts import gTTS
import webbrowser

r = sr.Recognizer()


def record_audio(ask=False):
with sr.Microphone() as source:
if ask:
watson_speak(ask)
audio = r.listen(source)
voice_data = ''
try:
voice_data = r.recognize_google(audio)
except sr.UnknownValueError:
watson_speak("Sorry, I did not catch that")
except sr.RequestError:
watson_speak("I am offline right now")
return voice_data


def watson_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 respond(voice_data):
if 'what is your name' in voice_data:
watson_speak("My name is Watson")
if 'what time is it' in voice_data:
watson_speak(ctime())
if 'search' in voice_data:
search = record_audio("What do you want to search for?")
url = "https://duckduckgo.com/?t=ffnt&q=" + search
webbrowser.get().open(url)
watson_speak("Here is what I found for " + search)
if 'find location' in voice_data:
location = record_audio("What is the location?")
url = "https://google.nl/maps/place/" + location + "/&"
webbrowser.get().open(url)
watson_speak("Here is the location of " + location)
if 'exit' in voice_data:
exit()


time.sleep(1)
watson_speak("How can I help you?")
while 1:
voice_data = record_audio()
respond(voice_data)
...
不知道我做错了什么。一些指导将不胜感激。它不断要求我不确定的 token 种子。

最佳答案

您应该考虑检查您的 gTTS-token 包版本。如果您通过 pip 安装了该软件包,请在命令提示符下尝试这一行:

pip install gTTS-token --upgrade
这至少在我的情况下是这种错误消息的修复

关于python - ValueError : Unable to find token seed! https ://translate. google.com 是否更改?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64699071/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com