summaryrefslogtreecommitdiff
path: root/makima/src/bin/server.rs
blob: 1964caec1e24a695afa6d929115d470307896daf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//! Makima Audio API Server binary.
//!
//! This server provides WebSocket-based speech-to-text streaming.

use std::sync::Arc;

use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};

use makima::server::{run_server, state::AppState};

/// Default model paths relative to the working directory.
const PARAKEET_MODEL_DIR: &str = "models/parakeet-tdt-0.6b-v3";
const SORTFORMER_MODEL_PATH: &str = "models/diarization/diar_streaming_sortformer_4spk-v2.onnx";

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Initialize tracing subscriber with environment filter
    tracing_subscriber::registry()
        .with(
            tracing_subscriber::EnvFilter::try_from_default_env()
                .unwrap_or_else(|_| "makima=debug,tower_http=debug".into()),
        )
        .with(tracing_subscriber::fmt::layer())
        .init();

    tracing::info!("Starting Makima Listening API Server");
    tracing::info!("Loading ML models...");

    // Load ML models
    let state = Arc::new(
        AppState::new(PARAKEET_MODEL_DIR, SORTFORMER_MODEL_PATH)
            .map_err(|e| anyhow::anyhow!("Failed to load models: {}", e))?,
    );

    tracing::info!("Models loaded successfully");

    // Run the server
    run_server(state, "0.0.0.0:8080").await
}