48 lines
1.1 KiB
Rust
48 lines
1.1 KiB
Rust
use std::path::PathBuf;
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use crate::error::AppResult;
|
|
use crate::models::DEFAULT_MODEL_ID;
|
|
|
|
pub mod crispasr;
|
|
pub mod openai;
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct TranscriptionInput {
|
|
pub audio_path: PathBuf,
|
|
pub options: TranscriptionOptions,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct TranscriptionOptions {
|
|
pub model_id: String,
|
|
pub language: Option<String>,
|
|
pub timestamps: bool,
|
|
}
|
|
|
|
impl Default for TranscriptionOptions {
|
|
fn default() -> Self {
|
|
Self {
|
|
model_id: DEFAULT_MODEL_ID.to_string(),
|
|
language: None,
|
|
timestamps: false,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct TranscriptionResult {
|
|
pub text: String,
|
|
pub backend: String,
|
|
pub model_id: String,
|
|
pub detected_language: Option<String>,
|
|
}
|
|
|
|
pub trait Transcriber {
|
|
fn transcribe(&self, input: TranscriptionInput) -> AppResult<TranscriptionResult>;
|
|
}
|