I have this code that plays a video, and detects something on it. Whenever it detects something in the video, I want to hear something, here is the code:
import cv2
import os
video_capture = cv2.VideoCapture('video')
while True:
_, frame = video_capture.read()
found = detect_something(frame)
if found :
os.system("aplay 'alarm'")
cv2.imshow('Video',frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
video_capture.release()
cv2.destroyAllWindows()
The problem is that, whenever it plays the alarm, the video freezes. I want the alarm to be played as a background sound. How can I do that?