respeaker / avs

python implementation of alexa voice service app, 支持DuerOS
Other
197 stars 63 forks source link

Raspberry pi 3 + respeaker 2mic + Alexa hdmi output music #17

Closed correderadiego closed 6 years ago

correderadiego commented 6 years ago

Description

I am triying to connect respeaker 2 mic hat with raspbian stretch in a raspberry pi 3 and Alexa. I would like to create a stand alone device. I am in trouble with the output sounds. I am hearing the output over the hdmi interface instead of the respeaker audio jack.

What I Did

I have installed properly the respeaker 2 mic hat , following this tutorial http://wiki.seeed.cc/Respeaker_2_Mics_Pi_HAT/. I have managed to reproduce sounds and record my own voice properly. I have also reproduce sounds using youtube. I can hear it using a headphones connected to respeaker. The problems appears with Alexa itself.

I run alexa-audio-check and the sounds outs throw the hdmi interface instead of the built-in jack output. I would like that the sound outs throw the jack board. ¿Could you help me with it? I have followed some tutorials but I can't make it work.

Thanks for your support.

Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.
xiongyihui commented 6 years ago

See https://www.raspberrypi.org/documentation/configuration/audio-config.md

correderadiego commented 6 years ago

Thanks for your reply, I have review the link and I have selected the 3.5 mm jack option using raspi-config. The problem persists and I only can hear the sound through the hdmi interface. I have realized that using alexa-audio-check I am seeing the following logs (I have attached the logs at the end of the post)

It looks like that the default configuration can't be found. I have installed the respeaker board using git clone https://github.com/respeaker/seeed-voicecard.git cd seeed-voicecard sudo ./install.sh 2mic reboot

And I can hear myself using arecord -f cd -Dhw:1 | aplay -Dhw:1

As far as I could see, the board is working properly but there is a mistake in my alexa project configuration. Could you help me with it?

Thanks for your time

ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21 ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21 ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround40 ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround41 ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround50 ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround51 ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71 ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958 ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958 ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958 ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device' ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device' ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa ALSA lib pcm_dmix.c:990:(snd_pcm_dmix_open) The dmix plugin supports only playback stream ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave ALSA lib pcm_dsnoop.c:556:(snd_pcm_dsnoop_open) The dsnoop plugin supports only capture stream ALSA lib pcm_dmix.c:990:(snd_pcm_dmix_open) The dmix plugin supports only playback stream ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave ALSA lib pcm_dsnoop.c:556:(snd_pcm_dsnoop_open) The dsnoop plugin supports only capture stream Cannot connect to server socket err = No such file or directory Cannot connect to server request channel jack server is not running or cannot be started JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock

xiongyihui commented 6 years ago

Which jack port do you want to use? The one on Pi, or the one on 2 mic hat? If you want to use the on-board jack port on Pi, Use the guide https://www.raspberrypi.org/documentation/configuration/audio-config.md. If it doesn't work, maybe try to download the latest raspbian image.

Otherwise, if your 2 mic sound card is hw:1, change hw:0 to hw:1 in the /etc/asound.conf

correderadiego commented 6 years ago

Hello, I am using raspbian stretch (this is the latests version in the web). I would like to use the one on 2 mic hat jack. I have managed to use hdmi port and the raspberry 3 jack but not the 2 mic hat jack. I would like to port it to a raspberry pi zero in a future.

I have changed the configuration in /etc/asound.conf and the sounds still outs throw the hdmi interface. If you need further information please ask me. I have found respearker plus pi zero awesome and I would like to make it work together.

This is my /etc/asound.conf file :

The IPC key of dmix or dsnoop plugin must be unique

If 555555 or 666666 is used by other processes, use another one

pcm.!default { type asym playback.pcm "playback" capture.pcm "capture" }

pcm.playback { type plug slave.pcm "dmixed" }

pcm.capture { type plug slave.pcm "array" }

pcm.dmixed { type dmix slave.pcm "hw:1,0" ipc_key 555555 }

pcm.array { type dsnoop slave { pcm "hw:1,0" channels 2 } ipc_key 666666 }

Thanks for your time.

xiongyihui commented 6 years ago

Maybe have a try to replace 555555 to 777777 or a random number, then run aplay -v any_audio.wav and check the output log.

correderadiego commented 6 years ago

Hello,

