#[cfg(feature = "whisper")]
use voxora_bridge::{AsrEngine, HuggingFaceSource, TranscribeOptions, WhisperEngine};
#[cfg(feature = "whisper")]
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let model_id = std::env::args()
.nth(1)
.ok_or("usage: basic_transcribe <hf-model-id>")?;
let source = HuggingFaceSource::new()?;
let engine = WhisperEngine::from_hf(&source, &model_id, &Default::default()).await?;
let samples = vec![0.0_f32; 16_000];
let opts = TranscribeOptions::new(Some("en".into()), false, false);
let result = engine.transcribe(&samples, &opts)?;
println!("text: {:?}", result.text);
println!("segments: {}", result.segments.len());
if let Some(model_type) = engine.model_type() {
println!("model_type: {model_type}");
}
Ok(())
}
#[cfg(not(feature = "whisper"))]
fn main() {
eprintln!(
"this example requires the `whisper` feature: cargo run --example basic_transcribe -p voxora-bridge --features voxora-bridge/whisper -- <hf-model-id>"
);
std::process::exit(2);
}