Sample code for 30+ languages & platforms
Rust

VoiceBase -- Retrieve Plain Text Transcript

See more VoiceBase Examples

Retrieves a plain text transcript for a media file.

Chilkat Rust Downloads

Rust
// This example assumes the Chilkat HTTP API to have been previously unlocked.
// See Global Unlock Sample for sample code.

// Insert your Bearer token here:
let access_token = "VOICEBASE_TOKEN".to_string();

let http = chilkat::Http::new();

// Add the access (bearer) token to the request, which is a header
// having the following format:
// Authorization: Bearer <userAccessToken>
let sb_auth = chilkat::StringBuilder::new();
let _ = sb_auth.append("Bearer ");
let _ = sb_auth.append(&access_token);
http.set_request_header("Authorization", &sb_auth.get_as_string().unwrap_or_default());

let sb_url = chilkat::StringBuilder::new();
let _ = sb_url.append("https://apis.voicebase.com/v2-beta/media/$MEDIA_ID/transcripts/latest");
let replace_count = sb_url.replace("$MEDIA_ID", "f9b9bb88-d52c-4960-bcef-d516a9f85594");

http.set_accept("text/plain");

let Ok(str_text) = http.quick_get_str(&sb_url.get_as_string().unwrap_or_default()) else {
    println!("{}", http.last_error_text());
    return;
};

println!("Response status code = {}", http.last_status());
println!("{}", str_text);

if http.last_status() != 200 {
    println!("Failed");
} else {
    println!("Success");
}