I have download a sample from internet and play using aplay -v bach.wav . This is the output log. I can hear the sound perfectly using aplay command, but I cannot hear anything using alexa-tap or alexa-audio-check. I have realized that using alexa sometimes I can hear some background sound (white noise in engineering language). It could be possible that there would be some python missing libraries?

Playing WAVE 'bach.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo Plug PCM: Rate conversion PCM (48000, sformat=S16_LE) Converter: linear-interpolation Protocol version: 10002 Its setup is: stream : PLAYBACK access : RW_INTERLEAVED format : S16_LE subformat : STD channels : 2 rate : 44100 exact rate : 44100 (44100/1) msbits : 16 buffer_size : 16537 period_size : 5512 period_time : 125000 tstamp_mode : NONE tstamp_type : MONOTONIC period_step : 1 avail_min : 5512 period_event : 0 start_threshold : 16537 stop_threshold : 16537 silence_threshold: 0 silence_size : 0 boundary : 1083768832 Slave: Direct Stream Mixing PCM Its setup is: stream : PLAYBACK access : MMAP_INTERLEAVED format : S16_LE subformat : STD channels : 2 rate : 48000 exact rate : 48000 (48000/1) msbits : 16 buffer_size : 18000 period_size : 6000 period_time : 125000 tstamp_mode : NONE tstamp_type : MONOTONIC period_step : 1 avail_min : 6000 period_event : 0 start_threshold : 18000 stop_threshold : 18000 silence_threshold: 0 silence_size : 0 boundary : 1179648000 Hardware PCM card 1 'seeed-2mic-voicecard' device 0 subdevice 0 Its setup is: stream : PLAYBACK access : MMAP_INTERLEAVED format : S16_LE subformat : STD channels : 2 rate : 48000 exact rate : 48000 (48000/1) msbits : 16 buffer_size : 18000 period_size : 6000 period_time : 125000 tstamp_mode : ENABLE tstamp_type : MONOTONIC period_step : 1 avail_min : 6000 period_event : 0 start_threshold : 1 stop_threshold : 1179648000 silence_threshold: 0 silence_size : 1179648000 boundary : 1179648000 appl_ptr : 0 hw_ptr : 0

xiongyihui commented 6 years ago

Have you installed the dependencies?

sudo apt-get install gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly \
gir1.2-gstreamer-1.0 python-gi python-gst-1.0 python-pyaudio
correderadiego commented 6 years ago

Hello I already installed them

pi@raspberrypi:~ $ sudo apt-get install gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly \

gir1.2-gstreamer-1.0 python-gi python-gst-1.0 python-pyaudio Reading package lists... Done Building dependency tree
Reading state information... Done gir1.2-gstreamer-1.0 is already the newest version (1.10.4-1). gstreamer1.0-plugins-bad is already the newest version (1.10.4-1). gstreamer1.0-plugins-good is already the newest version (1.10.4-1). gstreamer1.0-plugins-ugly is already the newest version (1.10.4-1). python-gi is already the newest version (3.22.0-2). python-gst-1.0 is already the newest version (1.10.4-1). python-pyaudio is already the newest version (0.2.11-1). The following packages were automatically installed and are no longer required: erlang-base erlang-crypto erlang-syntax-tools fonts-lato libboost-thread1.62.0 libdouble-conversion1 libpython-all-dev libqt5concurrent5 libqt5core5a libqt5dbus5 libqt5gui5 libqt5network5 libqt5opengl5 libqt5printsupport5 libqt5scintilla2-12v5 libqt5scintilla2-l10n libqt5svg5 libqt5widgets5 libqt5x11extras5 libqt5xml5 libqwt-qt5-6 libruby2.3 libscsynth1 libsctp1 libxcb-icccm4 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xkb1 libxkbcommon-x11-0 libxkbcommon0 libyaml-0-2 python-all python-all-dev python-keyring python-keyrings.alt python-secretstorage python-wheel qt5-gtk-platformtheme qttranslations5-l10n rake ruby ruby-did-you-mean ruby-minitest ruby-net-telnet ruby-power-assert ruby-test-unit ruby2.3 rubygems-integration Use 'sudo apt autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 49 not upgraded. pi@raspberrypi:~ $ sudo pip install avs respeaker pocketsphinx Requirement already satisfied: avs in /usr/local/lib/python2.7/dist-packages Requirement already satisfied: respeaker in /usr/local/lib/python2.7/dist-packages Requirement already satisfied: pocketsphinx in /usr/local/lib/python2.7/dist-packages Requirement already satisfied: requests in /usr/local/lib/python2.7/dist-packages (from avs) Requirement already satisfied: hyper in /usr/local/lib/python2.7/dist-packages (from avs) Requirement already satisfied: click in /usr/lib/python2.7/dist-packages (from avs) Requirement already satisfied: tornado in /usr/local/lib/python2.7/dist-packages (from avs) Requirement already satisfied: python-dateutil in /usr/local/lib/python2.7/dist-packages (from avs) Requirement already satisfied: urllib3<1.23,>=1.21.1 in /usr/local/lib/python2.7/dist-packages (from requests->avs) Requirement already satisfied: idna<2.7,>=2.5 in /usr/local/lib/python2.7/dist-packages (from requests->avs) Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python2.7/dist-packages (from requests->avs) Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python2.7/dist-packages (from requests->avs) Requirement already satisfied: h2<3.0,>=2.4 in /usr/local/lib/python2.7/dist-packages (from hyper->avs) Requirement already satisfied: hyperframe<4.0,>=3.2 in /usr/local/lib/python2.7/dist-packages (from hyper->avs) Requirement already satisfied: singledispatch in /usr/local/lib/python2.7/dist-packages (from tornado->avs) Requirement already satisfied: backports-abc>=0.4 in /usr/local/lib/python2.7/dist-packages (from tornado->avs) Requirement already satisfied: six>=1.5 in /usr/local/lib/python2.7/dist-packages (from python-dateutil->avs) Requirement already satisfied: hpack<4,>=2.2 in /usr/local/lib/python2.7/dist-packages (from h2<3.0,>=2.4->hyper->avs) Requirement already satisfied: enum34<2,>=1.0.4; python_version == "2.7" or python_version == "3.3" in /usr/lib/python2.7/dist-packages (from h2<3.0,>=2.4->hyper->avs)

xiongyihui commented 6 years ago

That's really weird! Based on your aplay log, 'seeed-2mic-voicecard' is the default device. How about to run alexa-audio-check and check if any sound is playing

correderadiego commented 6 years ago

Hello, It would be possible for you to give a step by step installation guide on raspberry pi zero? I would like to create an alexa speaker with your hardware and put in a destiny 2 ghost printer case. I have not managed to make it work on my own. If it would be possible I would like to have a minimal installation procedure based on raspbian stretch.

Thanks for your time and sorry for the inconveniences

2018-01-26 1:49 GMT+01:00 Yihui Xiong notifications@github.com:

That's really weird! Based on your aplay log, 'seeed-2mic-voicecard' is the default device. How about to run alexa-audio-check and check if any sound is playing

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/respeaker/avs/issues/17#issuecomment-360650450, or mute the thread https://github.com/notifications/unsubscribe-auth/ASHE2kp4O0L_rnMg-_JVEWp5j8x_7yN8ks5tOSEHgaJpZM4Rlxrh .

-- Diego Corredera Martín

http://www.linkedin.com/in/correderadiego

En función de la Ley Orgánica 15/1999, este mensaje de correo electrónico y sus documentos adjuntos estan dirigidos exclusivamente a los destinatarios especificados y su información es de uso estrictamente privado salvo que se especifique lo contrario. La información contenida puede ser confidencial y/o estar legalmente protegida. Si usted recibe este mensaje por error, por favor comuníqueselo inmediatamente al remitente y elimínelo ya que carece de autorización de todo tipo. Se prohíbe expresamente la revelación, distribución, impresión o copia de toda o alguna parte de la información contenida en este mensaje

xiongyihui commented 6 years ago

Copied from https://github.com/respeaker/avs/issues/19#issuecomment-375531841

It is likely that the default of pi's gstreamer audio sink is GstOMXHdmiAudioSink. It ignores ALSA configurations (/etc/asound.conf or ~/.asoundrc)

image

To verify if it's the case:

sudo apt-get install gstreamer1.0-tools
gst-launch-1.0 playbin uri=https://archive.org/download/SuperMarioBros.ThemeMusic/SuperMarioBros.mp3
# Audio output port should be HDMI

 gst-launch-1.0 playbin uri=https://archive.org/download/SuperMarioBros.ThemeMusic/SuperMarioBros.mp3  audio-sink=alsasink
# Audio output port should be the default alsa output device

If you don't want HDMI audio output, try:

sudo apt remove gstreamer1.0-omx gstreamer1.0-omx-rpi