如何将 macOS Catalina 上的音量调整为浮点数(例如 6.5)而不是 osascript 允许的整数?

问题描述 投票:0回答:1

上面的问题,总的来说,我的程序的目标是逐步增加音量,直到用户能够听到声音,然后将该值存储到一个变量中,然后可以稍后访问该变量,我将非常感谢任何帮助我如何才能实现这一目标?

进一步参考:当运行“短语”下面的代码时,打印出来的只是当前值+1(因为它向上舍入),例如,如果当前音量= 6,那么它会变成7,而不是6.5,但我需要一个将音量更改为 6.5 的方法(例如)。

current_volume = float(osascript.osascript("output volume of (get volume settings)")[1])
print(current_volume)
phrase = "set volume output volume {}".format(current_volume + 0.5)
print(phrase)
osascript.osascript(phrase)
sleep(1)
python macos volume osascript
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.