Expand description
AssemblyAI provider implementation for the LLM Kit.
This crate provides a provider implementation for AssemblyAI’s transcription API, supporting speech-to-text functionality with advanced features like speaker diarization, sentiment analysis, and content moderation.
§Examples
§Basic Transcription (Provider-Only)
use llm_kit_assemblyai::AssemblyAIClient;
use llm_kit_provider::transcription_model::call_options::TranscriptionModelCallOptions;
// Create a provider using the client builder
let provider = AssemblyAIClient::new()
.api_key("your-api-key")
.build();
let model = provider.transcription_model("best");
// Download audio from a URL
let audio_url = "https://example.com/audio.mp3";
let audio_data = reqwest::get(audio_url).await?.bytes().await?;
// Create call options with mp3 audio
let call_options = TranscriptionModelCallOptions::mp3(audio_data.to_vec());
// Call do_generate() directly (provider trait method)
let result = model.do_generate(call_options).await?;
println!("Transcription: {}", result.text);§Using Provider Options
use llm_kit_assemblyai::AssemblyAIClient;
use llm_kit_provider::transcription_model::call_options::TranscriptionModelCallOptions;
use llm_kit_provider::shared::provider_options::SharedProviderOptions;
let provider = AssemblyAIClient::new()
.api_key("your-api-key")
.build();
let model = provider.transcription_model("best");
let audio_url = "https://example.com/audio.mp3";
let audio_data = reqwest::get(audio_url).await?.bytes().await?;
// Configure provider options for advanced features
let mut provider_options = SharedProviderOptions::new();
provider_options.insert(
"assemblyai".to_string(),
vec![
("speakerLabels".to_string(), serde_json::json!(true)),
("speakersExpected".to_string(), serde_json::json!(2)),
("sentimentAnalysis".to_string(), serde_json::json!(true)),
("autoChapters".to_string(), serde_json::json!(true)),
]
.into_iter()
.collect(),
);
let call_options = TranscriptionModelCallOptions::mp3(audio_data.to_vec())
.with_provider_options(provider_options);
let result = model.do_generate(call_options).await?;
println!("Transcription: {}", result.text);
println!("Segments: {}", result.segments.len());Re-exports§
pub use client::AssemblyAIClient;pub use error::AssemblyAIError;pub use provider::AssemblyAIProvider;pub use settings::AssemblyAIProviderSettings;pub use transcription::AssemblyAITranscriptionModel;pub use transcription::AssemblyAITranscriptionModelId;pub use transcription::AssemblyAITranscriptionOptions;
Modules§
- client
- Client builder for creating AssemblyAI providers.
- error
- Error types for AssemblyAI provider operations.
- provider
- Provider implementation and creation functions.
- settings
- Settings and configuration for AssemblyAI providers.
- transcription
- Transcription model implementation.
Constants§
- VERSION
- The version of this crate.