我想使用python和raspberry pi构建学校报警应用程序。
如何使用python在指定的时间播放音频文件?
答案 0 :(得分:0)
如果警报噪声文件与python文件本身位于同一目录中,则此方法有效。我确实警告过你,虽然这是非常笨重的,声音文件是单独打开的,但它仍然可以满足你的要求。
import os, time
while True:
os.startfile("FILENAME OF SOUND") #Replace with the appropriate file name (Make sure the alarm sound is in the same directory as the python file else this will not work)
time.sleep(DELAY IN SECONDS) #This is how long the delay is between each time it opens the sound