I'm working on a voice recognition project using the Google Speech Recognition API and every time I try to run the program, it gives me the same error each time:
Traceback (most recent call last):
File "pook.py", line 4, in <module>
with sr.Microphone() as source:
File "Random File name", line 79, in __init__
self.pyaudio_module = self.get_pyaudio()
File "Random File name", line 110, in get_pyaudio
raise AttributeError("Could not find PyAudio; check installation")
AttributeError: Could not find PyAudio; check installation
I've tried to see every post with this same exact error, but none of them seem to work.
Related
I have a Python Code to conduct an experiment. To ensure that the Code is working smoothly I wanted to run a trial round via 'otree devserver', but I always get an AttributeError message and I am stuck here. Can anyone help me out?
I have downloaded the Code from GitHub and downloaded all required packages. I am using macOS, otree-5.10.2 and django-4.1.7. Here is my full traceback / error message:
Traceback (most recent call last): File
"/Users/.otreevenv/bin/otree", line 8, in
sys.exit(execute_from_command_line()) File "/Users/.otreevenv/lib/python3.10/site-packages/otree/main.py", line
108, in execute_from_command_line
setup() File "/Users/.otreevenv/lib/python3.10/site-packages/otree/main.py", line
132, in setup
from otree import settings File "/Users/.otreevenv/lib/python3.10/site-packages/otree/settings.py",
line 50, in
OTREE_APPS = get_OTREE_APPS(settings.SESSION_CONFIGS) File "/Users/.otreevenv/lib/python3.10/site-packages/django/conf/__init__.py",
line 94, in __getattr__
val = getattr(_wrapped, name) File "/Users/.otreevenv/lib/python3.10/site-packages/django/conf/__init__.py",
line 270, in __getattr__
return getattr(self.default_settings, name) AttributeError: module 'django.conf.global_settings' has no attribute 'SESSION_CONFIGS'. Did
you mean: 'SESSION_ENGINE'?
First few steps working , but error is coming that
Terminal Output (vs, pycharm, all of them , say same)
Traceback (most recent call last):
File "C:#################\ai.py", line 39, in takeCommand
audio = r.listen(source)
File "C:#################\Python\Python310\lib\site-packages\speech_recognition_init_.py", line 651, in listen
assert source.stream is not None, "Audio source must be entered before listening, see documentation for AudioSource; are you using source outside of a with statement?"
AssertionError: Audio source must be entered before listening, see documentation for AudioSource; are you using source outside of a with statement?
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:####################\ai.py", line 64, in <module>
query = takeCommand().lower()
File "C:#####3###############\ai.py", line 36, in takeCommand
with sr.Microphone() as source:
File "C:###############\Python\Python310\lib\site-packages\speech_recognition_init_.py", line 201, in exit
self.stream.close()
AttributeError: 'NoneType' object has no attribute 'close'
Process finished with exit code 1
I have never encountered this with my laptop. It's happening on friend's laptop. And nothing , absolutely nothing is fixing it, Now what?
i was expecting it to listen , but speech recognitions is not working!
i have an error with speech recognition and pyaudio but it's all installed
PS C:\Users\giova> & C:/Users/giova/AppData/Local/Microsoft/WindowsApps/python3.10.exe
"c:/Users/giova/OneDrive/Desktop/python/ai e assistenti/assistente tutorial pit pro/assis.py"
Traceback (most recent call last):
File "C:\Users\giova\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\speech_recognition\__init__.py", line 108, in get_pyaudio
import pyaudio
ModuleNotFoundError: No module named 'pyaudio'
AttributeError: Could not find PyAudio; check installation
PS C:\Users\giova> & C:/Users/giova/AppData/Local/Microsoft/WindowsApps/python3.10.exe "c:/Users/giova/OneDrive/Desktop/python/ai e assistenti/assistente tutorial pit pro/assis.py"
Traceback (most recent call last):
File "C:\Users\giova\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\speech_recognition\__init__.py", line 108, in get_pyaudio
import pyaudio
ModuleNotFoundError: No module named 'pyaudio'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users\giova\OneDrive\Desktop\python\ai e assistenti\assistente tutorial pit pro\assis.py", line 9, in <module>
with Microphone() as source:
File "C:\Users\giova\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\speech_recognition\__init__.py", line 79, in __init__
self.pyaudio_module = self.get_pyaudio()
File "C:\Users\giova\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\speech_recognition\__init__.py", line 110, in get_pyaudio
raise AttributeError("Could not find PyAudio; check installation")
AttributeError: Could not find PyAudio; check installation
with this code :
from pyttsx3 import init
from speech_recognition import Recognizer, Microphone
engine = init()
engine.say("che cavolo vuoi")
engine.runAndWait()
r = Recognizer()
with Microphone() as source:
print("pronto ad ascoltare...")
audio = r.listen(source)
testo = r.recognize_google(audio, Lenguage="it-IT")
print(testo)
I am following an tutorial and idk why this error appears to me
I have a script, which has been working fine in April 2021 when I created it, but now it gives me the following error. I'm not very experienced in coding, so if anyone can help me it would be great.
What I'm trying to do is simply download a song from youtube as a mp4. I can see that the error says there is something wrong with the pytube module imported, but I am not skilled enough to see what it is.
I'm using MacOS 12.1, Pycharm 2020.3, and Python 3.9.
Script:
import pytube
url = str('https://www.youtube.com/watch?v=gJLIiF15wjQ')
youtube = pytube.YouTube(url)
video = youtube.streams.get_by_itag(140)
video.download(output_path='/Users/clarajacobsen/Documents/TrueFIR/Klub100/Songs/', filename='test')
Error:
Traceback (most recent call last):
File "/Users/user/Documents/Folder1/venv/test.py", line 8, in <module>
video = youtube.streams.get_by_itag(140)
File "/Users/user/Documents/Folder1/venv/lib/python3.9/site-packages/pytube/__main__.py", line 292, in streams
return StreamQuery(self.fmt_streams)
File "/Users/user/Documents/Folder1/venv/lib/python3.9/site-packages/pytube/__main__.py", line 177, in fmt_streams
extract.apply_signature(stream_manifest, self.vid_info, self.js)
File "/Users/user/Documents/Folder1/venv/lib/python3.9/site-packages/pytube/extract.py", line 409, in apply_signature
cipher = Cipher(js=js)
File "/Users/user/Documents/Folder1/venv/lib/python3.9/site-packages/pytube/cipher.py", line 43, in __init__
self.throttling_plan = get_throttling_plan(js)
File "/Users/user/Documents/Folder1/venv/lib/python3.9/site-packages/pytube/cipher.py", line 387, in get_throttling_plan
raw_code = get_throttling_function_code(js)
File "/Users/user/Documents/Folder1/venv/lib/python3.9/site-packages/pytube/cipher.py", line 301, in get_throttling_function_code
code_lines_list = find_object_from_startpoint(js, match.span()[1]).split('\n')
AttributeError: 'NoneType' object has no attribute 'span'
After trying out solution 1, suggested by Sarim, error in PyCharm:
Traceback (most recent call last):
File "/Users/user/Documents/Folder1/venv/lib/python3.9/site-packages/pytube/__main__.py", line 177, in fmt_streams
extract.apply_signature(stream_manifest, self.vid_info, self.js)
File "/Users/user/Documents/Folder1/venv/lib/python3.9/site-packages/pytube/extract.py", line 409, in apply_signature
cipher = Cipher(js=js)
File "/Users/user/Documents/Folder1/venv/lib/python3.9/site-packages/pytube/cipher.py", line 29, in __init__
self.transform_plan: List[str] = get_transform_plan(js)
File "/Users/user/Documents/Folder1/venv/lib/python3.9/site-packages/pytube/cipher.py", line 197, in get_transform_plan
return regex_search(pattern, js, group=1).split(";")
File "/Users/user/Documents/Folder1/venv/lib/python3.9/site-packages/pytube/helpers.py", line 129, in regex_search
raise RegexMatchError(caller="regex_search", pattern=pattern)
pytube.exceptions.RegexMatchError: regex_search: could not find match for iha=function\(\w\){[a-z=\.\(\"\)]*;(.*);(?:.+)}
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/user/Documents/Folder1/venv/test.py", line 5, in <module>
video = youtube.streams.get_by_itag(140)
File "/Users/user/Documents/Folder1/venv/lib/python3.9/site-packages/pytube/__main__.py", line 292, in streams
return StreamQuery(self.fmt_streams)
File "/Users/user/Documents/Folder1/venv/lib/python3.9/site-packages/pytube/__main__.py", line 184, in fmt_streams
extract.apply_signature(stream_manifest, self.vid_info, self.js)
File "/Users/user/Documents/Folder1/venv/lib/python3.9/site-packages/pytube/extract.py", line 409, in apply_signature
cipher = Cipher(js=js)
File "/Users/user/Documents/Folder1/venv/lib/python3.9/site-packages/pytube/cipher.py", line 29, in __init__
self.transform_plan: List[str] = get_transform_plan(js)
File "/Users/user/Documents/Folder1/venv/lib/python3.9/site-packages/pytube/cipher.py", line 197, in get_transform_plan
return regex_search(pattern, js, group=1).split(";")
File "/Users/user/Documents/Folder1/venv/lib/python3.9/site-packages/pytube/helpers.py", line 129, in regex_search
raise RegexMatchError(caller="regex_search", pattern=pattern)
pytube.exceptions.RegexMatchError: regex_search: could not find match for iha=function\(\w\){[a-z=\.\(\"\)]*;(.*);(?:.+)}
After trying to run it in Google Colab:
/usr/local/lib/python3.7/dist-packages/pytube/cipher.py in get_throttling_function_code(js)
299
300 # Extract the code within curly braces for the function itself, and merge any split lines
--> 301 code_lines_list = find_object_from_startpoint(js, match.span()[1]).split('\n')
302 joined_lines = "".join(code_lines_list)
303
AttributeError: 'NoneType' object has no attribute 'span'
To fix this issue, This doesnt depends on which operating system you are on or which python you are using. Follow these steps:
I used Colab for this, if you are using Google colab use it and test it.
Install Pytube with !pip install pytube
After installing pytube just shutdown the kernel and the application you are using for it. either VSCode, Jupyter notebook or Colab. shut down its kernel.
Then run the enviroment again and try importing and running your code.
It should run now.
or if it gives you the same error as before:
Go to the files where pytube is install and go to folder in pytube named "pytube" then go into "cipher.py" and open it.
Search for the line: 293. Where name = re.escape(get_throttling_function_name(js))
Replace name = "iha"
Then close all kernels and file you are running the code on. and restart them completely after shutting down.
These two solutions should work 100%. Solution that worked for me is first one.
As the error tells us, you have a NoneType object called youtube in line 8 which was created before in line 7. Did you check if the YouTube link or anything on that video page that concerns you has changed?
I'm planning to use the Language-check module for python 3 in my poem making code. I was just testing it with
import language_tool
lang_tool = language_tool.LanguageTool("en-US")
text = "A sentence with a error in the Hitchhiker’s Guide tot he Galaxy"
matches = lang_tool.check(text)
print(len(matches))
but it gave me this error.
Traceback (most recent call last):
File "/home/runner/.site-packages/language_tool/__init__.py", line 548, in get_server_cmd
cmd = cache["server_cmd"]
KeyError: 'server_cmd'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/runner/.site-packages/language_tool/__init__.py", line 559, in get_jar_info
java_path, jar_path = cache["jar_info"]
KeyError: 'jar_info'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 10, in <module>
lang_tool = language_tool.LanguageTool("en-US")
File "/home/runner/.site-packages/language_tool/__init__.py", line 188, in __init__
self._start_server_on_free_port()
File "/home/runner/.site-packages/language_tool/__init__.py", line 323, in _start_server_on_free_port
cls._start_server()
File "/home/runner/.site-packages/language_tool/__init__.py", line 335, in _start_server
server_cmd = get_server_cmd(cls._port)
File "/home/runner/.site-packages/language_tool/__init__.py", line 550, in get_server_cmd
java_path, jar_path = get_jar_info()
File "/home/runner/.site-packages/language_tool/__init__.py", line 563, in get_jar_info
raise JavaError("can’t find Java")
language_tool.JavaError: can’t find Java
I've looked at some similar questions and I know I probably need to put something in 'Path' but I don't know what specifically to enter. Thanks for your help!
Also I'm on doing this on repl.it, not IDLE.
Note: I'm adding this as an actual answer because the question was resolved in the comments.
Your question says:
Also I'm on doing this on repl.it, not IDLE.
That means that you need to install this module and all its prerequisites into your repl.it environment, not into your local machine.
On the BitBucket link you provided, under "Prerequisites", the page says:
LanguageTool requires Java 6 or later.
So you will need to ensure Java is installed into your repl.it environment somehow. I don't know whether that is possible or not. Alternatively, you can simply install this package and all its prerequisites locally instead.