File tree 1 file changed +9
-5
lines changed
1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 1
1
"""Live captions from microphone using Moonshine and SileroVAD ONNX models."""
2
2
3
+ import argparse
3
4
import os
4
5
import sys
5
6
import time
6
- import argparse
7
7
8
8
from queue import Queue
9
9
@@ -67,7 +67,7 @@ def create_input_callback(q):
67
67
def input_callback (data , frames , time , status ):
68
68
if status :
69
69
print (status )
70
- q .put ((data .copy (), status ))
70
+ q .put ((data .copy (). flatten () , status ))
71
71
72
72
return input_callback
73
73
@@ -144,12 +144,10 @@ def print_captions(text, new_cached_caption=False):
144
144
print_captions ("Ready..." )
145
145
try :
146
146
while True :
147
- data , status = q .get ()
147
+ chunk , status = q .get ()
148
148
if VERBOSE and status :
149
149
print (status )
150
150
151
- chunk = np .array (data ).flatten ()
152
-
153
151
speech = np .concatenate ((speech , chunk ))
154
152
if not recording :
155
153
speech = speech [- lookback_size :]
@@ -182,6 +180,12 @@ def print_captions(text, new_cached_caption=False):
182
180
except KeyboardInterrupt :
183
181
stream .close ()
184
182
183
+ if recording :
184
+ while not q .empty ():
185
+ chunk , _ = q .get ()
186
+ speech = np .concatenate ((speech , chunk ))
187
+ end_recording (speech , "<END.>" )
188
+
185
189
print (f"""
186
190
187
191
model_name : { model_name }
You can’t perform that action at this time.
0 commit comments