Python Forum

Full Version: sounddevice errors ALSA audio
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello guys, i'm super new to this forum. My intention was to make use of PyMumble to make a client to make voice calls via Mumble.
I managed to listen the room, but i ran into issues. When i run the code on mac os it works fine, but when i run it on my Raspberry pi 3B i got these errors during the reception of sounds:
alsa lib pcm.c XXXX (snd_pcm_recover) underrun occurred
alsa lib pcm.c XXXX (snd_pcm_recover) underrun occurred
alsa lib pcm.c XXXX (snd_pcm_recover) underrun occurred
alsa lib pcm.c XXXX (snd_pcm_recover) underrun occurred
alsa lib pcm.c XXXX (snd_pcm_recover) underrun occurred
XXXX is a number. most people got this error online with different numbers. none of teir solutions worked for me.

i can hear everything but it skips frames it seems. not a good qality overall

i tried using pyaudio, but the quality was way much worse. plus i had to encapsulate the sream reading with try except, or the program would crash.
Thanks in advice for your help

import pymumble_py3
from pymumble_py3.callbacks import PYMUMBLE_CLBK_SOUNDRECEIVED as PCS
import sounddevice as sd


# Mumble server connection Settings
pwd = "" 
server = "10.211.55.3"  
nick = "audio-only_client"
port = 64738 

# Audio stream settings
CHUNK = 512*2
DATATYPE = 'int16'
CHANNELS = 1
RATE = 48000

# Inistialize the audio stream using devices
stream = sd.RawStream(device=("Built-in Microphone", "Built-in Output"), 
                   samplerate= RATE, 
                   channels= CHANNELS, 
                   blocksize= CHUNK,
                   dtype= DATATYPE)

def sound_received_handler(user, soundchunk):
    # When a sound packet arrives it is immediately written to the device output stream
    stream.write(soundchunk.pcm)

# This part is about the connection to the Mumble Server
# Setting 
mumble = pymumble_py3.Mumble(server, nick, password=pwd, port=port)
mumble.callbacks.set_callback(PCS, sound_received_handler)
mumble.set_receive_sound(1)
# Starting the client and waiting to be in
mumble.start()
mumble.is_ready()

# Starting the Stream
stream.start()


while True:
    pass