0

Hi i am having a few problems with the winsound i want to play a short sound clip and on this page here: Play a Sound with Python it is said that this should work:

import winsound

winsound.PlaySound('sound.wav', winsound.SND_FILENAME)

on mine i get the error, the program and the audio file which is a .wav are both in the same folder, and im not sure why any help? Code:

import winsound

winsound.PlaySound('sound.wav', winsound.SND_audio)

Error:

Traceback (most recent call last):
  File "C:\Users\----\----\python\test\soundtest.py", line 3, in <module>
    winsound.PlaySound('sound.wav', winsound.SND_audio)
AttributeError: module 'winsound' has no attribute 'SND_audio'
Jeremy Hansford
  • 11
  • 1
  • 1
  • 3

2 Answers2

0

Replace .SND_audio with .SND_FILENAME as it said on the page and it should work.

If it still doesn't work try .SND_ASYNC

A Shem
  • 1
0

I got the same error. Code required to get it running was adding

winsound.PlaySound("soundname.wav", winsound.SND_ASYNC)
Dharman
  • 30,962
  • 25
  • 85
  • 135
Jan97
  • 21
  • 1
  • 5