0

I copied this program from a previous reply on this site:

import pygame
pygame.mixer.init()
pygame.mixer.music.load('beep.wav')
pygame.mixer.music.play()

while pygame.mixer.music.get_busy()==True:
    continue

The 'beep.wav. file is located in the python programs file

When I run it, I get the following:

Traceback (most recent call last):
  File "/home/pi/programs/test pygame.py", line 3, in <module>
    pygame.mixer.music.load('beep.wav')
pygame.error: Couldn't open 'beep.wav'

I would be grateful for advice about where I am going wrong. have I put the wav file in the wrong place?

Thanks

  • check the bit rate of the file. I seem to remember that pygame has a specific file format of what it will play back. I used it a couple years back and had to use Audacity to convert a bunch of little sound bites to the correct format for it to work. – Chef Flambe Feb 2 '18 at 21:35
0

Solved. It is a problem with the 'wav' file. I tried with a 'wav' file from the python games folder, and that works.

I don't know what the problem with my file is - it works ok with windows, but that's a different issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.