A few seconds after launching the python program I wanted a beep sound, but I couldn't make it so I'll make a note of it.
ubuntu 16.04 python 3.6
import os
import time
duration = 1 # seconds
freq = 440 # Hz
bool1 = True
elapsed_time = 0
while bool1:
start = time.time()
elapsed_time += time.time() - start
if elapsed_time >= 2.5:#Adjust yourself
os.system('play -nq -t alsa synth {} sine {}'.format(duration, freq))
bool1 = False
It's just a memo. .. .. Please let me know if there is a better way.
Recommended Posts