Skip to main content

SessionOptions

Struct SessionOptions 

Source
pub struct SessionOptions { /* private fields */ }
Expand description

会话选项构造器:拼出 crate::Model::create_task_session 的 session_options 参数要的 JSON 字符串。

JSON 形如 {"session_len_sec":100.0,"graph_capacity_mode":"grow"}; 空选项序列化为 {}。未知键用 SessionOptions::option 自由扩展 (shim 对未知键同样静默忽略,键名请核对 session 常量)。

§示例

use audio_cpp::{Backend, Registry, RunMode, TaskKind, options::SessionOptions};

let registry = Registry::new()?;
let model = registry.load("./sortformer-diar-4spk-q8_0.gguf", None, None)?;
let opts = SessionOptions::new()
    .session_len_sec(100.0)
    .graph_capacity_mode(audio_cpp::options::session::graph_capacity::GROW);
let opts_json = opts.to_json();
let session = model.create_task_session(
    TaskKind::Diar, RunMode::Offline, Backend::Cpu, 0, 4, Some(&opts_json),
)?;

Implementations§

Source§

impl SessionOptions

Source

pub fn new() -> Self

空选项。

Source

pub fn option(self, key: impl Into<String>, value: impl ToString) -> Self

设置一个选项键值(值为任意可转字符串类型)。

Source

pub fn session_len_sec(self, seconds: f64) -> Self

会话图长度(秒),见 session::SESSION_LEN_SEC。

Source

pub fn graph_capacity_mode(self, mode: impl Into<String>) -> Self

会话图容量模式(取值见 session::graph_capacity),见 session::GRAPH_CAPACITY_MODE。

Source

pub fn qwen3_aligner_model_path(self, path: impl Into<String>) -> Self

Qwen3 ASR 词戳回填的对齐模型路径,见 session::QWEN3_ASR_FORCED_ALIGNER_MODEL_PATH。

Source

pub fn to_json(&self) -> String

序列化为 JSON 字符串(传给 create_task_session)。

数值型值(SessionOptions::session_len_sec 写入的)按 JSON 数字 还原,其余按字符串;空选项为 {}。

Trait Implementations§

Source§

impl Clone for SessionOptions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SessionOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SessionOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.