pub struct SessionOptions { /* private fields */ }Expand description
会话选项构造器:拼出 crate::Model::create_task_session 的
session_options 参数要的 JSON 字符串。
JSON 形如 {"options":{"session_len_sec":100.0,"graph_capacity_mode":"grow"}}
(嵌套形状,与 crate::Request::to_json 同款——shim 只读嵌套 "options"
对象,扁平键会被静默丢弃,见 audio-cpp-sys/capi.cpp);
空选项序列化为 {}。未知键用 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
impl SessionOptions
Sourcepub fn option(self, key: impl Into<String>, value: impl ToString) -> Self
pub fn option(self, key: impl Into<String>, value: impl ToString) -> Self
设置一个选项键值(值为任意可转字符串类型)。
Sourcepub fn session_len_sec(self, seconds: f64) -> Self
pub fn session_len_sec(self, seconds: f64) -> Self
会话图长度(秒),见 session::SESSION_LEN_SEC。
Sourcepub fn graph_capacity_mode(self, mode: impl Into<String>) -> Self
pub fn graph_capacity_mode(self, mode: impl Into<String>) -> Self
会话图容量模式(取值见 session::graph_capacity),见
session::GRAPH_CAPACITY_MODE。
Sourcepub fn qwen3_aligner_model_path(self, path: impl Into<String>) -> Self
pub fn qwen3_aligner_model_path(self, path: impl Into<String>) -> Self
Qwen3 ASR 词戳回填的对齐模型路径,见
session::QWEN3_ASR_FORCED_ALIGNER_MODEL_PATH。
Sourcepub fn to_json(&self) -> String
pub fn to_json(&self) -> String
序列化为 JSON 字符串(传给 create_task_session)。
嵌套在 "options" 键下(shim 约定,同 Request 形状);
数值型值(SessionOptions::session_len_sec 写入的)按 JSON 数字
还原,其余按字符串;空选项为 {}。
Trait Implementations§
Source§impl Clone for SessionOptions
impl Clone for SessionOptions
Source§impl Debug for SessionOptions
impl Debug for SessionOptions
Auto Trait Implementations§
impl Freeze for SessionOptions
impl RefUnwindSafe for SessionOptions
impl Send for SessionOptions
impl Sync for SessionOptions
impl Unpin for SessionOptions
impl UnsafeUnpin for SessionOptions
impl UnwindSafe for SessionOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more