New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed / High pitch sound issue with JABRA Speaker with Raspberry Pi #65

Closed
LengZai opened this Issue Jul 24, 2016 · 34 comments

Comments

Projects
None yet
10 participants
@LengZai

LengZai commented Jul 24, 2016

Description

Hi,

At first, thanks for your project, I really like it and I have started to test your project.
I use a Raspberry Pi 3 and a Jabra Speaker MS510
I got an issue to play 16000Hz sound.
It was very annoying because all my voices and Jarvis voice were very fast with a high pitched

I finally found a fix to make it worked and i hope it will help someone else. Maybe you can add it to your code but i suppose you need to check the impact.

At first i told to my raspberry that i want my USB audio device as default
So i create (as i don't have it) the file alsa-base.conf

$cat /etc/modprobe.d/alsa-base.conf
# This sets the index value of the cards but doesn't reorder.
options snd_usb_audio index=0
options snd_bcm2835 index=1

# Does the reordering.
options snd slots=snd_usb_audio,snd_bcm2835

So by default my audio device will be the Jabra speaker, even after rebooting the device

With the command $aplay -L
I listed all my "audio devices" and i found that there is a line named sysdefault

$ aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
pulse
    PulseAudio Sound Server
sysdefault
default:CARD=USB
    Jabra SPEAK 510 USB, USB Audio
    Default Audio Device
front:CARD=USB,DEV=0
    Jabra SPEAK 510 USB, USB Audio
    Front speakers
surround21:CARD=USB,DEV=0
    Jabra SPEAK 510 USB, USB Audio
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=USB,DEV=0
    Jabra SPEAK 510 USB, USB Audio
    4.0 Surround output to Front and Rear speakers
surround41:CARD=USB,DEV=0
........

So to find my issue i used "aplay" with -D option until i got the correct sound
Example: $aplay -Dsysdefault:CARD=USB -c 2 -f cd audio_test_from_pico2wave.wav
(it also works like this: $aplay -Dsysdefault -c 2 -f cd audio_test_from_pico2wave.wav)

So to fix my issue, i changed the file (generated and cleaned by jarvis.sh) .asoundrc by replacing pcm.!default by pcm.!sysdefault
to get something like this

$cat ./.asoundrc
pcm.!sysdefault {
  type asym
   playback.pcm {
     type plug
     slave.pcm "hw:0,0"
   }
   capture.pcm {
     type plug
     slave.pcm "hw:0,0"
   }
}

As you can see, even I plugged an USB audio device, I put hw:0,0 and not hw:1,0 as i set my USB audio device as default (to load the audio usb driver first) on the file alsa-base.conf

@LengZai LengZai closed this Jul 24, 2016

@LengZai LengZai changed the title from Fix USB sound issue with JABRA Speaker - Configuration file: .asoundrc to [Solved] USB sound issue with JABRA Speaker - Configuration file: .asoundrc Jul 24, 2016

@LengZai LengZai changed the title from [Solved] USB sound issue with JABRA Speaker - Configuration file: .asoundrc to [Solved] USB sound issue with JABRA Speaker - Speed / High pitch issue - Configuration file: .asoundrc Jul 24, 2016

@alexylem

This comment has been minimized.

Owner

alexylem commented Jul 24, 2016

I will leave it open until I test the impact & probably integrate it in the code.
Thanks for raising this and for your testings.

@alexylem alexylem reopened this Jul 24, 2016

@alexylem alexylem added the bug label Jul 24, 2016

@alexylem alexylem changed the title from [Solved] USB sound issue with JABRA Speaker - Speed / High pitch issue - Configuration file: .asoundrc to Speed / High pitch sound issue with JABRA Speaker Jul 24, 2016

@alexylem alexylem added this to the Je travaille dessus milestone Jul 24, 2016

@alexylem alexylem self-assigned this Jul 24, 2016

@alexylem

This comment has been minimized.

Owner

alexylem commented Jul 24, 2016

Couldn't find anything obvious about the different between default & sysdefault in Alsa.
However I tested on my raspberry pi and replacing default by sysdefault as you suggested still works (even after a reboot).
I'll commit this and see reaction from the community 😄 (or else I'll put both)

@alexylem alexylem closed this in 46ccf98 Jul 27, 2016

@alexylem

This comment has been minimized.

Owner

alexylem commented Jul 27, 2016

I had to fallback this one. My mic was no longer working with this fix for some reason (although it was working during my tests).

@alexylem alexylem reopened this Jul 27, 2016

@LengZai LengZai changed the title from Speed / High pitch sound issue with JABRA Speaker to Speed / High pitch sound issue with JABRA Speaker with Raspberry Pi Aug 4, 2016

@wikijm

This comment has been minimized.

Collaborator

wikijm commented Sep 25, 2016

I have exactly the the same on a fresh new Raspberry Pi 3 installation, except that I have a JABRA SPEAK 410.

J'ai exactement le même problème sur un e installation toute fraîche sur un Raspberry Pi 3, excepté que j'utilise un JABRA SPEAK 410.

@alexylem

This comment has been minimized.

Owner

alexylem commented Sep 25, 2016

