Ask coding questions

← Back to all posts
Replit audio not working
h
ch1ck3n (2088)

I'm trying to make a python program, and I want notifications to work, and I'm using the replit audio API (I have explorer turned on)

and I try this bit of code:

audio.play_file('tarzan-screaming.wav')

I run it, then suddenly I get an error.

Traceback (most recent call last):
  File "main.py", line 9, in <module>
    audio.play_file('tarzan-screaming.wav')
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/replit/audio/__init__.py", line 293, in play_file
    return self.__get_new_source(name, does_loop)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/replit/audio/__init__.py", line 237, in __get_new_source
    raise TimeoutError("Source was not created within 2 seconds.")
TimeoutError: Source was not created within 2 seconds.

I don't know what I'm doing wrong, please help.

Answered by UnikaftUnikaft (6) [earned 5 cycles]
View Answer
Comments
hotnewtop
FloCal35 (666)

Your audio file is empty, thus there is nothing to play. It shoud run correctly after you fix it

ch1ck3n (2088)

@FloCal35 No i uploaded it from my local computer, if i download it i can play it but in repl.it i can't.

FloCal35 (666)

Send it to another device and upload it from there??? @ch1ck3n. Or just report it

UnikaftUnikaft (6)

@FloCal35 could it also be that the audio file is too short?

FloCal35 (666)

finally marks correct answer after 3 months @ch1ck3n

RYANTADIPARTHI (6018)

that's a TimeoutError. You get that if your music file is too long or nothing. For this case, it seems your music file has nothing in it.

that's probably the cause of the error.

ch1ck3n (2088)

@RYANTADIPARTHI No i uploaded it from my local computer, if i download it i can play it but in repl.it i can't.

ch1ck3n (2088)

here's a completely unrelated error i got hours before that's not this project