Superfast squeaky voice recording with Jabra 410 on picroft

TL;DR Sound recorded on my picroft with jabra 410 usb microphone is hilariously compressed into a tiny squeak. Please help.

15 sec and SFW video here

https://drive.google.com/open?id=1Kacbt5ZZNdmvo3pLBbubGp7fp351TUM0

Long Story. When first booting my new picroft, this type of thing didn’t produce any sound

speak "hello"
mimic -t "Hello. my name is Mycroft." -o hello.wav
aplay hello.wav

However after some googling I discovered this did work!

aplay -Dplughw:1,0 hello.wav

So I promptly edited my mycroft.conf

pi@picroft:~ $ cat /etc/mycroft/mycroft.conf
{
   "play_wav_cmdline": "aplay -Dplughw:1,0 %1",
   "play_mp3_cmdline": "mpg123 -a plughw:1,0 %1",
   "enclosure": {
      "platform": "picroft",
      "update": true,
      "test": false
   },
   "tts": {
      "module": "mimic",
      "mimic": {
         "voice": "ap",
         "path": "/usr/local/bin/mimic"
      }
   },
   "ipc_path": "/ramdisk/mycroft/ipc/"
}

But this didn’t help anything, and I’m thinking it was actualy the wrong thing to do.

Moving on…

I found some more resources with googlefoo, and this worked!

pi@picroft:~ $ pactl info
Server String: /run/user/1000/pulse/native
Library Protocol Version: 29
Server Protocol Version: 29
Is Local: yes
Client Index: 22
Tile Size: 65496
User Name: pi
Host Name: picroft
Server Name: pulseaudio
Server Version: 5.0
Default Sample Specification: s16le 2ch 44100Hz
Default Channel Map: front-left,front-right
Default Sink: alsa_output.0.analog-stereo
Default Source: alsa_input.usb-0b0e_Jabra_SPEAK_410_USB_501AA5D84A75x010900-00-USB.analog-mono
Cookie: a36b:f296

pi@picroft:~ $ pactl set-default-sink 0

pi@picroft:~ $ pactl info
Server String: /run/user/1000/pulse/native
Library Protocol Version: 29
Server Protocol Version: 29
Is Local: yes
Client Index: 25
Tile Size: 65496
User Name: pi
Host Name: picroft
Server Name: pulseaudio
Server Version: 5.0
Default Sample Specification: s16le 2ch 44100Hz
Default Channel Map: front-left,front-right
Default Sink: alsa_output.usb-0b0e_Jabra_SPEAK_410_USB_501AA5D84A75x010900-00-USB.analog-stereo
Default Source: alsa_input.usb-0b0e_Jabra_SPEAK_410_USB_501AA5D84A75x010900-00-USB.analog-mono
Cookie: a36b:f296

pi@picroft:~ $ aplay hello.wav
Playing WAVE 'hello.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Mono
pi@picroft:~ $ mimic -t "Hello. my name is Mycroft." -o hello.wav

Horay! I have sound. I suspect I should go back and put mycroft.conf back to default.

Now I’m left with the very odd problem of the microphone recording as in the video

https://drive.google.com/open?id=1Kacbt5ZZNdmvo3pLBbubGp7fp351TUM0

I think it’s the recording at fault, not the playback, because I can play other audio fine, and I have no wakeword detection (hey mycroft).

Any pointers you can give would be great. I’ve attached the output from aplay -L and arecord -L for details.

pi@picroft:~ $ aplay -L
default
    Playback/recording through the PulseAudio sound server
null
    Discard all samples (playback) or generate zero samples (capture)
pulse
    PulseAudio Sound Server
sysdefault:CARD=ALSA
    bcm2835 ALSA, bcm2835 ALSA
    Default Audio Device
dmix:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Direct sample mixing device
dmix:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Direct sample mixing device
dsnoop:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Direct sample snooping device
dsnoop:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Direct sample snooping device
hw:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Direct hardware device without any conversions
hw:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Direct hardware device without any conversions
plughw:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Hardware device with all software conversions
plughw:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Hardware device with all software conversions
sysdefault:CARD=USB
    Jabra SPEAK 410 USB, USB Audio
    Default Audio Device
front:CARD=USB,DEV=0
    Jabra SPEAK 410 USB, USB Audio
    Front speakers
surround21:CARD=USB,DEV=0
    Jabra SPEAK 410 USB, USB Audio
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=USB,DEV=0
    Jabra SPEAK 410 USB, USB Audio
    4.0 Surround output to Front and Rear speakers
surround41:CARD=USB,DEV=0
    Jabra SPEAK 410 USB, USB Audio
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=USB,DEV=0
    Jabra SPEAK 410 USB, USB Audio
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=USB,DEV=0
    Jabra SPEAK 410 USB, USB Audio
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=USB,DEV=0
    Jabra SPEAK 410 USB, USB Audio
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=USB,DEV=0
    Jabra SPEAK 410 USB, USB Audio
    IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=USB,DEV=0
    Jabra SPEAK 410 USB, USB Audio
    Direct sample mixing device
