Problems adding audio?

Hiya - I am relatively new to replit, and working through the 100 days of code. I’m on day 35, and I’m making a basic "to-do list’ programme. and at the end once all the tasks are completed, i want it to play a little “tada!” sound, i’ve followed all the tutorials I can find about adding audio, and I can’t work out why it’s not working. what’s weird is sometimes it works, and sometimes it doesn’t, depending on the run (without me having changed any of the code).

i’ve published it here if anyone feels like having a look and helping me out, what have I done wrong?

at the minute, when i run through console in the workspace, it works. when i run from that page, it works but no audio. when i’ve sent it to a friend, it works until the place where there should be audio and then she gets loads of error messages.

Hi @ahollyborealis , welcome to the forums! Replit audio is known to be buggy.

1 Like

Just to confirm, you are using from replit import audio?
I had problems too, back when I did 100DC.

yes from replit import audio, and then i’ve dragged my audio file into the files. it plays for me when i run it through console but just seems really clunky, and then doesn’t work at all sometimes, and then on a different browser comes up with error messages. it’s annoying!

Yes, I get errors too.

Hmm… @IanAtCSTeach sorry to ping you, but can you take a look?

1 Like

Based on my experience with replit audio, I just have these 3 things to say…

  1. Replit audio doesn’t work on the cover page, period.
  2. If your program tries to import anything from replit when being run by an anonymous user, it will return an error unless the replit/ file is modified.
  3. Replit audio is extremely underdocumented, which could (and most likely) would lead to silent errors.
    Overall, i would suggest that you put some TADA animation in the console at the end if your audience isnt using the workspace to run the code.

try this:

import time
import playsound

# ...

# After your to-do list has been completed
time.sleep(1)  # Add a 1-second delay
playsound.playsound('path/to/audio/file.mp3') # in this case your 'tada' sound

1 Like

sound is not a built-in feature of any command-line interface, and can only coexist if implemented separately, such as through websockets in the browser, or opening vlc or some other video/audio plugin in the background. what might work on one device might not work on another, such as in an SSH connection with a remote server, with or without X11 forwarding

1 Like