2

I'm using Raspberry Pi 3b, usb mic and 3.5mm audio jack as speaker. mic is hw:1,0; speaker is hw:0,0

Everything works fine except that I'm unable to get pygame.mixer.Sound.play() in a python script to work.

Script:

import time
import pygame
pygame.init()
pygame.mixer.init()
sounda=pygame.mixer.Sound("test.wav")
sounda.play()

I get:

ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
pygame.error: No available audio device

or MemoryError

However if I enter python2&3 environment then run the commands again, it worked fine... Appreciate the help.

June Wang
  • 241
  • 1
  • 4
  • 11

1 Answers1

3

I finally made this work.

Check your alsa.conf and .asoundrc file, only one of them needs to be configured with your audio setup.

I setup my audio in both files which caused the confusion, once I restored alsa.conf to default, the problem is gone.

June Wang
  • 241
  • 1
  • 4
  • 11