The problem is when I am using sounddevice's loop option to loop a playback, I cannot get it to stop.
import soundfile as sf
import sounddevice as sd
weight = 1.4
data, fs = sf.read('sound.wav')
sd.play(data * weight, fs, blocking=True,loop=True)
sd.stop()
How to stop the loop, after it has started. Is it possible to write a function such that when the function is called the loop stops and the audio stream is closed?