Skip to main content

transcribe_cpp_types/
session.rs

1//! [`RunOptions`]: the per-run parameters of `transcribe_cpp::Session::run`,
2//! `run_batch` and `stream`.
3
4use crate::family::RunExtension;
5use crate::types::{Diarize, Itn, Pnc, Task, TimestampKind};
6
7/// Per-run parameters.
8#[derive(Debug, Clone, PartialEq)]
9#[cfg_attr(
10    feature = "serde",
11    derive(serde::Serialize, serde::Deserialize),
12    serde(default)
13)]
14pub struct RunOptions {
15    pub task: Task,
16    pub timestamps: TimestampKind,
17    pub pnc: Pnc,
18    pub itn: Itn,
19    pub diarize: Diarize,
20    /// Source language hint (ISO code), or `None` to autodetect.
21    pub language: Option<String>,
22    /// Target language for translation, or `None`.
23    pub target_language: Option<String>,
24    /// Keep special vocab tags (e.g. `<|...|>`) in the returned text.
25    pub keep_special_tags: bool,
26    /// Speculative-decode draft length. `-1` = family default, `0` = disabled.
27    pub spec_k_drafts: i32,
28    /// Optional family-specific run extension (e.g. whisper decode knobs).
29    pub family: Option<RunExtension>,
30    /// Custom terms in priority order, formatted per family
31    /// (`Feature::Vocabulary`; ignored with a warning elsewhere).
32    pub vocabulary: Vec<String>,
33    /// Context text under `Task::Transcribe`/`Translate`
34    /// (`Feature::ContextPrompt`); the required instruction under
35    /// `Task::Instruct`.
36    pub prompt: Option<String>,
37    /// Transcript text the model continues from (`Feature::TranscriptPrefix`;
38    /// an error elsewhere, and in batch and streaming runs). `text` holds only
39    /// the continuation; `raw_text` leads with the prefix.
40    pub prefix: Option<String>,
41}
42
43impl Default for RunOptions {
44    fn default() -> Self {
45        RunOptions {
46            task: Task::Transcribe,
47            timestamps: TimestampKind::Auto,
48            pnc: Pnc::Default,
49            itn: Itn::Default,
50            diarize: Diarize::Default,
51            language: None,
52            target_language: None,
53            keep_special_tags: false,
54            spec_k_drafts: -1,
55            family: None,
56            vocabulary: Vec::new(),
57            prompt: None,
58            prefix: None,
59        }
60    }
61}