Skip to content

Fix #599: live mode STT restored — ORT path, async deadlock, diagnostic logging - #601

Merged
joelteply merged 1 commit into
mainfrom
fix/vad-init-logging
Mar 30, 2026
Merged

joelteply merged 1 commit into
mainfrom
fix/vad-init-logging

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Problem

Live mode subtitles completely broken. No speech-to-text from human mic.

Root Causes (3 layers)

  1. ORT_DYLIB_PATH not set — ONNX Runtime installed via Homebrew but Rust binary couldn't find it. Set in start-workers.sh.
  2. ORT deadlocked in async context — ort::Session::builder() uses internal std::sync::Mutex that deadlocks when called from tokio async task. Fixed with spawn_blocking.
  3. Whisper killed by orphan watchdog — 60s timeout assumed stable session count = orphaned. Live calls have 15 stable sessions. Timeout → 600s (PR Fix #599: STT killed mid-call — orphan watchdog timeout too aggressive #600).

Evidence

Before: VAD init task panicked with message "Mutex poisoned"
After: Subtitles appear when speaking in live mode.

Test

  • cargo build --release passes
  • Subtitles appear in live mode (verified by user)

…diagnostic logging

Three fixes to restore live mode speech-to-text:
1. Set ORT_DYLIB_PATH in start-workers.sh (ONNX Runtime wasn't found)
2. Use spawn_blocking for VAD init (ORT deadlocked in async context)
3. Added diagnostic logging throughout listen_and_transcribe pipeline
4. Orphan watchdog timeout 60s → 600s (PR #600, already merged)
Copilot AI review requested due to automatic review settings March 30, 2026 04:19
@joelteply
joelteply merged commit 9d85876 into main Mar 30, 2026
4 of 6 checks passed
@joelteply
joelteply deleted the fix/vad-init-logging branch March 30, 2026 04:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restores live-mode STT/subtitles by ensuring ONNX Runtime can be located at runtime and by avoiding an ORT deadlock when initializing Silero VAD inside async tasks.

Changes:

  • Export ORT_DYLIB_PATH in start-workers.sh for Homebrew-installed ONNX Runtime.
  • Initialize ProductionVAD via tokio::task::spawn_blocking to avoid ORT deadlock in async context.
  • Add additional diagnostic logging around STT/VAD startup and initialization.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/workers/start-workers.sh Sets ORT_DYLIB_PATH to help the Rust workers dynamically load ONNX Runtime for Silero VAD.
src/workers/continuum-core/src/live/transport/livekit_agent.rs Adds STT lifecycle logs and moves VAD initialization to spawn_blocking to avoid async deadlock.
src/workers/continuum-core/src/live/audio/vad/production.rs Adds initialization progress logs for the two-stage VAD pipeline.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +191 to +195
# The ort crate with load-dynamic feature needs to find libonnxruntime.dylib
if [ -f "/opt/homebrew/lib/libonnxruntime.dylib" ]; then
export ORT_DYLIB_PATH="/opt/homebrew/lib/libonnxruntime.dylib"
elif [ -f "/usr/local/lib/libonnxruntime.so" ]; then
export ORT_DYLIB_PATH="/usr/local/lib/libonnxruntime.so"

Copilot AI Mar 30, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

start-workers.sh sets ORT_DYLIB_PATH based only on Homebrew/mac paths and will overwrite any user-provided ORT_DYLIB_PATH. This misses the repo’s standard user-space install location (~/.continuum/lib/libonnxruntime.so) used by install.sh/parallel-start.sh and can break VAD when start-workers.sh is run directly. Consider: only setting ORT_DYLIB_PATH if it’s unset, and checking $HOME/.continuum/lib first (then Homebrew paths).

Suggested change
# The ort crate with load-dynamic feature needs to find libonnxruntime.dylib
if [ -f "/opt/homebrew/lib/libonnxruntime.dylib" ]; then
export ORT_DYLIB_PATH="/opt/homebrew/lib/libonnxruntime.dylib"
elif [ -f "/usr/local/lib/libonnxruntime.so" ]; then
export ORT_DYLIB_PATH="/usr/local/lib/libonnxruntime.so"
# The ort crate with load-dynamic feature needs to find the ONNX Runtime shared library.
# Respect any user-provided ORT_DYLIB_PATH; otherwise, try common install locations.
if [ -z "${ORT_DYLIB_PATH:-}" ]; then
# Prefer the repo's standard user-space install location
if [ -f "$HOME/.continuum/lib/libonnxruntime.so" ]; then
export ORT_DYLIB_PATH="$HOME/.continuum/lib/libonnxruntime.so"
elif [ -f "/opt/homebrew/lib/libonnxruntime.dylib" ]; then
export ORT_DYLIB_PATH="/opt/homebrew/lib/libonnxruntime.dylib"
elif [ -f "/usr/local/lib/libonnxruntime.so" ]; then
export ORT_DYLIB_PATH="/usr/local/lib/libonnxruntime.so"
fi

Copilot uses AI. Check for mistakes.
# Set ORT_DYLIB_PATH for ONNX Runtime (needed by Silero VAD in live mode)
# The ort crate with load-dynamic feature needs to find libonnxruntime.dylib
if [ -f "/opt/homebrew/lib/libonnxruntime.dylib" ]; then
export ORT_DYLIB_PATH="/opt/homebrew/lib/libonnxruntime.dylib"

Copilot AI Mar 30, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On macOS Intel/Homebrew the library is typically /usr/local/lib/libonnxruntime.dylib, but this script only checks /usr/local/lib/libonnxruntime.so. Add a .dylib check (and keep .so for Linux) so ORT_DYLIB_PATH is set correctly on Intel Macs.

Suggested change
export ORT_DYLIB_PATH="/opt/homebrew/lib/libonnxruntime.dylib"
export ORT_DYLIB_PATH="/opt/homebrew/lib/libonnxruntime.dylib"
elif [ -f "/usr/local/lib/libonnxruntime.dylib" ]; then
export ORT_DYLIB_PATH="/usr/local/lib/libonnxruntime.dylib"

Copilot uses AI. Check for mistakes.
return;
}
Err(e) => {
clog_error!("🎤 STT: VAD init task panicked for '{}': {}", speaker_name, e);

Copilot AI Mar 30, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tokio::task::JoinError isn’t always a panic (it can also indicate task cancellation). The log message says "panicked" unconditionally, which can mislead debugging. Consider branching on e.is_panic()/e.is_cancelled() (or wording like "VAD init task failed/join error") and logging the appropriate reason.

Suggested change
clog_error!("🎤 STT: VAD init task panicked for '{}': {}", speaker_name, e);
if e.is_panic() {
clog_error!("🎤 STT: VAD init task panicked for '{}': {}", speaker_name, e);
} else if e.is_cancelled() {
clog_error!("🎤 STT: VAD init task was cancelled for '{}' (join error): {}", speaker_name, e);
} else {
clog_error!("🎤 STT: VAD init task failed for '{}' (join error): {}", speaker_name, e);
}

Copilot uses AI. Check for mistakes.
tbuf,
)
.await;
clog_warn!("🎤 STT: listen_and_transcribe exited for '{}'", sname);

Copilot AI Mar 30, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

listen_and_transcribe() ending is likely a normal lifecycle event (participant disconnect / track ended), but it’s logged at warn level. Consider using info/debug (or include an error condition) to avoid warning spam during normal calls.

Suggested change
clog_warn!("🎤 STT: listen_and_transcribe exited for '{}'", sname);
clog_info!("🎤 STT: listen_and_transcribe exited for '{}'", sname);

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants