Created
September 20, 2025 17:16
-
-
Save trappedinspacetime/e97b633317a53bf0e20478afd0708911 to your computer and use it in GitHub Desktop.
hotword detection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| import pyaudio | |
| import numpy as np | |
| from openwakeword.model import Model | |
| MODEL_PATH = "yah_zuh_juh.tflite" | |
| CHUNK = 1280 | |
| RATE = 16000 | |
| FORMAT = pyaudio.paInt16 | |
| CHANNELS = 1 | |
| audio = pyaudio.PyAudio() | |
| mic_stream = audio.open(format=FORMAT, channels=CHANNELS, | |
| rate=RATE, input=True, frames_per_buffer=CHUNK) | |
| owwModel = Model(wakeword_models=[MODEL_PATH], inference_framework="tflite") | |
| last_detect_time = 0 | |
| cooldown = 1.5 # saniye | |
| print("Dinleniyor...") | |
| while True: | |
| audio_data = np.frombuffer(mic_stream.read(CHUNK), dtype=np.int16) | |
| owwModel.predict(audio_data) | |
| for mdl in owwModel.prediction_buffer.keys(): | |
| score = list(owwModel.prediction_buffer[mdl])[-1] | |
| if score > 0.5 and (time.time() - last_detect_time > cooldown): | |
| print(f"Hotword algılandı! ({mdl}) Skor: {score:.2f}") | |
| last_detect_time = time.time() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment