HackerShackOfficial / AI-Smart-Mirror

Smart Mirror with a smart AI 🤖
MIT License
537 stars 214 forks source link

Doesn't seem to work on Raspberry pi #22

Open kireol opened 7 years ago

kireol commented 7 years ago

In case you guys wanted some data, setup for AI seems to fail for raspberry pi's. I tried a RP Zero and a RP 2b+ and get the same error.

`:~/AI-Smart-Mirror$ sudo ./setup.sh Requirement already satisfied (use --upgrade to upgrade): virtualenv in /usr/local/lib/python2.7/dist-packages Cleaning up... New python executable in /home/pi/AI-Smart-Mirror/hhsmartmirror/bin/python Installing setuptools, pip, wheel...done. Collecting speechrecognition (from -r requirements.txt (line 1)) Downloading SpeechRecognition-3.5.0.tar.gz (31.5MB) 99% |████████████████████████████████| 31.5MB 1.3MB/s eta 0:00:01Exception: Traceback (most recent call last): File "/home/pi/AI-Smart-Mirror/hhsmartmirror/local/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/home/pi/AI-Smart-Mirror/hhsmartmirror/local/lib/python2.7/site-packages/pip/commands/install.py", line 335, in run wb.build(autobuilding=True) File "/home/pi/AI-Smart-Mirror/hhsmartmirror/local/lib/python2.7/site-packages/pip/wheel.py", line 749, in build self.requirement_set.prepare_files(self.finder) File "/home/pi/AI-Smart-Mirror/hhsmartmirror/local/lib/python2.7/site-packages/pip/req/req_set.py", line 380, in prepare_files ignore_dependencies=self.ignore_dependencies)) File "/home/pi/AI-Smart-Mirror/hhsmartmirror/local/lib/python2.7/site-packages/pip/req/req_set.py", line 620, in _prepare_file session=self.session, hashes=hashes) File "/home/pi/AI-Smart-Mirror/hhsmartmirror/local/lib/python2.7/site-packages/pip/download.py", line 821, in unpack_url hashes=hashes File "/home/pi/AI-Smart-Mirror/hhsmartmirror/local/lib/python2.7/site-packages/pip/download.py", line 659, in unpack_http_url hashes) File "/home/pi/AI-Smart-Mirror/hhsmartmirror/local/lib/python2.7/site-packages/pip/download.py", line 882, in _download_http_url _download_url(resp, link, content_file, hashes) File "/home/pi/AI-Smart-Mirror/hhsmartmirror/local/lib/python2.7/site-packages/pip/download.py", line 603, in _download_url hashes.check_against_chunks(downloaded_chunks) File "/home/pi/AI-Smart-Mirror/hhsmartmirror/local/lib/python2.7/site-packages/pip/utils/hashes.py", line 46, in check_against_chunks for chunk in chunks: File "/home/pi/AI-Smart-Mirror/hhsmartmirror/local/lib/python2.7/site-packages/pip/download.py", line 571, in written_chunks for chunk in chunks: File "/home/pi/AI-Smart-Mirror/hhsmartmirror/local/lib/python2.7/site-packages/pip/utils/ui.py", line 139, in iter for x in it: File "/home/pi/AI-Smart-Mirror/hhsmartmirror/local/lib/python2.7/site-packages/pip/download.py", line 560, in resp_read decode_content=False): File "/home/pi/AI-Smart-Mirror/hhsmartmirror/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 357, in stream data = self.read(amt=amt, decode_content=decode_content) File "/home/pi/AI-Smart-Mirror/hhsmartmirror/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 314, in read data = self._fp.read(amt) File "/home/pi/AI-Smart-Mirror/hhsmartmirror/local/lib/python2.7/site-packages/pip/_vendor/cachecontrol/filewrapper.py", line 63, in read self._close() File "/home/pi/AI-Smart-Mirror/hhsmartmirror/local/lib/python2.7/site-packages/pip/_vendor/cachecontrol/filewrapper.py", line 50, in _close self.callback(self.buf.getvalue()) File "/home/pi/AI-Smart-Mirror/hhsmartmirror/local/lib/python2.7/site-packages/pip/_vendor/cachecontrol/controller.py", line 275, in cache_response self.serializer.dumps(request, response, body=body), File "/home/pi/AI-Smart-Mirror/hhsmartmirror/local/lib/python2.7/site-packages/pip/_vendor/cachecontrol/serialize.py", line 87, in dumps ).encode("utf8"), MemoryError /home/pi/AI-Smart-Mirror/hhsmartmirror/local/lib/python2.7/site-packages/pip/commands/install.py:194: UserWarning: Disabling all use of wheels due to the use of --build-options / --global-options / --install-options. cmdoptions.check_install_build_global(options) Collecting pyaudio Using cached PyAudio-0.2.9.tar.gz Skipping bdist_wheel for pyaudio, due to binaries being disabled for it. Installing collected packages: pyaudio Running setup.py install for pyaudio ... error Complete output from command /home/pi/AI-Smart-Mirror/hhsmartmirror/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-nZAyv3/pyaudio/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" build_ext -I/usr/local/include -L/usr/local/lib install --record /tmp/pip-hzIsEq-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/pi/AI-Smart-Mirror/hhsmartmirror/include/site/python2.7/pyaudio: running build_ext building '_portaudio' extension creating build creating build/temp.linux-armv6l-2.7 creating build/temp.linux-armv6l-2.7/src arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/local/include -I/usr/include/python2.7 -c src/_portaudiomodule.c -o build/temp.linux-armv6l-2.7/src/_portaudiomodule.o src/_portaudiomodule.c:28:20: fatal error: Python.h: No such file or directory

include "Python.h"

                    ^
compilation terminated.
error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1

----------------------------------------

Command "/home/pi/AI-Smart-Mirror/hhsmartmirror/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-nZAyv3/pyaudio/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" build_ext -I/usr/local/include -L/usr/local/lib install --record /tmp/pip-hzIsEq-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/pi/AI-Smart-Mirror/hhsmartmirror/include/site/python2.7/pyaudio" failed with error code 1 in /tmp/pip-build-nZAyv3/pyaudio/`

