Morse Key help.
Hello repl! First post here. I decided to make a Morse key because I was bored. I didn't want it to translate Morse originally, I planned on somehow making the program be able to determine using length of user input and length in between inputs to determine whether it'd be a (.), a (_), or a (/), however at the moment I can't even get it to play anything.
My main goal at the moment is just to make it play a sound for the duration of a keypress. Eventually I plan on making the screen turn white (not the entire screen, just the one in the top right for pygame) as opposed to black by default, but my main focus is just the sound for the moment.
I tried making it play a note, guided by replit's own guide on playing audio. That didn't work, at least it wouldn't play again. Then tried audio files. Didn't like how short it was, so I made it longer and tried to make it loop while pressed, and play a loopoff sound when it stopped (not a problem at the moment, as I haven't even been able to get there to test it!)
Always the same error, regardless of keypress length, tine.sleep length, or audio file length:
Traceback (most recent call last): File "main.py", line 41, in <module> looponf = audio.play_file(sound_loopon) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/replit/audio/__init__.py", line 294, 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 238, in __get_new_source raise TimeoutError("Source was not created within 2 seconds.") TimeoutError: Source was not created within 2 seconds.
So currently, I have tried as well, replit audio doesn't work
well. I have tried multiple times, and yet it doesn't work. You should try using a different module or system, or maybe use a different python
lib to access music.
Hope this helps!
Yes. That is because replit runs on servers and not on your build in cpu. That is why you can run repl off a ipad or phone. If you were to set up a camera off regular code, then you would not be able access the camera because it is built in the servers. You can do it with html however because the main website or domain runs off your regular cpu. @JBloves27
Hey! So in your main code you never stated a place where the sound was supposed to execute. So basically to fix this, where you want sound, just type this..
Its simple but I don't see this anywhere in your code.
It seems to not want to co-operate. The code seems to work, but the audio does not play and it doesn't encounter any errors. Take note I've put a quick
from replit import audio source = audio.play_file("start.mp3") source.volume=(0.1) time.sleep(1.5) source.paused = True
at the beginning to trigger the little "We hear audio!" popup in case that is part of the problem.