autoagents-speech 0.3.7

Speech (TTS/STT) provider abstractions for AutoAgents
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use super::error::{VadError, VadResult};
use ort::session::{Session, builder::GraphOptimizationLevel};
use std::path::Path;

pub fn create_session(path: &Path) -> VadResult<Session> {
    let session = Session::builder()
        .map_err(|err| VadError::ModelLoad(err.to_string()))?
        .with_optimization_level(GraphOptimizationLevel::Level3)
        .map_err(|err| VadError::ModelLoad(err.to_string()))?
        .with_intra_threads(1)
        .map_err(|err| VadError::ModelLoad(err.to_string()))?
        .with_inter_threads(1)
        .map_err(|err| VadError::ModelLoad(err.to_string()))?
        .commit_from_file(path)
        .map_err(|err| VadError::ModelLoad(err.to_string()))?;
    Ok(session)
}