to get around this, i manually installed speechrecognition:

pip install SpeechRecognition

and then commented out that line in the requirements.txt file.

I also had other missing deps. I had to run:

apt-get install python-dev apt-get install python-devel apt-get install libportaudio-dev apt-get install portaudio19-dev

then i could run AI-Smart-Mirror's setup.sh

atainter commented 7 years ago

Did you get it to run eventually, or are you still getting an error?

kireol commented 7 years ago

I got it to complete given my instructions above.

atainter commented 7 years ago

Are you interested in creating a Raspberry Pi guide on the Readme.md? I would merge it into the main repository if you did. Otherwise, I can document this when I get the time.

smand90 commented 7 years ago

Hi atainter , were you able to install AI on raspi3 ? can you share any readme file or steps to follow ?

20wks commented 7 years ago

@kireol can you please provide any kind of steps for your running of setup.sh. I'm stuck with the same problem here and cannot figure a way out. I'm quite new at this, but really interested on the subject. Tried your method, installed manually all dependencies but I cannot get it to run on my RPi3B. (hhsmartmirror) pi@nelle:~/Ai-Smart-Mirror $ python bot.py Warning: OpenCV not installed. To use facial recognition, make sure you've properly configured OpenCV. Found face Traceback (most recent call last): File "bot.py", line 254, in bot.start() File "bot.py", line 43, in start recognizer, audio = self.speech.listen_for_audio() File "/home/pi/Ai-Smart-Mirror/speech.py", line 32, in listen_for_audio m = sr.Microphone() File "/home/pi/Ai-Smart-Mirror/hhsmartmirror/local/lib/python2.7/site-packages/speech_recognition/init.py", line 79, in init self.pyaudio_module = self.get_pyaudio() File "/home/pi/Ai-Smart-Mirror/hhsmartmirror/local/lib/python2.7/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

Much appreciate your help

advokaten commented 7 years ago
(hhsmartmirror) pi@magicpi:~/MagicMirror/modules/AI-Smart-Mirror $ python bot.py/home/pi/MagicMirror/modules/AI-Smart-Mirror/hhsmartmirror/local/lib/python2.7/site-packages/pydub/utils.py:165: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
  warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
/home/pi/MagicMirror/modules/AI-Smart-Mirror/hhsmartmirror/local/lib/python2.7/site-packages/pydub/utils.py:178: RuntimeWarning: Couldn't find ffplay or avplay - defaulting to ffplay, but may not work
  warn("Couldn't find ffplay or avplay - defaulting to ffplay, but may not work", RuntimeWarning)
Warning: OpenCV not installed. To use facial recognition, make sure you've properly configured OpenCV.
Used wrong endpoint for microphone debugging
Found face
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.front.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM front
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround21
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround21
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround40.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround40
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround41
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround50
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround51
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround71.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround71
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM iec958
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM spdif
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM spdif
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

connect(2) call to /tmp/jack-1000/default/jack_0 failed (err=No such file or directory)
attempt to connect to server failed
Traceback (most recent call last):
  File "bot.py", line 254, in <module>
    bot.start()
  File "bot.py", line 43, in start
    recognizer, audio = self.speech.listen_for_audio()
  File "/home/pi/MagicMirror/modules/AI-Smart-Mirror/speech.py", line 32, in listen_for_audio
    m = sr.Microphone()
  File "/home/pi/MagicMirror/modules/AI-Smart-Mirror/hhsmartmirror/local/lib/python2.7/site-packages/speech_recognition/__init__.py", line 86, in __init__
    device_info = audio.get_device_info_by_index(device_index) if device_index is not None else audio.get_default_input_device_info()
  File "/home/pi/MagicMirror/modules/AI-Smart-Mirror/hhsmartmirror/local/lib/python2.7/site-packages/pyaudio.py", line 949, in get_default_input_device_info
    device_index = pa.get_default_input_device()
IOError: No Default Input Device Available

@kireol I got it installed but I can't get the python bit to work. Maybe there's something I missed. I tried to follow your steps but failed. Any ideas? Thanks mate!

pawan-saxena commented 6 years ago

@advokaten Please see the error it already says that it can't find a valid input device. two options : 1.Use USB microphone 2.Buy a sound card or use hat for raspberry cause raspberry doesn't have any audio-input for that matter.