Skip to content

Instantly share code, notes, and snippets.

@excenter
Created July 15, 2019 18:43
Show Gist options
  • Save excenter/4aadddfd618b31b8b02d3a0a051732d4 to your computer and use it in GitHub Desktop.
Save excenter/4aadddfd618b31b8b02d3a0a051732d4 to your computer and use it in GitHub Desktop.
from pyogg import VorbisFile
from pygame import mixer
# path to your audio
path = "./file.ogg"
# an object representing the audio, see https://github.com/Zuzu-Typ/PyOgg
sound = VorbisFile(path)
# pull the frequency out of the Vorbis abstraction
frequency = sound.frequency
# initialize the mixer
mixer.init(frequency=frequency)
# add the audio to the mixer's music channel
mixer.music.load(path)
# mixer.music.set_volume(1.0)
# mixer.music.fadeout(15)
# play
mixer.music.play()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment