Hi, this is my script
import numpy as np
import sounddevice as sd
import librosa
import threading
import keyboard
gleaming_audio, _ = librosa.load("GleamingAudio.wav", sr=44100)
def detect_audio(stop_event,):
stream = sd.InputStream(samplerate=44100, channels=2)
stream.start()
audio_record = []
while not stop_event.is_set():
frame, _ = stream.read(1)
frame = np.mean(frame, axis=1)
audio_record.extend(frame)
if len(audio_record) == 84143:
correlation = np.corrcoef(audio_record, gleaming_audio)[0, 1]
if correlation > 0.5:
print("Gleaming audio detected!")
audio_record.pop(0)
def main():
stop_event = threading.Event()
print("Detecting gleaming audio...")
detect_thread = threading.Thread(target=detect_audio, args=(stop_event,))
detect_thread.start()
keyboard.wait("0")
stop_event.set()
detect_thread.join()
print("Gleaming audio detection stopped.")
if __name__ == "__main__":
main()
the problem is that it doesnt detect even when i play the audio, does any1 know why?