Hi @wikijm, is fix also working for you?

So to fix my issue, i changed the file (generated and cleaned by jarvis.sh) .asoundrc by replacing pcm.!default by pcm.!sysdefault

@wikijm

This comment has been minimized.

Collaborator

wikijm commented Sep 25, 2016

Badly, no. With pcm.!sysdefault, I stop hearing sound, on Jarvis and for every sounds.

Hélas non. Avec pcm.!sysdefault, je n'entends plus aucun son, que ce soit pour Jarvis et tout le reste.

@LengZai

This comment has been minimized.

LengZai commented Sep 26, 2016

Hi @wikijm

Can you show us the ouput of the command $aplay -L
Thanks

@wikijm

This comment has been minimized.

Collaborator

wikijm commented Oct 2, 2016

Sorry for the late response.
Here's the result:

pi@RaspAP3:~ $ aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
pulse
PulseAudio Sound Server
default
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
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

@wikijm

This comment has been minimized.

Collaborator

wikijm commented Oct 3, 2016

After Jarvis and Raspbian update, everything works fine.

@wikijm

This comment has been minimized.

Collaborator

wikijm commented Oct 4, 2016

After verification, the problem do not appear when I start Jarvis normally, but this problem still appear with the "Troubleshooting mode"

@taostaos

This comment has been minimized.

Contributor

taostaos commented Oct 9, 2016

Had the same issue on my debian jessie home server with a Jabra 410. It looks like the tts.wav tmp file created by Pico have a 16000hz sample rate. As I didn't found a solution to change alsa default sample rate, I just convert the tmp file with avconv to 44100hz. Quick and dirty, but it's seamless on my server.

@alexylem

This comment has been minimized.

Owner

alexylem commented Oct 9, 2016

Does it work is you pass the format to aplay?

aplay --rate=16000 --channels=1 --format=S16_LE tts.wav

You can also use sox to convert:

sox tts.wav -r 44100 tts.wav
@taostaos

This comment has been minimized.

Contributor

taostaos commented Oct 9, 2016

Does it work is you pass the format to aplay?
aplay --rate=16000 --channels=1 --format=S16_LE tts.wav

Nop, this doesn't work

You can also use sox to convert:
sox tts.wav -r 44100 tts.wav

Yep this works.

@rikigeek

This comment has been minimized.

rikigeek commented Nov 1, 2016

I had exactly the same issue. I use a Jabra SPEAKER 510

hw:CARD=USB,DEV=0
    Jabra SPEAK 510 USB, USB Audio
    Direct hardware device without any conversions
plughw:CARD=USB,DEV=0
    Jabra SPEAK 510 USB, USB Audio
    Hardware device with all software conversions

And I use the following ~/.asoundrc:

pcm.jabbra {
    type hw
    card 1
    device 0
    rate 48000
}
pcm.!default {
  type asym
   playback.pcm {
     type plug
     slave.pcm "jabbra"
   }
   capture.pcm {
     type plug
     slave.pcm "hw:1,0"
   }
}

The important point is to set the rate to 48KHz for the Jabbra playback. From my different testing results, only 16000 and 48000 values allow aplay to send something. And only 48000 allow aplay to send something correctly!
Hope it will also work for you.

@wikijm

This comment has been minimized.

Collaborator

wikijm commented Dec 15, 2016

