0

I was wondering is there anyway I could play a sound without importing an external library like pygame. Something like this:

import os    
import sound

mysound = sound.load("mysound.mp3") # gets the sound "mysound.mp3"

while True:    
        input("Press enter to play sound")    
        sound.play(mysound) # plays the sound mysound        
        os.system('cls') # clears the console
Ben
  • 48,249
  • 32
  • 114
  • 131
David Callanan
  • 3,296
  • 2
  • 35
  • 70

2 Answers2

2

You cannot. You need some library.

nothrow
  • 14,840
  • 6
  • 50
  • 97
1

The standard library has some functions for playing .wav files (see winsound.PlaySound on Windows and the slightly outdated ossaudiodev for Linux), but AFAIK no methods for loading .mp3 files.

This question has several answers listing various third-party modules for playing sound.

Community
  • 1
  • 1
nneonneo
  • 154,210
  • 32
  • 267
  • 343