Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Bard encountered an error #28

Open
OH2912 opened this issue Jul 6, 2023 · 1 comment
Open

Google Bard encountered an error #28

OH2912 opened this issue Jul 6, 2023 · 1 comment

Comments

@OH2912
Copy link

OH2912 commented Jul 6, 2023

Hi;

I was using the AI to make a Voice Assistant but encounter an error Below you can find my py file:

Google Bard encountered an error: b')]}'\n\n38\n[["wrb.fr",null,null,null,null,[9]]]\n56\n[["di",58],["af.httprm",58,"-8469647117787525651",16]]\n25\n[["e",4,null,null,131]]\n'.

from Bard import Chatbot
from playsound import playsound
import speech_recognition as sr
from os import system
import whisper
import warnings
import sys

token = "YOUR TOKEN"
chatbot = Chatbot(token)
r = sr.Recognizer()

tiny_model = whisper.load_model('tiny')
base_model = whisper.load_model('base')
warnings.filterwarnings("ignore", message="FP16 is not supported on CPU; using FP32 instead")

if sys.platform != 'darwin':
import pyttsx3
engine = pyttsx3.init()
rate = engine.getProperty('rate')
engine.setProperty('rate', rate-50)

def prompt_bard(prompt):
response = chatbot.ask(prompt)
return response['content']

def speak(text):
if sys.platform == 'darwin':
ALLOWED_CHARS = set("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,?!-_$: ")
clean_text = ''.join(c for c in text if c in ALLOWED_CHARS)
system(f"say '{clean_text}'")
else:
engine.say(text)
engine.runAndWait()

def main():
with sr.Microphone() as source:
r.adjust_for_ambient_noise(source)
while True:
while True:
try:
print('\nSay "google" to wake me up. \n')
audio = r.listen(source)
with open("wake_detect.wav", "wb") as f:
f.write(audio.get_wav_data())
result = tiny_model.transcribe('wake_detect.wav')
text_input = result['text']
if 'google' in text_input.lower().strip():
break
else:
print("No wake word found. Try again.")
except:
print("Error transcribe audio: ", e)
continue
try:
playsound('wake_detected.mp3')
print("Wake word detected. Please speak your prompt to Bard. \n")
audio = r.listen(source)
with open("prompt.wav", "wb") as f:
f.write(audio.get_wav_data())
result = base_model.transcribe('prompt.wav')
prompt_text = result['text']
print("Sending to Bard:", prompt_text, '\n')
if len(prompt_text.strip()) == 0:
print("Empty prompt. Please speak again.")
speak("Empty prompt. Please speak again.")
continue
except Exception as e:
print("Error transcribing audio: ", e)
continue
response = prompt_bard(prompt_text)
if sys.platform.startswith('win'):
print('Bards response: ', response)
else:
print('Bards response: ', response)
speak(response)

if name == 'main':
main()

@Triggered0
Copy link

Having the same issue

Error: Google Bard encountered an error )]}'
38
[["wrb.fr",null,null,null,null,[8]]]
56
[["di",95],["af.httprm",94,"-6806050964693520689",48]]
25
[["e",4,null,null,131]]
.

@OH2912 OH2912 closed this as completed Jul 18, 2023
@OH2912 OH2912 reopened this Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants