Sunteți pe pagina 1din 5

{

"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"ename": "AttributeError",
"evalue": "Could not find PyAudio; check installation",
"output_type": "error",
"traceback": [

"\u001b[0;31m----------------------------------------------------------------------
-----\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback
(most recent call last)",
"\u001b[0;32m~/.local/lib/python3.8/site-
packages/speech_recognition/__init__.py\u001b[0m in
\u001b[0;36mget_pyaudio\u001b[0;34m()\u001b[0m\n\u001b[1;32m 107\u001b[0m
\u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u00
1b[0m\u001b[0m\n\u001b[0;32m--> 108\u001b[0;31m
\u001b[0;32mimport\u001b[0m
\u001b[0mpyaudio\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001
b[0m\u001b[1;32m 109\u001b[0m \u001b[0;32mexcept\u001b[0m
\u001b[0mImportError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34
m\u001b[0m\u001b[0m\n",
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'pyaudio'",
"\nDuring handling of the above exception, another exception occurred:\n",
"\u001b[0;31mAttributeError\u001b[0m Traceback
(most recent call last)",
"\u001b[0;32m<ipython-input-1-517e2618984c>\u001b[0m in
\u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 2\u001b[0m
\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mr\u001b[0m
\u001b[0;34m=\u001b[0m
\u001b[0msr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mRecognizer\u001b[0m\u001b[0;34m(
\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\
n\u001b[0;32m----> 4\u001b[0;31m \u001b[0;32mwith\u001b[0m
\u001b[0msr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mMicrophone\u001b[0m\u001b[0;34m(
\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mas\u001b[0m
\u001b[0msource\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u00
1b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 5\u001b[0m
\u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"speak
anything : \"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b
[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0maudio\u001b[0m
\u001b[0;34m=\u001b[0m
\u001b[0mr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlisten\u001b[0m\u001b[0;34m(\u001
b[0m\u001b[0msource\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m
\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/.local/lib/python3.8/site-
packages/speech_recognition/__init__.py\u001b[0m in
\u001b[0;36m__init__\u001b[0;34m(self, device_index, sample_rate,
chunk_size)\u001b[0m\n\u001b[1;32m 77\u001b[0m
\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 78\u001b[0m \u001b[0;31m#
set up
PyAudio\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u00
1b[0m\n\u001b[0;32m---> 79\u001b[0;31m
\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpyaudio_module\u001b[0m
\u001b[0;34m=\u001b[0m
\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_pyaudio\u001b[0m\u001b[0;3
4m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[
0m\n\u001b[0m\u001b[1;32m 80\u001b[0m \u001b[0maudio\u001b[0m
\u001b[0;34m=\u001b[0m
\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpyaudio_module\u001b[0m\u001b[
0;34m.\u001b[0m\u001b[0mPyAudio\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0
m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 81\u001b[0m
\u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u00
1b[0m\u001b[0m\n",
"\u001b[0;32m~/.local/lib/python3.8/site-
packages/speech_recognition/__init__.py\u001b[0m in
\u001b[0;36mget_pyaudio\u001b[0;34m()\u001b[0m\n\u001b[1;32m 108\u001b[0m
\u001b[0;32mimport\u001b[0m
\u001b[0mpyaudio\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001
b[1;32m 109\u001b[0m \u001b[0;32mexcept\u001b[0m
\u001b[0mImportError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34
m\u001b[0m\u001b[0m\n\u001b[0;32m--> 110\u001b[0;31m
\u001b[0;32mraise\u001b[0m
\u001b[0mAttributeError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Could not find
PyAudio; check
installation\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001
b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 111\u001b[0m
\u001b[0;32mfrom\u001b[0m
\u001b[0mdistutils\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mversion\u001b[0m
\u001b[0;32mimport\u001b[0m
\u001b[0mLooseVersion\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n
\u001b[1;32m 112\u001b[0m \u001b[0;32mif\u001b[0m
\u001b[0mLooseVersion\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpyaudio\u001b[0m\u001b
[0;34m.\u001b[0m\u001b[0m__version__\u001b[0m\u001b[0;34m)\u001b[0m
\u001b[0;34m<\u001b[0m
\u001b[0mLooseVersion\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"0.2.11\"\u001b[0m
\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b
[0m\u001b[0m\n",
"\u001b[0;31mAttributeError\u001b[0m: Could not find PyAudio; check
installation"
]
}
],
"source": [
"import speech_recognition as sr\n",
"\n",
"r = sr.Recognizer()\n",
"with sr.Microphone() as source:\n",
" print(\"speak anything : \")\n",
" audio = r.listen(source)\n",
" try:\n",
" text = r.recognize_google(audio)\n",
" print(\"You said : {}\".format(text))\n",
" except:\n",
" print(\"Sorry could not recognize what you said? \")"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Defaulting to user installation because normal site-packages is not
writeable\n",
"Collecting PyAudio\n",
" Using cached PyAudio-0.2.11.tar.gz (37 kB)\n",
"Building wheels for collected packages: PyAudio\n",
" Building wheel for PyAudio (setup.py) ... \u001b[?25lerror\n",
"\u001b[31m ERROR: Command errored out with exit status 1:\n",
" command: /usr/bin/python -u -c 'import sys, setuptools, tokenize;
sys.argv[0] = '\"'\"'/tmp/pip-install-bbr79pys/PyAudio/setup.py'\"'\"';
__file__='\"'\"'/tmp/pip-install-
bbr79pys/PyAudio/setup.py'\"'\"';f=getattr(tokenize, '\"'\"'open'\"'\"', open)
(__file__);code=f.read().replace('\"'\"'\\r\\n'\"'\"',
'\"'\"'\\n'\"'\"');f.close();exec(compile(code, __file__, '\"'\"'exec'\"'\"'))'
bdist_wheel -d /tmp/pip-wheel-olgh7tio\n",
" cwd: /tmp/pip-install-bbr79pys/PyAudio/\n",
" Complete output (16 lines):\n",
" running bdist_wheel\n",
" running build\n",
" running build_py\n",
" creating build\n",
" creating build/lib.linux-x86_64-3.8\n",
" copying src/pyaudio.py -> build/lib.linux-x86_64-3.8\n",
" running build_ext\n",
" building '_portaudio' extension\n",
" creating build/temp.linux-x86_64-3.8\n",
" creating build/temp.linux-x86_64-3.8/src\n",
" x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG
-g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security
-g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-
time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.8 -c src/_portaudiomodule.c
-o build/temp.linux-x86_64-3.8/src/_portaudiomodule.o\n",
" src/_portaudiomodule.c:29:10: fatal error: portaudio.h: No such file or
directory\n",
" 29 | #include \"portaudio.h\"\n",
" | ^~~~~~~~~~~~~\n",
" compilation terminated.\n",
" error: command 'x86_64-linux-gnu-gcc' failed with exit status 1\n",
" ----------------------------------------\u001b[0m\n",
"\u001b[31m ERROR: Failed building wheel for PyAudio\u001b[0m\n",
"\u001b[?25h Running setup.py clean for PyAudio\n",
"Failed to build PyAudio\n",
"Installing collected packages: PyAudio\n",
" Running setup.py install for PyAudio ... \u001b[?25lerror\n",
"\u001b[31m ERROR: Command errored out with exit status 1:\n",
" command: /usr/bin/python -u -c 'import sys, setuptools, tokenize;
sys.argv[0] = '\"'\"'/tmp/pip-install-bbr79pys/PyAudio/setup.py'\"'\"';
__file__='\"'\"'/tmp/pip-install-
bbr79pys/PyAudio/setup.py'\"'\"';f=getattr(tokenize, '\"'\"'open'\"'\"', open)
(__file__);code=f.read().replace('\"'\"'\\r\\n'\"'\"',
'\"'\"'\\n'\"'\"');f.close();exec(compile(code, __file__, '\"'\"'exec'\"'\"'))'
install --record /tmp/pip-record-xjysdjtd/install-record.txt --single-version-
externally-managed --user --prefix= --compile --install-headers
/home/derry/.local/include/python3.8/PyAudio\n",
" cwd: /tmp/pip-install-bbr79pys/PyAudio/\n",
" Complete output (16 lines):\n",
" running install\n",
" running build\n",
" running build_py\n",
" creating build\n",
" creating build/lib.linux-x86_64-3.8\n",
" copying src/pyaudio.py -> build/lib.linux-x86_64-3.8\n",
" running build_ext\n",
" building '_portaudio' extension\n",
" creating build/temp.linux-x86_64-3.8\n",
" creating build/temp.linux-x86_64-3.8/src\n",
" x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG
-g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security
-g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-
time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.8 -c src/_portaudiomodule.c
-o build/temp.linux-x86_64-3.8/src/_portaudiomodule.o\n",
" src/_portaudiomodule.c:29:10: fatal error: portaudio.h: No such file or
directory\n",
" 29 | #include \"portaudio.h\"\n",
" | ^~~~~~~~~~~~~\n",
" compilation terminated.\n",
" error: command 'x86_64-linux-gnu-gcc' failed with exit status 1\n",
" ----------------------------------------\u001b[0m\n",
"\u001b[31mERROR: Command errored out with exit status 1: /usr/bin/python -u
-c 'import sys, setuptools, tokenize; sys.argv[0] = '\"'\"'/tmp/pip-install-
bbr79pys/PyAudio/setup.py'\"'\"'; __file__='\"'\"'/tmp/pip-install-
bbr79pys/PyAudio/setup.py'\"'\"';f=getattr(tokenize, '\"'\"'open'\"'\"', open)
(__file__);code=f.read().replace('\"'\"'\\r\\n'\"'\"',
'\"'\"'\\n'\"'\"');f.close();exec(compile(code, __file__, '\"'\"'exec'\"'\"'))'
install --record /tmp/pip-record-xjysdjtd/install-record.txt --single-version-
externally-managed --user --prefix= --compile --install-headers
/home/derry/.local/include/python3.8/PyAudio Check the logs for full command
output.\u001b[0m\n",
"\u001b[?25hNote: you may need to restart the kernel to use updated
packages.\n"
]
}
],
"source": [
"pip install PyAudio"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.8.2 64-bit",
"language": "python",
"name": "python38264bitf61b78f71ccd40358f760543c2a95d9e"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

S-ar putea să vă placă și