Mycroft Community Forum

Newbie Problems? No audio output on USB-Card, no change to german language

I’m a newbie on Picroft. I’m a user of Snips which community is closed. Now I’m looking for alternatives. Download, installing and running setup generally without problems, but the usb analog output (headset) isn’t recognized by the setup procedure - the usb microphone works well. Only the 3,5 mm plug of the Raspi4 is used for audio output. Where is the configuration file for audio settings stored? Second problem: Changing to german language is impossible. I used this description https://github.com/MycroftAI/documentation/pull/98/files but starting mycroft-cli-client produces error messages and changes all entries of the ~/.mycroft/mycroft.conf file back to standard values. Does anybody know what is going wrong?

Hi @JoergZ

Ill recomend first get mycroft to work and then change language. One problem at a time.

For audio troubleshooting you can get som good information here

https://mycroft-ai.gitbook.io/docs/using-mycroft-ai/troubleshooting/audio-troubleshooting

When that works look at how to change language
That is covered in Language section
https://mycroft-ai.gitbook.io/docs/using-mycroft-ai/customizations/languages

hello regarding the change in german i wrote a little instruction in german: https://github.com/gras64/docs-rewrite/blob/master/_pages/german.md
You can also reach us in de chat.

1 Like

Ok, first audio configuration. I read the audio troubleshooting page and did all the things which have to do with pulseaudio. Pulse is recommended by mycroft., isn’t it? Result of pactl info:
Server String: /run/user/1000/pulse/native
Library Protocol Version: 32
Server Protocol Version: 32
Is Local: yes
Client Index: 89
Tile Size: 65496
User Name: pi
Host Name: picroft
Server Name: pulseaudio
Server Version: 12.2
Default Sample Specification: s16le 2ch 44100Hz
Default Channel Map: front-left,front-right
Default Sink: alsa_output.usb-0d8c_USB_PnP_Sound_Device-00.analog-stereo
Default Source: alsa_input.usb-0d8c_USB_PnP_Sound_Device-00.analog-mono
Cookie: 22b7:8339

The mic is working fine, but no output on the Default sink. But if I sent a wav-file to default sink directly it’s gonna be played: paplay foo.wav works. Output is on USB connected headset

And I did:
mycroft-config set listener.device_name “pulse”

mycroft-start audiotest -l shows
====================== Audio Devices ======================
Index Device Name
3: pulse
7: default

========================== Info ===========================
Input device: pulse @ Sample rate: 16000 Hz
Playback commandline: paplay  WAV_FILE

===========================================================
 ==         STARTING TO RECORD, MAKE SOME NOISE!          ==
===========================================================

But the record is sent to 3,5 mm audio plug

Changing first line in file /etc/mycroft/mycroft.conf to
“play_wav_cmdline”: “paplay %1”

produces an error message:
An error occured while playing back audio (1)

I’ve done mycroft-setup-wizard several times but nothing brought the USB output working.

Question: What is the function of the Chat. It looks like another forum. I had expected online dialogue possibilities

EDIT: Actually there is no sound neither on 3,5 mm plug nor on USB audio output!
EDIT(2): After I remove the new line from ~/.mycroft/mycroft.conf which was the result of the command
mycroft-config set listener.device_name “pulse” audio is on 3,5 mm plug again

The Chat is found on to menu on most mycroft.ai pageses or in the side menu on some pages.

It all points to this link https://chat.mycroft.ai/

In the chat there are different channels and specfik one for troubleshooting.

All that said, the Picroft is “just” a Raspbian with Mycroft preinstalled. So often you can find information regarding specifik hardware on raspbian specifik sites on the net. And when your hardware is working ads you want, then configure Mycroft to use that.

Or you can try in the Mycroft chat :slight_smile:

1 Like

Ok, german speaking is installed and running but not the wakeword. That’s not very important for the moment. My main failure: syntax of JSON, the damn colons :wink: Thank you for the german translation! Pleas give an information (also at @KathyReid ) that the installation of the libraries must be done first and than editing the mycroft.conf file and restarting the system.

1 Like

pacmd is always a good start and you can also set the defaults that way.

pacmd list-cards

throw the whole output on here so people can have a look.

pacmd set-default-sink 1 which is an output and you can also do it via full sink name alsa_output.usb-0d8c_USB_PnP_Sound_Device-00.analog-stereo instead if the index

pacmd set-default-source 1 which is an input and same again with full name. alsa_input.usb-0d8c_USB_PnP_Sound_Device-00.analog-mono

Download this file and play it:
wget http://youness.net/wp-content/uploads/2016/08/h2g2.ogg -P /tmp/
paplay /tmp/h2g2.ogg

Try to record your voice:
parecord -v /tmp/voice.wav

Play it back:
paplay -v /tmp/voice.wav

I think Mycroft is originally setup for default, but use pacmd and get pulse working and know what outputs correspond to which before changing the Mycroft setting.

Dunno why but seem to prefer pacmd over the pactl commands, but choice is yours.

OMG! Before I’m posting the results of pacmd let me tell you, that now the usb speaker (headphone) is working with the setup-wizard but not the microphone. Using Mycroft ow neither 3,5 mm jack nor usb-speaker is working, but the mic!
parecord and paplay is working. So, on the OS level pulse is okay but Mycroft does not communicate with the speaker (mic is working).

Result of pacmd list-cards:
(.venv) pi@picroft:~ $ pacmd list-cards
2 card(s) available.
index: 0
name: <alsa_card.usb-0d8c_USB_PnP_Sound_Device-00>
driver: <module-alsa-card.c>
owner module: 20
properties:
alsa.card = “1”
alsa.card_name = “USB PnP Sound Device”
alsa.long_card_name = “USB PnP Sound Device at usb-0000:01:00.0-1.3, full speed”
alsa.driver_name = “snd_usb_audio”
device.bus_path = “platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.3:1.0”
sysfs.path = “/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.3/1-1.3:1.0/sound/card1”
udev.id = “usb-0d8c_USB_PnP_Sound_Device-00”
device.bus = “usb”
device.vendor.id = “0d8c”
device.vendor.name = “C-Media Electronics, Inc.”
device.product.id = “013c”
device.product.name = “CM108 Audio Controller”
device.serial = “0d8c_USB_PnP_Sound_Device”
device.string = “1”
device.description = “CM108 Audio Controller”
module-udev-detect.discovered = “1”
device.icon_name = “audio-card-usb”
profiles:
input:analog-mono: Analog Mono Input (priority 7, available: unknown)
output:analog-stereo: Analog Stereo Output (priority 6500, available: unknown)
output:analog-stereo+input:analog-mono: Analog Stereo Output + Analog Mono Input (priority 6507, available: unknown)
output:iec958-stereo: Digital Stereo (IEC958) Output (priority 5500, available: unknown)
output:iec958-stereo+input:analog-mono: Digital Stereo (IEC958) Output + Analog Mono Input (priority 5507, available: unknown)
output:iec958-ac3-surround-51: Digital Surround 5.1 (IEC958/AC3) Output (priority 300, available: unknown)
output:iec958-ac3-surround-51+input:analog-mono: Digital Surround 5.1 (IEC958/AC3) Output + Analog Mono Input (priority 307, available: unknown)
off: Off (priority 0, available: unknown)
active profile: output:analog-stereo+input:analog-mono
sinks:
alsa_output.usb-0d8c_USB_PnP_Sound_Device-00.analog-stereo/#1: CM108 Audio Controller Analog Stereo
sources:
alsa_output.usb-0d8c_USB_PnP_Sound_Device-00.analog-stereo.monitor/#2: Monitor of CM108 Audio Controller Analog Stereo
alsa_input.usb-0d8c_USB_PnP_Sound_Device-00.analog-mono/#3: CM108 Audio Controller Analog Mono
ports:
analog-input-mic: Microphone (priority 8700, latency offset 0 usec, available: unknown)
properties:
device.icon_name = “audio-input-microphone”
analog-output-speaker: Speakers (priority 10000, latency offset 0 usec, available: unknown)
properties:
device.icon_name = “audio-speakers”
iec958-stereo-output: Digital Output (S/PDIF) (priority 0, latency offset 0 usec, available: unknown)
properties:

    index: 1
	name: <alsa_card.platform-soc_audio>
	driver: <module-alsa-card.c>
	owner module: 21
	properties:
		alsa.card = "0"
		alsa.card_name = "bcm2835 ALSA"
		alsa.long_card_name = "bcm2835 ALSA"
		alsa.driver_name = "snd_bcm2835"
		device.bus_path = "platform-soc:audio"
		sysfs.path = "/devices/platform/soc/soc:audio/sound/card0"
		device.form_factor = "internal"
		device.string = "0"
		device.description = "Built-in Audio"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card"
	profiles:
		output:analog-mono: Analog Mono Output (priority 700, available: unknown)
		off: Off (priority 0, available: unknown)
	active profile: <output:analog-mono>
	sinks:
		alsa_output.platform-soc_audio.analog-mono/#2: Built-in Audio Analog Mono
	sources:
		alsa_output.platform-soc_audio.analog-mono.monitor/#4: Monitor of Built-in Audio Analog Mono
	ports:
		analog-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
			properties:

I am a noob with Mycroft also but prob the initial setup I think should be to use the defaults.
I actually don’t know what the mycroft-config set listener.device_name “pulse” script does in terms of PA default devices.

