Commit 5d74f47b authored by Paul Bethge's avatar Paul Bethge
Browse files

add waiting and comments

parent 4ddd302e
0.1.0: 2021 Jan 01
0.1.0: 2021 Sep 15
* fixed issue A
* added feature B
* updated thing C
* removed widget D
* added kws model trained on "yes, no, unknown"
......@@ -4,6 +4,7 @@ import pyaudio
import scipy.io.wavfile as wav
import threading
from queue import Queue
import time
import torch
torch.set_num_threads(1)
......@@ -16,7 +17,7 @@ from tensorflow.keras.models import load_model
# Configure
vad_threshold = 0.8 # minimum confidence of the VAD to trigger KWS
kws_threshold = 0.95 # minimum confidence of the KWS to detect a word
kws_threshold = 0.8 # minimum confidence of the KWS to detect a word
kws_required_size = 4 # number of chunks -1 to feed into the KWS
frame_duration_ms = 250 # chunks size for the VAD in milliseconds (250ms is min)
......@@ -68,11 +69,6 @@ CHANNELS = 1
SAMPLE_RATE = 16000
CHUNK = int(SAMPLE_RATE / 10)
audio = pyaudio.PyAudio()
stream = audio.open(format=FORMAT,
channels=CHANNELS,
rate=SAMPLE_RATE,
input=True,
frames_per_buffer=CHUNK)
chunk_size = int(SAMPLE_RATE * frame_duration_ms / 1000.0)
data = []
......@@ -80,7 +76,17 @@ audio_int16 = []
nu_voice_chunks = 0
got_voice = False
print("Started Recording")
# wait a bit for libraries to load
print("Loading libraries...")
print("This may take up to 10 seconds!")
time.sleep(7)
stream = audio.open(format=FORMAT,
channels=CHANNELS,
rate=SAMPLE_RATE,
input=True,
frames_per_buffer=CHUNK)
print("Listening...")
while True:
# keep the last chunk so nothing gets lost
......@@ -97,7 +103,7 @@ while True:
# trigger if voice is detected
if vad_outs >= vad_threshold and not got_voice:
print("I found something")
print("Voice detected! Recording...")
got_voice = True
data = []
data.append(last_chunk)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment