[new to stack overflow, don't know how to format. :) ]Trying to make it so when a user inputs something, it plays a sound, something maybe in this format?:
response = input(">>> ")
if response == 0
#play sound?
[new to stack overflow, don't know how to format. :) ]Trying to make it so when a user inputs something, it plays a sound, something maybe in this format?:
response = input(">>> ")
if response == 0
#play sound?
Use playsound
module to play a sound file like .wav
or .mp3
(You need to have a sound file downloaded).
Install playsound
using cmd with - pip install playsound
.
More info to install package
After installation, try this basic code to play sound -
from playsound import playsound
response = input(">>> ")
if int(response) == '0':
playsound('path to sound file')
print('Playing sound')
This would play the sound file when you type 0 as input
Check this for more info - https://pypi.org/project/playsound/