Skip to content

Commit 1e28fc5

Browse files
committed
el: Make model optional
1 parent 69876ae commit 1e28fc5

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

services/elevenlabs/src/transcribe.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ use context_switch_core::{
2626
const DEFAULT_REALTIME_HOST: &str = "wss://api.elevenlabs.io/v1/speech-to-text/realtime";
2727
const API_KEY_HEADER: &str = "xi-api-key";
2828
const WRITER_SHUTDOWN_GRACE_PERIOD: Duration = Duration::from_secs(2);
29+
const DEFAULT_MODEL: &str = "scribe_v2_realtime";
2930
const DEFAULT_INCLUDE_LANGUAGE_DETECTION: bool = false;
3031

3132
#[derive(Debug, Deserialize)]
3233
#[serde(rename_all = "camelCase")]
3334
pub struct Params {
3435
/// ElevenLabs API key for the `xi-api-key` websocket header.
3536
pub api_key: String,
36-
/// Realtime model. Default: `scribe_v2_realtime`.
37-
#[serde(default = "default_model")]
38-
pub model: String,
37+
/// Optional realtime model. Defaults to `scribe_v2_realtime` when omitted.
38+
pub model: Option<String>,
3939
/// Optional websocket endpoint override.
4040
pub host: Option<String>,
4141
/// Optional language hint (ISO 639-1 or ISO 639-3).
@@ -55,10 +55,6 @@ pub struct Params {
5555
pub previous_text: Option<String>,
5656
}
5757

58-
fn default_model() -> String {
59-
"scribe_v2_realtime".to_owned()
60-
}
61-
6258
#[derive(Debug, Clone, Copy, Deserialize)]
6359
#[serde(rename_all = "snake_case")]
6460
pub enum AudioEncoding {
@@ -249,7 +245,7 @@ fn build_endpoint(params: &Params, audio_encoding: AudioEncoding) -> Result<Url>
249245

250246
{
251247
let mut q = url.query_pairs_mut();
252-
q.append_pair("model_id", &params.model);
248+
q.append_pair("model_id", params.model.as_deref().unwrap_or(DEFAULT_MODEL));
253249
// Defaulting to false enables automatic translation to the requested language.
254250
let include_language_detection = params
255251
.include_language_detection

0 commit comments

Comments
 (0)