gpt4 book ai didi

python - 有没有办法使用 qpython 播放声音?

转载 作者:行者123 更新时间:2023-11-30 21:49:40 27 4
gpt4 key购买 nike

我正在尝试在 qpython 中运行以下脚本。您能否建议 android 中 mpg321 的替代方案?

import os
from time import sleep as sleep

pwd = os.path.dirname(os.path.abspath(__file__))
os.chdir(pwd)

work_time = int(raw_input("give the working time. Default time is 25 minutes : ") or "25")
chill_time = int(raw_input("give the chill out time. Default time is 3 minutes : ") or "3")
total_time = int(raw_input("give the total working time. Default is 3 hours : ") or "3")*60

loop_count = (total_time/(work_time+chill_time+1))+1



def notificationsystem(work_time, chill_time):
print "stop procrastinating and start working"
os.system('mpg321 start.mp3 &')
sleep(work_time*60)
print ("take a break for %s minutes" % chill_time)
os.system('mpg321 stop.mp3 &')
sleep(chill_time*60)


while loop_count > 0:
notificationsystem(work_time, chill_time)
loop_count -= 1

最佳答案

您可以尝试内置的 sl4a 模块:

import sl4a
ad = sl4a.Android()
ad.mediaPlay("/your/path/to/sound.mp3")

关于python - 有没有办法使用 qpython 播放声音?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34732229/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com