Skip to content

Instantly share code, notes, and snippets.

@HuangJiaLian
Last active September 23, 2022 17:52
Show Gist options
  • Save HuangJiaLian/d83f13db1f26fec3c876d3e99952147d to your computer and use it in GitHub Desktop.
Save HuangJiaLian/d83f13db1f26fec3c876d3e99952147d to your computer and use it in GitHub Desktop.
Play click sound
import simpleaudio, time
strong_beat = simpleaudio.WaveObject.from_wave_file('strong_beat.wav')
while True:
strong_beat.play()
time.sleep(0.5)
@Zigomar7
Copy link

Zigomar7 commented Sep 22, 2022

Hi,
I get : "FileNotFoundError: [Errno 2] No such file or directory: 'strong_beat.wav'" on line 2
I searched my C drive for 'strong_beat.wav', seems it should come with the package, but its not with the samples in ...\AppData\Local\Packages\Python...\site-packages\simpleaudio\test_audio.
What happened ?
I also tried with the name of one of the wav file (without path) from test_audio folder and it wasn't found either (It worked with a full path) !
A questions pops to mind : what is the default directory for simpleaudio.WaveObject.from_wave_file ?
Where will I find this type of information ?
I'm new to Python ...
Thanks

@HuangJiaLian
Copy link
Author

@Zigomar7 Hi, sorry to make you confused. Here, the audio file strong_beat.wav should be placed in the same folder as the python script 1_play_beats.py. You can download it from here: https://github.com/HuangJiaLian/HuanBu_Metronome/tree/main/src .

@Zigomar7
Copy link

Zigomar7 commented Sep 23, 2022

I had a hard time finding how to download.
After trying a number of ways from that page and the main page I ended up in the project page where I found the Code tab with Download ZIP link !
thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment