@staff0rd/assist 0.86.0 → 0.86.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -261,28 +261,37 @@ class VoiceDaemon:
|
|
|
261
261
|
self._last_partial_at = sample_count
|
|
262
262
|
self._run_partial_stt()
|
|
263
263
|
|
|
264
|
-
|
|
264
|
+
is_end, reset_silence = self._check_segment_end(sample_count, trailing_silence)
|
|
265
|
+
if is_end:
|
|
265
266
|
self._finalize_utterance()
|
|
266
267
|
sample_count = 0
|
|
267
268
|
trailing_silence = 0
|
|
269
|
+
elif reset_silence:
|
|
270
|
+
trailing_silence = 0
|
|
268
271
|
|
|
269
272
|
return sample_count, trailing_silence
|
|
270
273
|
|
|
271
|
-
def _check_segment_end(
|
|
274
|
+
def _check_segment_end(
|
|
275
|
+
self, sample_count: int, trailing_silence: int
|
|
276
|
+
) -> tuple[bool, bool]:
|
|
272
277
|
"""Check if the current segment is done.
|
|
273
278
|
|
|
274
279
|
Follows the reference smart-turn implementation:
|
|
275
280
|
1. Accumulate speech + trailing silence.
|
|
276
281
|
2. After STOP_MS of continuous silence, send the full segment to smart turn.
|
|
277
|
-
3. If smart turn says "Incomplete", keep listening
|
|
278
|
-
4. If smart turn says "Complete", finalize
|
|
282
|
+
3. If smart turn says "Incomplete", keep listening.
|
|
283
|
+
4. If smart turn says "Complete", finalize.
|
|
279
284
|
5. Hard cap at MAX_SPEECH_SECONDS always finalizes.
|
|
285
|
+
|
|
286
|
+
Returns (is_end, reset_silence). When reset_silence is True the caller
|
|
287
|
+
must zero trailing_silence so that another full STOP_MS of silence is
|
|
288
|
+
required before re-checking smart turn.
|
|
280
289
|
"""
|
|
281
290
|
max_samples = MAX_SPEECH_SECONDS * 16000
|
|
282
291
|
|
|
283
292
|
if sample_count >= max_samples:
|
|
284
293
|
log("max_speech", "Reached max speech duration")
|
|
285
|
-
return True
|
|
294
|
+
return True, False
|
|
286
295
|
|
|
287
296
|
if trailing_silence >= STOP_CHUNKS:
|
|
288
297
|
audio_so_far = np.concatenate(self._audio_buffer)
|
|
@@ -291,10 +300,11 @@ class VoiceDaemon:
|
|
|
291
300
|
label = "Complete" if is_complete else "Incomplete"
|
|
292
301
|
print(f"\n Smart turn: {label}", file=sys.stderr)
|
|
293
302
|
if is_complete:
|
|
294
|
-
return True
|
|
303
|
+
return True, False
|
|
295
304
|
else:
|
|
296
305
|
log("smart_turn_incomplete", "Continuing to listen...")
|
|
297
|
-
|
|
306
|
+
return False, True
|
|
307
|
+
return False, False
|
|
298
308
|
|
|
299
309
|
def _dispatch_result(self, text: str) -> None:
|
|
300
310
|
"""Log and optionally submit a recognized command."""
|
package/dist/index.js
CHANGED