feat: add transcription backend contracts
This commit is contained in:
1 parent
3b05cb22a0
commit
54e8b42330
9 files changed
+461
No files matched your search
@@ -0,0 +1,47 @@
|
||||
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>;
|
||||
}
|
||||
Reference in new issue
Block a user