fix: log teamsbot audio capture diagnostics in gateway
Read and log per-chunk capture diagnostics (trackId, readyState, rms, nativeSampleRate) from bot audioChunk messages to support root-cause analysis of silent audio streams. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
312163d34a
commit
ea8cffee3c
1 changed files with 13 additions and 0 deletions
|
|
@ -302,11 +302,13 @@ class TeamsbotService:
|
|||
audioData = message.get("audio", {})
|
||||
audioBase64 = audioData.get("data", "")
|
||||
sampleRate = audioData.get("sampleRate", 16000)
|
||||
captureDiagnostics = audioData.get("captureDiagnostics") or {}
|
||||
if audioBase64:
|
||||
await self._processAudioChunk(
|
||||
sessionId=sessionId,
|
||||
audioBase64=audioBase64,
|
||||
sampleRate=sampleRate,
|
||||
captureDiagnostics=captureDiagnostics,
|
||||
interface=interface,
|
||||
voiceInterface=voiceInterface,
|
||||
websocket=websocket,
|
||||
|
|
@ -390,6 +392,7 @@ class TeamsbotService:
|
|||
sessionId: str,
|
||||
audioBase64: str,
|
||||
sampleRate: int,
|
||||
captureDiagnostics: Optional[Dict[str, Any]],
|
||||
interface,
|
||||
voiceInterface,
|
||||
websocket: WebSocket,
|
||||
|
|
@ -401,6 +404,16 @@ class TeamsbotService:
|
|||
if len(audioBytes) < 1000:
|
||||
return
|
||||
|
||||
if captureDiagnostics:
|
||||
trackId = captureDiagnostics.get("trackId")
|
||||
readyState = captureDiagnostics.get("readyState")
|
||||
rms = captureDiagnostics.get("rms")
|
||||
nativeSampleRate = captureDiagnostics.get("nativeSampleRate")
|
||||
logger.debug(
|
||||
f"[AudioChunk] diagnostics: track={trackId}, readyState={readyState}, "
|
||||
f"rms={rms}, nativeRate={nativeSampleRate}, bytes={len(audioBytes)}"
|
||||
)
|
||||
|
||||
# Detect silent/all-zeros audio early to avoid expensive STT calls
|
||||
if len(set(audioBytes[100:min(500, len(audioBytes))])) < 3:
|
||||
logger.debug(f"[AudioChunk] Skipping silent audio ({len(audioBytes)} bytes, low byte variation)")
|
||||
|
|
|
|||
Loading…
Reference in a new issue