whisper/
whisper.rs

1use gradio::{Client, ClientOptions, PredictionInput};
2
3#[tokio::main]
4async fn main() {
5    if std::env::args().len() < 2 {
6        println!("Please provide an audio file path as an argument");
7        std::process::exit(1);
8    }
9    let args: Vec<String> = std::env::args().collect();
10    let file_path = &args[1];
11    println!("File: {}", file_path);
12
13    let client = Client::new("hf-audio/whisper-large-v3", ClientOptions::default())
14        .await
15        .unwrap();
16
17    let output = client
18        .predict(
19            "/predict",
20            vec![
21                PredictionInput::from_file(file_path),
22                PredictionInput::from_value("transcribe"),
23            ],
24        )
25        .await
26        .unwrap();
27    println!(
28        "Output: {}",
29        output[0].clone().as_value().unwrap().as_str().unwrap()
30    );
31}