feat: Forward user settings to Whisper API
Include per-user hotwords and initial prompts in the multipart form data sent to the Whisper API. The language parameter is now dynamically set based on user configuration, defaulting to "de" if not specified.
This commit is contained in:
@@ -5,7 +5,7 @@ use std::time::Duration;
|
||||
use tracing::{error, info, warn};
|
||||
|
||||
use super::{ffmpeg, ollama, whisper, TranscribeReceiver};
|
||||
use crate::config::Config;
|
||||
use crate::config::{Config, WhisperUserSettings};
|
||||
|
||||
const ONELINER_TIMEOUT: Duration = Duration::from_secs(60);
|
||||
|
||||
@@ -23,7 +23,17 @@ pub async fn run(mut rx: TranscribeReceiver, config: Arc<Config>, client: reqwes
|
||||
continue;
|
||||
}
|
||||
|
||||
info!(audio = %audio_path.display(), "Transcribing");
|
||||
// Look up per-user Whisper settings live from the shared config so that
|
||||
// edits to users.toml (on next restart) reach in-flight jobs naturally.
|
||||
// Unknown slug → empty settings (service falls back to language=de).
|
||||
let settings: WhisperUserSettings = config
|
||||
.users
|
||||
.iter()
|
||||
.find(|u| u.slug == job.user_slug)
|
||||
.map(|u| u.whisper.clone())
|
||||
.unwrap_or_default();
|
||||
|
||||
info!(audio = %audio_path.display(), user = %job.user_slug, "Transcribing");
|
||||
|
||||
let remuxed = match ffmpeg::remux_faststart(&audio_path).await {
|
||||
Ok(f) => f,
|
||||
@@ -33,7 +43,7 @@ pub async fn run(mut rx: TranscribeReceiver, config: Arc<Config>, client: reqwes
|
||||
}
|
||||
};
|
||||
|
||||
let text = match whisper::transcribe(&client, &config.whisper_url, remuxed.path(), timeout).await {
|
||||
let text = match whisper::transcribe(&client, &config.whisper_url, remuxed.path(), timeout, &settings).await {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
error!(audio = %audio_path.display(), error = %e, "whisper call failed");
|
||||
|
||||
Reference in New Issue
Block a user