[Python] PyDub not reading from CDRom

Discussão em 'Python' iniciado por Stack, Abril 27, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to write a python script that plays audio files off a CD. I have tested the code with audio files off the CD and it worked. But when I put the CD directory in, it stays silent and doesn't throw any errors.

    CD Reader Class

    class CD_Reader:
    def __init__(self):
    self.cdPath = "/run/user/1000/gvfs/cdda:host=sr0/" #CD Rom Path

    def playSong(self,format):
    print(self.cdPath + "Track 1.wav")
    song = AudioSegment.from_wav(self.cdPath + "Track 1.wav")
    play(song)#Works with files off CD


    Main.py

    import mediaPlayerClass
    import os


    #print(os.listdir("/run/user/1000/gvfs/cdda:host=sr0/"))
    player = mediaPlayerClass.CD_Reader()
    player.playSong("wav")


    Output (Inputted directory into file explorer and it existed)

    python3 main.py
    /run/user/1000/gvfs/cdda:host=sr0/Track 1.wav

    Continue reading...

Compartilhe esta Página