bcae4e5466
Introduce an `AppState` struct to hold shared application state, including configuration and the transcription sender. Modify `create_router` and `create_router_with_state` to use `AppState`. Update `main.rs` to initialize the transcription worker and pass the `AppState` to the router. Implement the transcription worker logic in `server/src/transcribe/worker.rs`, handling job queues, FFmpeg remuxing, and Whisper transcription. Update `server/src/auth.rs` to use `Arc<Config>` from the shared state. Modify `server/src/routes/upload.rs` to enqueue transcription jobs and handle potential errors. Add `TranscribeJob` and channel types in `server/src/transcribe/mod.rs`.
22 lines
431 B
Rust
22 lines
431 B
Rust
use std::path::PathBuf;
|
|
|
|
use tokio::sync::mpsc;
|
|
|
|
pub mod ffmpeg;
|
|
pub mod whisper;
|
|
pub mod worker;
|
|
|
|
pub const QUEUE_DEPTH: usize = 64;
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct TranscribeJob {
|
|
pub audio_path: PathBuf,
|
|
}
|
|
|
|
pub type TranscribeSender = mpsc::Sender<TranscribeJob>;
|
|
pub type TranscribeReceiver = mpsc::Receiver<TranscribeJob>;
|
|
|
|
pub fn channel() -> (TranscribeSender, TranscribeReceiver) {
|
|
mpsc::channel(QUEUE_DEPTH)
|
|
}
|