-1
from playsound import playsound
import cv2
image = cv2.imread("img.png")
cv2.imshow("image2", image), playsound("Stan.mp3")
cv2.waitKey(0)
cv2.destroyAllWindows()

I write this program, when I run it, this sound run the sound works well, but image doesn't run well and gets regimented. and my image not responding

I want to run this image and this sound same time

Prashant Maurya
  • 639
  • 4
  • 13

1 Answers1

0

In your code you are trying to do the 2 tasks sequentially instead of doing it parallel. In order to run both tasks in parallel use multi-threading. For example the below code will show image and play audio at the same time:

from playsound import playsound
import cv2
import _thread


def play_audio():
    playsound("stan.mp3")

image = cv2.imread("image.png")

_thread.start_new_thread( play_audio, () )
cv2.imshow("image2", image)
cv2.waitKey(0)
cv2.destroyAllWindows()
Prashant Maurya
  • 639
  • 4
  • 13