forked from 0xPlaygrounds/rig
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtranscription.rs
More file actions
33 lines (24 loc) · 774 Bytes
/
transcription.rs
File metadata and controls
33 lines (24 loc) · 774 Bytes
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
use std::env::args;
use rig::{providers::openai, transcription::TranscriptionModel};
#[tokio::main]
async fn main() {
// Load the path from the first command line argument
let args = args().collect::<Vec<_>>();
if args.len() <= 1 {
println!("No file was specified!");
return;
}
let file_path = args[1].clone();
// Create an OAI client
let openai = openai::Client::from_env();
// Create the whisper transcription model
let whisper = openai.transcription_model(openai::WHISPER_1);
let response = whisper
.transcription_request()
.load_file(&file_path)
.send()
.await
.expect("Failed to transcribe file");
let text = response.text;
println!("Whisper-1: {text}")
}