有没有办法给代码添加音效python
Is there a way to add sound effects to code python
[栈溢出新手,不知道怎么格式化。 :) ]试图做到这一点,当用户输入某些东西时,它会播放声音,可能是这种格式的东西?:
response = input(">>> ")
if response == 0
#play sound?
使用playsound
模块播放.wav
或.mp3
等声音文件(您需要下载声音文件)。
使用 cmd 和 - pip install playsound
安装 playsound
。
More info to install package
安装完成后,试试这个基本代码来播放声音-
from playsound import playsound
response = input(">>> ")
if int(response) == '0':
playsound('path to sound file')
print('Playing sound')
这将在您输入 0 作为输入时播放声音文件
查看此以获取更多信息 - https://pypi.org/project/playsound/
[栈溢出新手,不知道怎么格式化。 :) ]试图做到这一点,当用户输入某些东西时,它会播放声音,可能是这种格式的东西?:
response = input(">>> ")
if response == 0
#play sound?
使用playsound
模块播放.wav
或.mp3
等声音文件(您需要下载声音文件)。
使用 cmd 和 - pip install playsound
安装 playsound
。
More info to install package
安装完成后,试试这个基本代码来播放声音-
from playsound import playsound
response = input(">>> ")
if int(response) == '0':
playsound('path to sound file')
print('Playing sound')
这将在您输入 0 作为输入时播放声音文件
查看此以获取更多信息 - https://pypi.org/project/playsound/