Used this standard code for speech recognition:
import sys
sys.path.append('/home/nagy/.local/lib/python3.9/site-packages')
import speech_recognition
import pyttsx3
r = speech_recognition.Recognizer()
while True:
with speech_recognition.Microphone() as mic:
r.adjust_for_ambient_noise(mic,duration=0.2)
audio = r.listen(mic)
words = r.recognize_sphinx(audio)
words=words.lower()
print(words)
This is the error I receivee:
Traceback (most recent call last):
File "speech.py", line 3, in <module>
import speech_recognition
File "/home/nagy/.local/lib/python3.9/site-packages/speech_recognition/__init__.py", line 1513
endpoint = f"https://api.assemblyai.com/v2/transcript/{transciption_id}" ^
SyntaxError: invalid syntax
I'm not sure exactly what the error is but I know it's in the speech recognition library.
Related
I wasn't very sure on what to title this question so I'm sorry if it's not understandable. This project that I've been working on is a Jarvis-related project (Python) recently and this is my error
Traceback (most recent call last):
File "C:\Users\Admin\Rohan_Python\Virtual Assistant.py", line 13, in <module>
text = recog.recognize_google(sound)
File "D:\Rohan_Python\lib\site-packages\speech_recognition\__init__.py", line 858, in
recognize_google
if not isinstance(actual_result, dict) or len(actual_result.get("alternative", [])) == 0: raise
UnknownValueError()
speech_recognition.UnknownValueError
My code...
import pyttsx3 as py
import speech_recognition as sr
# initializing speech_recognition
engine = py.init()
engine.say("Hey there! I'm Trevor. A virtual assistant for
programmers.")
engine.runAndWait()
recog = sr.Recognizer()
with sr.Microphone() as Sound_source:
recog.energy_threshold = 10000
recog.adjust_for_ambient_noise(Sound_source, 1.2)
print("Listening...")
sound = recog.listen(Sound_source)
text = recog.recognize_google(sound)
print(text)
I think this might be a simple error but could someone explain what the error means and what my error is? Also do give me the solution. Please and Thanks!
Recognition failed. You should catch that error:
try:
text = recog.recognize_google(sound)
print(text)
except sr.UnknownValueError:
print("Could not understand")
I'm getting an error I have never seen in python before, and I'm having trouble finding any information on the internet that solves my problem. I'm trying to program a voice assistant. Here is my code:
from fuzzywuzzy import fuzz
import sys
#sys.path.insert(0, '/home/pi/AIY-voice-kit-python/src/aiy/voice')
from aiy.voice import tts
#import tts
tts.say('Harry activated')
from os import environ, path
import os
#sys.path.insert(0, '/home/pi/AIY-voice-kit-python/src/examples/voice')
#from __init__ import LiveSpeech, get_model_path
from pocketsphinx import LiveSpeech, get_model_path
model_path = get_model_path()
print("active")
speech = LiveSpeech(
verbose=False,
sampling_rate=16000,
buffer_size=2048,
no_search=False,
full_utt=False,
hmm=os.path.join(model_path, 'en-us'),
lm=os.path.join(model_path, 'en-us.lm.bin'),
dic=os.path.join(model_path, 'cmudict-en-us.dict')
)
for phrase in speech:
p = str(phrase)
print(p)
r1 = (fuzz.ratio(p,"harry"))
print(r1)
ri = int(r1)
if ri > 60():
print("you said my name")
I'm not having any problems with imports. It's just the speech recognition has accuracy issues which is why I'm experimenting with "fuzzywuzzy". Python spits this error at me:
Traceback (most recent call last):
File "/home/pi/Desktop/AIY-projects-python/src/examples/voice/speack.py", line 31, in <module>
if ri > 60():
TypeError: 'int' object is not callable
I don't know where to go from here. Does anyone know how to resolve this issue? (Yes I know stackoverflow already has a similar question, but the answers don't seem to apply my situation)
I don't think that you need the () so try
int(ri) > 60:
We are trying to use Azure Machine Learning to interpret a model by using Azure ML Interpretability libraries namely azureml-interpret and azureml-sdk[explain].
Our model is RandomForestRegressor from sklearn.ensemble.
import lightgbm
from interpret.ext.blackbox import PFIExplainer
#from interpret.ext.glassbox import DecisionTreeExplainableModel
from azureml.contrib.interpret.explanation.explanation_client import ExplanationClient
model = train_model(X_train_df,y_train_df)
explainer = PFIExplainer(model, features = feature_names)
global_explanation = explainer.explain_global(X_test_df[0:50],true_labels=y_test_df[0:50])
explain_client = ExplanationClient.from_run(run)
explain_client.upload_model_explanation(global_explanation)
We are getting the following error
Traceback (most recent call last):
File "training/train.py", line 83, in <module>
explain_client.upload_model_explanation(global_explanation)
File "/azureml-envs/azureml_d5d57a45ca9af991b8408524822c201f/lib/python3.6/site-packages/azureml/interpret/_internal/explanation_client.py", line 793, in upload_model_explanation
asset_type=History.ASSET_TYPE
TypeError: create_asset() got an unexpected keyword argument 'asset_type'
We have tried -
TabularExplainer, MimicExplainer(with DecisionTreeExplainableModel) but all of them result in the same error.
i am trying to convert text to speech using pyttsx3 in python. but iam getting the error -- _pickle.UnpicklingError: invalid load key, '\x00'.
it worked once. later it didn't
my code
import pyttsx3
engine = pyttsx3.init()
engine.say("I will speak this text")
engine.runAndWait()
error i am receiving is --
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\pyttsx3__init__.py",
line 20, in init
eng = _activeEngines[driverName]
File "C:\ProgramData\Anaconda3\lib\weakref.py", line 137, in
getitem
o = self.data[key]()
KeyError: None
During handling of the above exception, another exception occurred:
...
File "C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\gencache.py", line 113, in _LoadDicts
version = p.load()
_pickle.UnpicklingError: invalid load key, '\x00'.
python version is 3.7.3 |
pyttsx3 version is 2.71|
pywin32 version is 224
please help
I had this problem as well and fixed it by deleting gen_py in my temp directory.
You can find this folder here:
C:\Users\USERNAME\AppData\Local\Temp\gen_py
when i run the the given code in prepare_dataset.py whose code is below as
from urllib.request
import urlopen
import json as simplejson
def main():
# Download and prepare datasets
list_generator = video_list_generator.Generator("playlists.json", youtube_api_client.Client("AIzaSyD_UC-FpXbJeWzPfscLz9RhqSjKwj33q6A"))
video_list = list_generator.get_video_list("piano")
downloader = youtube_video_downloader.Downloader()
downloader.download_from_list(video_list)
if __name__ == '__main__':
main()
as python prepare_dataset.py in command-line then i get these errors
Traceback (most recent call last):
File "prepare_dataset.py", line 1, in <module>
from urllib.request import urlopen
ImportError: No module named request
How can i get to run the above file any idea guys?