NM-TAFE / dip-programming-prj-advanced-gui-architect

Creative Commons Zero v1.0 Universal
2 stars 4 forks source link

Minor feature: play a notification sound when an action is completed #20

Closed lowkw closed 3 months ago

lowkw commented 4 months ago

Suggest to play an action complete notification sound or action failed notification sound for the following:

Reason(s): A visual impaired student needs to know the status of his/her action initiated. For example, an action shall be failed when the OcrRoo server is shut down.

Problem simulation: Stop the OcrRoo server while the video is playing.

Rumsie-Grimshaw commented 3 months ago

After a quick google search - there is a python package called 'playsound' to achieve this. I would like to give this a shot.

lowkw commented 3 months ago

Thank you Rumsie for self-assigned to this enhancement.

I tried to execute the playsound("capture.wav") and getting the Error 304. The filename is invalid.

I find the following changes work for me. 1) set the relative path "static\audio" at utils.py 2) download the free mp3 sound files from https://pixabay.com/sound-effects/ 3) play the mp3 sound file (i.e. utils.playsound_notification("capture.mp3") )

utils.py

file_path = os.getcwd()
file_path += "\\static\\audio"
file_name = audio_file
file_path = os.path.join(file_path, file_name)
print(file_path)
if audio_file is not None:
    playsound(file_path)

app.py and extract_text.py

utils.playsound_notification("capture.mp3") utils.playsound_notification("success.mp3") utils.playsound_notification("fail.mp3")

Rumsie-Grimshaw commented 3 months ago

Thank you lowkw for making the suggestion and allowing me to attempt to contribute.

Appreciate the feedback! I just want to clarify that the audio file should be "capture_tone.wav" and not "capture.wav" unless you renamed the files? I'm sure you did this correctly - but for the sake of being thorough, i just wanted to check.

Really like your suggestion regarding adding the folder dir to the path construction! Do you think it was the wav. format that was not being detected?