I got a bit confused on my first attempts with mycroft hence my pacmd knowledge which is all fresh :slight_smile:

I think vanilla mycroft is setup to use the defaults.
So on a fresh flash of mycroft as prob setting back listener.device_name to default will grab the Mic? as sort of unsure what “pulse” refers to.

You have pacmd list-cards

Then you can set the card profile pacmd set-card-profile cardname profilename

Then set default sink ( Output) which is usually in cardname.profile format

pacmd set-default-sink cardname.profile

Then set default source (Input) same again

pacmd set-default-source cardname.profile

On a fresh install of mycroft if it wasn’t good to go from a usb setup then prob the above should do it.

pulseaudio -k kills the daemon and think it should autorespawn.
pulseaudio --start if it doesn’t.

I found at times that I had got the sound right but prob needed to restart mycroft or pulseaudio as soud was lost until reboot.

Still a noob with mycroft but now know much more about pulseaudio :slight_smile:

To make default settings for the pulseaudio daemon we can edit /etc/pulse/default.pa (as root) to give a default source or sink in the last section by uncommenting the corresponding lines and give in the name of our output sink and input source:

### Make some devices default
set-default-sink <name_of_sink>
set-default-source <name_of_source>

If your sound card needs a specific profile you could also add the following line:

set-card-profile <cardindex> <profilename>

Guess that is the better option as you will then be certain pulseaudio and mycroft start with the right defaults, but don’t think its needed.
Also it then confuses me how to add echo cancellation and speaker feedback.

    ### Enable Echo/Noise-Cancellation
    load-module module-echo-cancel use_master_format=1 aec_method=webrtc aec_args="analog_gain_control=0\ digital_gain_control=1\ agc_start_volume=85"  source_name=echoCancel_source sink_name=echoCancel_sink

    set-default-source echoCancel_source
    set-default-sink echoCancel_sink

Solved(2) - much more elegantly
Update! It’s more simple without killing the audio drivers for bcm2835. Just edit two lines in the /etc/mycroft/mycroft.conf file. If the usb -card ist registrated as card 1 (aplay -l) then write this:
“play_wav_cmdline”: “aplay -Dhw:1,0 %1”,
“play_mp3_cmdline”: “mpg123 -a hw:1,0 %1”,
and all sounds are routed to the usb sound card.

DEPRECATED: Solved! (With a big hammer :slight_smile: )
Thank you very much for your detailed answer! Nevertheless I decided to go a different way for the following reason: pulseaudio worked correctly on operating system level. In the mycroft-setup-wizard the USB soundcard was recognized correctly. The audio test was successful, I could hear the word test, the volume control worked. The (USB-)microphone test seemed to be unsuccessful, because I couldn’t hear anything afterwards. But there was a current file /tmp/test.wav. This file could be played with paplay /tmp/test.wav. So it was proven that basically the sound was both output and recorded via USB. Only the assignment to which output the output is routed does not work neither in the wizard nor in the running Picroft program.
How did I solve it:
I noticed in voice.log that Picroft always tries to address the (alsa) device 0. But this is the bcm2835 chip.
First I deactivated the audio chip driver in raspberry:
sudo nano /etc/modprobe.d/alsa-blacklist.conf
I added the line blacklist snd_bcm2835
This disables the output via the 3.5 mm connector. However, this alone was not enough. I had to intervene much deeper into the system:
sudo nano /lib/modprobe.d/aliases.conf
and there comment out the line options snd-usb-audio index=-2
This causes the USB device to get priority.
Then reboot. Now I could communicate with Mycroft on a Raspberry Pi 4 via the USB soundcard.
But what I don’t hear is the confirmation sound after calling “Hey Mycroft”. This is still a bit strange.

The solution is, I think, quite brutal, but it works. It seems to me that the wizard still needs to be revised. Now that the hardware is working as desired, I can finally start to explore the functionalities: What I already noticed: The system is quite slow. I have been using SNIPS so far. This is much faster (on a Raspberry Pi 3!). But that is another matter…

3 Likes

A more elegant solution to ur problem would be to create a /etc/asound.conf file and set the proper defaults.

https://www.alsa-project.org/wiki/Asoundrc

Set the usb audio as the default out and wham’o.

1 Like

@c0rnelius Thanks. The best thing would be for the Picroft developers to look into this and improve the checking for multiple sound cards and adjust the selections accordingly.

You are prob right there as if you look at the number of solutions given there are too many options.
Should be just a singular conf prob .asoundrc as that seems a common method.
I would seem things have been a fix on a fix as revisions and dev has gone along and could likely just all build up and use .asoundrc.
I can’t remember if the pulse module-auto-switch is enabled or not as that can sometimes confuse.

https://www.alsa-project.org/wiki/Asoundrc