diff --git a/audio-knife/src/main.rs b/audio-knife/src/main.rs index 15bf1719..db84c819 100644 --- a/audio-knife/src/main.rs +++ b/audio-knife/src/main.rs @@ -373,7 +373,7 @@ impl SessionState { } }; - let conversation_span = info_span!("", cid = %short_conversation_id); + let conversation_span = info_span!("conversation", cid = %short_conversation_id); // We enter here, so that ContextSwitch picks the span up via `Span::current()`. let entered_conversation_span = conversation_span.enter(); diff --git a/services/azure/src/transcribe.rs b/services/azure/src/transcribe.rs index 1d5104f7..d41d0077 100644 --- a/services/azure/src/transcribe.rs +++ b/services/azure/src/transcribe.rs @@ -3,7 +3,7 @@ use async_stream::stream; use async_trait::async_trait; use futures::StreamExt; use serde::Deserialize; -use tracing::{error, info}; +use tracing::{debug, error, info}; use azure_speech::recognizer::{self, Event}; @@ -128,17 +128,27 @@ impl Service for AzureTranscribe { while let Some(event) = stream.next().await { match event? { - Event::SessionStarted(_) - | Event::SessionEnded(_) - | Event::StartDetected(_, _) - | Event::EndDetected(_, _) => {} + Event::SessionStarted(_) | Event::SessionEnded(_) => {} + // StartDetected and EndDetected seem to be received only once per session. They are + // not usable for turn detection. + Event::StartDetected(request_id, offset) => { + debug!(?request_id, offset, "Start of speech detected (ignored)"); + } + Event::EndDetected(request_id, offset) => { + debug!(?request_id, offset, "End of speech detected (ignored)"); + } Event::Recognizing(_, recognized, _, _, _) => { output_recognized_text(&output, recognized, false, include_detected_language)? } Event::Recognized(_, recognized, _, _, _) => { output_recognized_text(&output, recognized, true, include_detected_language)? } - Event::UnMatch(_, _, _, _) => {} + Event::UnMatch(request_id, offset, duration, raw_message) => { + debug!( + ?request_id, + offset, duration, raw_message, "Speech not recognized (ignored)" + ); + } } } diff --git a/services/deepgram/src/transcribe.rs b/services/deepgram/src/transcribe.rs index 8b047187..c97ac1e7 100644 --- a/services/deepgram/src/transcribe.rs +++ b/services/deepgram/src/transcribe.rs @@ -1,4 +1,4 @@ -use std::io; +use std::{io, result}; use anyhow::{Context, Result, anyhow, bail}; use async_trait::async_trait; @@ -103,7 +103,7 @@ impl Service for DeepgramTranscribe { let deepgram = Deepgram::with_base_url_and_api_key(endpoint.as_str(), params.api_key)?; let (mut input, output) = conversation.start()?; - let (mut audio_tx, audio_rx) = mpsc::channel::>(8); + let (mut audio_tx, audio_rx) = mpsc::channel::>(8); let mut stream = deepgram .transcription()