To resolve this issue:

  • Follow @rikigeek solution (create "jabra" audio device, #65 (comment))
  • Replace all text from ./config/play_hw to "jabra" value

Works like a charm with JABRA 410 & 510 (only USB tested)

@wikijm

This comment has been minimized.

Collaborator

wikijm commented Dec 16, 2016

@LengZai Could you try solution below? (#65 (comment))

@yaazzz

This comment has been minimized.

yaazzz commented Dec 18, 2016

Bonjour,

Cela fonctionne avec la configuration suivante dans le .asoundrc :

pcm.jabbra {
type hw
card 1
device 0
rate 48000
}
pcm.!default {
type asym
playback.pcm {
type plug
slave.pcm "jabbra"
}
capture.pcm {
type plug
slave.pcm "hw:1,0"
}
}

@esilky

This comment has been minimized.

esilky commented Jan 27, 2017

Since the Jabra (410 in my case) works fine when I use it on my PC, it seems like a configuration issue that should be able to be detected. If I plug in my Logitech USB headset into the Raspberry Pi, it works fine. If I plug either of these into my PC they both work fine - so again, it seems like something the driver or configuration should be able to handle.

I need the Jabra to work with my Raspberry Pi, so I am interested to a solution to this problem.

@wikijm

This comment has been minimized.

Collaborator

wikijm commented Jan 27, 2017

Hi @esilky,
Did you try solution below?

Follow @rikigeek solution (create "jabra" audio device, #65 (comment))
Replace all text from ./config/play_hw to "jabra" value
@wikijm

This comment has been minimized.

Collaborator

wikijm commented Feb 10, 2017

A solution was provided by @rikigeek and @yaazzz.
Please follow it, and eventualy re-open the ticket if problem still remains.

@claudioita

This comment has been minimized.

claudioita commented May 18, 2017

I tried all and still have the problem

@claudioita

This comment has been minimized.

claudioita commented May 18, 2017

I did follow step 65

@alexylem

This comment has been minimized.

Owner

alexylem commented May 19, 2017

@claudioita please paste here the config header of Jarvis (beginning of troubleshooting mode) as well as your ~/.asoudrc file. Thanks.

@claudioita

This comment has been minimized.

claudioita commented May 19, 2017

Please note that it did work in the past. Then I did not use it for a while.
In the meantime I installed AlexaPi and AssistantPi .. and those might have changed something?
Also note that this commands work well
pi@raspberrypi:~ $ arecord --format=S16_LE --duration=5 --rate=16k --file-type=raw out.raw
Recording raw data 'out.raw' : Signed 16 bit Little Endian, Rate 16000 Hz, Mono
pi@raspberrypi:~ $ aplay --format=S16_LE --rate=16k out.raw
Playing raw data 'out.raw' : Signed 16 bit Little Endian, Rate 16000 Hz, Mono
pi@raspberrypi:~ $

pcm.jabbra {
type hw
card 1
device 0
rate 48000
}
pcm.!default {
type asym
playback.pcm {
type plug
slave.pcm "jabbra"
}
capture.pcm {
type plug
slave.pcm "hw:1,0"
}
}

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

@alexylem

This comment has been minimized.

Owner

alexylem commented May 19, 2017

@claudioita did you set your jarvis/config/play_hw to "jabbra" as suggested by @wikijm ?

@claudioita

This comment has been minimized.

claudioita commented May 19, 2017

in /home/pi/jarvis/config

its empty directory (just file .gitkeep empty)

@alexylem

This comment has been minimized.

Owner

alexylem commented May 20, 2017

@claudioita it's not normal, Jarvis is not configured.
Please run:

$> jarvis -i

Then once completed, set your play_hw to jabbra:

$> echo "jabbra" > /home/pi/jarvis/config/play_hw
@claudioita

This comment has been minimized.

claudioita commented May 20, 2017

it was configured but after doing your echo command, now it's working

@claudioita

This comment has been minimized.

claudioita commented May 20, 2017

Although the audio is not totally clear, but maybe that's how it should sound (difficult to write how it is)?
Other issue, I still have the same high pitch, using the Google Assistant SDK ... you know by any chance what and where shall I look?

Must be the same problem

@claudioita

This comment has been minimized.

claudioita commented May 20, 2017

this is the log

ON_CONVERSATION_TURN_STARTED
ON_END_OF_UTTERANCE
ON_RECOGNIZING_SPEECH_FINISHED:
{'text': 'what time is it'}
ON_RESPONDING_STARTED:
{'is_error_response': False}
WriteDataToAlsa: Under-run occurred; attempting to recover.
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
WriteDataToAlsa: Under-run occurred; attempting to recover.
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
WriteDataToAlsa: Under-run occurred; attempting to recover.
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
WriteDataToAlsa: Under-run occurred; attempting to recover.
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
WriteDataToAlsa: Under-run occurred; attempting to recover.
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
WriteDataToAlsa: Under-run occurred; attempting to recover.
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
WriteDataToAlsa: Under-run occurred; attempting to recover.
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
WriteDataToAlsa: Under-run occurred; attempting to recover.
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
WriteDataToAlsa: Under-run occurred; attempting to recover.
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
WriteDataToAlsa: Under-run occurred; attempting to recover.
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
WriteDataToAlsa: Under-run occurred; attempting to recover.
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
WriteDataToAlsa: Under-run occurred; attempting to recover.
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
WriteDataToAlsa: Under-run occurred; attempting to recover.
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
WriteDataToAlsa: Under-run occurred; attempting to recover.
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
WriteDataToAlsa: Under-run occurred; attempting to recover.
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
WriteDataToAlsa: Under-run occurred; attempting to recover.
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
WriteDataToAlsa: Under-run occurred; attempting to recover.
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
WriteDataToAlsa: Under-run occurred; attempting to recover.
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
WriteDataToAlsa: Under-run occurred; attempting to recover.
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
WriteDataToAlsa: Under-run occurred; attempting to recover.
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
WriteDataToAlsa: Under-run occurred; attempting to recover.
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
ON_RESPONDING_FINISHED
ON_CONVERSATION_TURN_FINISHED:
{'with_follow_on_turn': False}

@alexylem

This comment has been minimized.

Owner

alexylem commented May 20, 2017

@claudioita We don't provide support here for Google Assistant SDK. Thank you for your understanding.

@jycoma

This comment has been minimized.

jycoma commented Nov 19, 2017

Hi,

I'm sorry but it is not possible to create the file alsa-base.conf.
I have this message when i want to create :
"modprobe.d/alsa-base.conf"
"modprobe.d/alsa-base.conf" E212: Can't open file for writing
Press ENTER or type command to continue

@Oliv4945

This comment has been minimized.

Collaborator

Oliv4945 commented Nov 20, 2017

Hi @jycoma, are you trying with sufficient privileges ?
As it seems to be an issue related to Alsa, you should ask Alsa developers ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment