diff --git a/Cargo.toml b/Cargo.toml index ed80251..ad9642d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ members = [ ] [workspace.package] -version = "3.3.2" +version = "3.4.0" edition = "2024" license = "MIT" repository = "https://github.com/pragmatrix/context-switch" diff --git a/examples/transcribe.rs b/examples/transcribe.rs index 2ca2e36..8b6c63f 100644 --- a/examples/transcribe.rs +++ b/examples/transcribe.rs @@ -39,6 +39,8 @@ struct Args { #[arg(long)] diarization: bool, #[arg(long)] + numerals: bool, + #[arg(long)] turn_threshold: Option, #[arg(long, value_enum)] turn_threshold_level: Option, @@ -87,6 +89,7 @@ struct ProviderArgs<'a> { transcription_model: Option<&'a str>, region: Option<&'a str>, diarization: bool, + numerals: bool, turn_detection: Option, } @@ -107,6 +110,7 @@ async fn main() -> Result<()> { transcription_model: args.transcription_model.as_deref(), region: args.region.as_deref(), diarization: args.diarization, + numerals: args.numerals, turn_detection: if args.turn_threshold.is_some() || args.turn_threshold_level.is_some() || args.turn_timeout_ms.is_some() @@ -268,6 +272,7 @@ async fn start_conversation( provider_args.transcription_model, provider_args.region, provider_args.diarization, + provider_args.numerals, provider_args.turn_detection.is_some(), )?; @@ -405,6 +410,7 @@ async fn start_conversation( endpoint: env::var("DEEPGRAM_ENDPOINT").expect("DEEPGRAM_ENDPOINT undefined"), language: languages.join_csv(), profanity_filter: false, + numerals: provider_args.numerals, keyterm: vec![], turn_detection: provider_args.turn_detection.clone(), }; @@ -418,6 +424,7 @@ async fn start_conversation( struct ProviderCapabilities { region: bool, diarization: bool, + numerals: bool, model: bool, transcription_model: bool, turn_detection: bool, @@ -433,6 +440,7 @@ impl Provider { capabilities.model = true; } Provider::Deepgram => { + capabilities.numerals = true; capabilities.turn_detection = true; } Provider::Elevenlabs => { @@ -482,6 +490,7 @@ fn validate_provider_args( transcription_model: Option<&str>, region: Option<&str>, diarization: bool, + numerals: bool, turn_detection: bool, ) -> Result<()> { let capabilities = provider.capabilities(); @@ -500,6 +509,7 @@ fn validate_provider_args( capabilities.diarization, provider, )?; + validate_capability("--numerals", numerals, capabilities.numerals, provider)?; validate_capability( "--turn-threshold/--turn-threshold-level/--turn-timeout-ms/--turn-eager-threshold", turn_detection, diff --git a/services/deepgram/src/transcribe.rs b/services/deepgram/src/transcribe.rs index c97ac1e..918ad11 100644 --- a/services/deepgram/src/transcribe.rs +++ b/services/deepgram/src/transcribe.rs @@ -28,6 +28,9 @@ pub struct Params { /// Replace detected profanity with asterisks in the transcript. #[serde(default)] pub profanity_filter: bool, + /// Format recognized numbers as numerals in the transcript. + #[serde(default)] + pub numerals: bool, /// Key terms to boost recognition accuracy for domain-specific vocabulary. #[serde(default)] pub keyterm: Vec, @@ -79,6 +82,9 @@ impl Service for DeepgramTranscribe { if params.profanity_filter { options_builder = options_builder.profanity_filter(true); } + if params.numerals { + options_builder = options_builder.numerals(true); + } let options_builder = if let Some(language_hints) = language_hints { options_builder.language_hint(language_hints)