mirror of
https://github.com/mii443/openai-api-rs.git
synced 2025-08-23 23:49:26 +00:00
* use reqwest
* support multipart form * fix audio apits
This commit is contained in:
20
examples/audio_transcriptions.rs
Normal file
20
examples/audio_transcriptions.rs
Normal file
@ -0,0 +1,20 @@
|
||||
use openai_api_rs::v1::api::OpenAIClient;
|
||||
use openai_api_rs::v1::audio::{AudioTranscriptionRequest, WHISPER_1};
|
||||
use std::env;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let client = OpenAIClient::new(env::var("OPENAI_API_KEY").unwrap().to_string());
|
||||
|
||||
let req = AudioTranscriptionRequest::new(
|
||||
"examples/data/problem.mp3".to_string(),
|
||||
WHISPER_1.to_string(),
|
||||
);
|
||||
|
||||
let result = client.audio_transcription(req).await?;
|
||||
println!("{:?}", result);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// OPENAI_API_KEY=xxxx cargo run --package openai-api-rs --example audio_translations
|
Reference in New Issue
Block a user