Python Play sound using pygame

shaggs

I'm trying to get a .wav file to play in my python script.

If I place the sound in the root folder the sound works.

If I move the file and reference it in the script it doesn't and I'm sure my reference is wrong. I have tried 3 ways, but nothing seems to be working.

Attempt 1:

sounds = os.path.basename ("C:\pager printer\src\pagerprinter\sounds\a.wav") s = pygame.mixer.Sound("sounds")

Attempt 2:

s = pygame.mixer.Sound("C:\pager printer\src\pagerprinter\sounds\a.wav")

Attempt 3:

sounds = os.path.basename("/pagerprinter/sounds/a.wav")
s = pygame.mixer.Sound("sounds")

Attempt 3 script is run in folder src using

 c:\pager printer\src>python -m pagerprinter.pagerprinter

If I place sound in

C:\pager printer\src

and run code as

s = pygame.mixer.Sound("a.wav")`

It works, but I wish to make file neat and tidy.

shaggs

Found it

s = os.path.join('pagerprinter', 'sounds', 'a.wav')

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Python: using pygame to play sounds

From Dev

Making Pygame Play Sound ONCE

From Dev

Play a sound using SoundPlayer

From Dev

Trying to play a Random Sound using SimpleAudioEngine, no sound

From Java

How to play a sound using Swift?

From Dev

Play sound using bytes array

From Dev

Play notification sound using URL

From Dev

Why does pygame.mixer.Sound().play() returns None?

From Dev

Why does pygame.mixer.Sound().play() returns None?

From Dev

Classes using AudioToolBox to play sound file compiles but no sound

From Dev

play sound & run timer using jquery

From Dev

Can I play a sound with vibrate using AVAudioPlayer?

From Dev

Play sound at application startup using eventtrigger

From Dev

Can I play a sound with vibrate using AVAudioPlayer?

From Dev

How to play a random sound using SoundPool?

From Dev

How do i play a sound in python 3?

From Dev

Using pygame to play a MIDI file from stream

From Dev

Play sound using timer on Android (Chrome) using JavaScript

From Java

Using Pygame with parallelism in python

From Dev

Why is attempting to use pygame.mixer.Channel.play(Sound) raising a SystemError?

From Dev

Play sound in Win32 program using MinGW + Eclipse

From Dev

How to play a sound using Qt from a specific point (timecode)?

From Dev

Play sound in left or right speaker using android AudioTrack

From Dev

play a sound in onClick within a fragment using media player or soundpool

From Dev

How to play any type of audio/sound file using C?

From Dev

Flash in browsers does not play sound accurately using Pulse network audio

From Dev

Play sound in Win32 program using MinGW + Eclipse

From Dev

Play sound based on array element using its index

From Dev

Play sound from resource file using c# wpf

Related Related

  1. 1

    Python: using pygame to play sounds

  2. 2

    Making Pygame Play Sound ONCE

  3. 3

    Play a sound using SoundPlayer

  4. 4

    Trying to play a Random Sound using SimpleAudioEngine, no sound

  5. 5

    How to play a sound using Swift?

  6. 6

    Play sound using bytes array

  7. 7

    Play notification sound using URL

  8. 8

    Why does pygame.mixer.Sound().play() returns None?

  9. 9

    Why does pygame.mixer.Sound().play() returns None?

  10. 10

    Classes using AudioToolBox to play sound file compiles but no sound

  11. 11

    play sound & run timer using jquery

  12. 12

    Can I play a sound with vibrate using AVAudioPlayer?

  13. 13

    Play sound at application startup using eventtrigger

  14. 14

    Can I play a sound with vibrate using AVAudioPlayer?

  15. 15

    How to play a random sound using SoundPool?

  16. 16

    How do i play a sound in python 3?

  17. 17

    Using pygame to play a MIDI file from stream

  18. 18

    Play sound using timer on Android (Chrome) using JavaScript

  19. 19

    Using Pygame with parallelism in python

  20. 20

    Why is attempting to use pygame.mixer.Channel.play(Sound) raising a SystemError?

  21. 21

    Play sound in Win32 program using MinGW + Eclipse

  22. 22

    How to play a sound using Qt from a specific point (timecode)?

  23. 23

    Play sound in left or right speaker using android AudioTrack

  24. 24

    play a sound in onClick within a fragment using media player or soundpool

  25. 25

    How to play any type of audio/sound file using C?

  26. 26

    Flash in browsers does not play sound accurately using Pulse network audio

  27. 27

    Play sound in Win32 program using MinGW + Eclipse

  28. 28

    Play sound based on array element using its index

  29. 29

    Play sound from resource file using c# wpf

HotTag

Archive