dsnoop:CARD=USB,DEV=0
    Jabra SPEAK 410 USB, USB Audio
    Direct sample snooping device
hw:CARD=USB,DEV=0
    Jabra SPEAK 410 USB, USB Audio
    Direct hardware device without any conversions
plughw:CARD=USB,DEV=0
    Jabra SPEAK 410 USB, USB Audio
    Hardware device with all software conversions

pi@picroft:~ $ arecord -L
default
    Playback/recording through the PulseAudio sound server
null
    Discard all samples (playback) or generate zero samples (capture)
pulse
    PulseAudio Sound Server
sysdefault:CARD=USB
    Jabra SPEAK 410 USB, USB Audio
    Default Audio Device
front:CARD=USB,DEV=0
    Jabra SPEAK 410 USB, USB Audio
    Front speakers
surround21:CARD=USB,DEV=0
    Jabra SPEAK 410 USB, USB Audio
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=USB,DEV=0
    Jabra SPEAK 410 USB, USB Audio
    4.0 Surround output to Front and Rear speakers
surround41:CARD=USB,DEV=0
    Jabra SPEAK 410 USB, USB Audio
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=USB,DEV=0
    Jabra SPEAK 410 USB, USB Audio
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=USB,DEV=0
    Jabra SPEAK 410 USB, USB Audio
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=USB,DEV=0
    Jabra SPEAK 410 USB, USB Audio
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=USB,DEV=0
    Jabra SPEAK 410 USB, USB Audio
    IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=USB,DEV=0
    Jabra SPEAK 410 USB, USB Audio
    Direct sample mixing device
dsnoop:CARD=USB,DEV=0
    Jabra SPEAK 410 USB, USB Audio
    Direct sample snooping device
hw:CARD=USB,DEV=0
    Jabra SPEAK 410 USB, USB Audio
    Direct hardware device without any conversions
plughw:CARD=USB,DEV=0
    Jabra SPEAK 410 USB, USB Audio
    Hardware device with all software conversions

pi@picroft:~ $ arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: USB [Jabra SPEAK 410 USB], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

pi@picroft:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
  Subdevices: 7/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: USB [Jabra SPEAK 410 USB], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

I have no idea on this one, haven’t heard this particular symptom before. Going to ping @forslund to see if he has any ideas.

Guessing you’ve seen our audio troubleshooting documentation at:
https://mycroft.ai/documentation/picroft/#audio-issues

tl;dr My new question is, what’s the correct way to specify the microphone device?

Long story.

I’ve had a bit more success, both test_microphone and mycroft-audio-test work now. Starting from a freshly imaged sd card, I run

pactl set-default-sink 0

to set the correct output device. then

test_microphone
mycroft-audio-test
aplay file.wav
mpg123 file.mp3

all work for both recorcing and playback. in addition

aplay -Dplughw:1,0 file.wav
mpg123 -a plughw:1,0 file.mp3 

Also work. I’m asuming this is redundant, as that interface is already set as default.

I updated my /etc/mycroft/mycroft.conf with

"play_wav_cmdline": "aplay -Dplughw:1,0 %1",
"play_mp3_cmdline": "mpg123 -a plughw:1,0 %1",

and now I get spoken responces to questions at the multicolour console! Woohoo, it’s looking better

However, I still have no indication of volume on the microphone graph, bottom right of the multicolour console display. I assume I need to set the microphone device?

I’ve tried setting

"listener": {
    "device_index": 1
}

in mycroft.conf, as per some of the documentation, but this causes the play_wav_cmdline to not be loaded and I lose my spoken feedback… (yes I checked it was valid json with a linter)

My new question is, what’s the correct way to specify the microphone device?

Great debugging. I’m going to ping my colleague @forslund who has more experience here with audio.

I’m sorry to report that I have very little experience with troublesome audio inputs. Mine have behaved well with the hardware I’m using.

The input_device is an integer between 0 and the number of devices reported by port audio (pyaudio.PyAudio().get_device_count())
Reading up on how Speechrecognition and PyAudio uses this index, it seems you might be able to find the correct index by running this script:

import pyaudio
p = pyaudio.PyAudio()
info = p.get_host_api_info_by_index(0)
numdevices = info.get('deviceCount')
for i in range(0, numdevices):
        if (p.get_device_info_by_host_api_device_index(0, i).get('maxInputChannels')) > 0:
            print "Input Device id ", i, " - ", p.get_device_info_by_host_api_device_index(0, i).get('name')

This should print all input device id’s and if possible the names. (if I’ve understood everything correctly)

/Åke

1 Like

Please see my recent comment here…