LiveSpeech SDK for Rust
A Rust SDK for real-time speech-to-speech AI conversations.
Installation
Add to your Cargo.toml:
[]
= "0.1"
= { = "1.35", = ["full"] }
Quick Start
use ;
async
API Reference
Regions
The SDK provides built-in region support, so you don't need to remember endpoint URLs:
| Region | Variant | Location |
|---|---|---|
ap-northeast-2 |
Region::ApNortheast2 |
Asia Pacific (Seoul) |
us-west-2 |
Region::UsWest2 |
US West (Oregon) - Coming soon |
Config
Use the builder pattern to create configuration:
let config = builder
.region // Required
.api_key // Required
.connection_timeout
.auto_reconnect
.max_reconnect_attempts
.reconnect_delay
.debug
.build?;
LiveSpeechClient
Methods
| Method | Description |
|---|---|
connect() |
Connect to the server |
disconnect() |
Disconnect from the server |
start_session(config) |
Start a conversation session |
end_session() |
End the current session |
send_audio(data, format) |
Send audio data to be transcribed |
connection_state() |
Get current connection state |
is_connected() |
Check if connected |
has_active_session() |
Check if session is active |
Event Handlers
// Transcript handler (text, is_final)
client.on_transcript.await;
// Response handler (text, is_final)
client.on_response.await;
// Audio handler (audio bytes)
client.on_audio.await;
// Error handler (ErrorEvent)
client.on_error.await;
SessionConfig
// Simple creation
let config = new;
// Builder pattern for more options
let config = builder
.voice_id
.language_code
.sample_rate
.input_format
.output_format
.metadata
.build;
AudioFormat
Audio Utilities
use ;
// Convert f32 samples to i16 PCM
let pcm = float32_to_int16;
// Create WAV from PCM
let wav = wrap_pcm_in_wav;
// Use AudioEncoder for convenience
let encoder = new;
let base64 = encoder.encode;
let decoded = encoder.decode?;
Events
All events can be received through the event channel:
let mut events = client.events.await;
while let Some = events.recv.await
Error Handling
The SDK uses a custom error type:
use ;
match client.connect.await
License
MIT