-1

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

hcheung
  • 845
  • 7
  • 14
epzcaw
  • 9
  • 1
  • 2
  • 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 02 '18 at 21:35

1 Answers1

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.

epzcaw
  • 9
  • 1
  • 2
  • 1
    Please accept your own answer with a click on the tick on its left side. Only this will finish the question and it will not pop up again year for year. – Ingo Jan 05 '20 at 11:26