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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//! Voice-to-Text Streaming Library
//!
//! This library provides real-time audio transcription capabilities for AI agents
//! and other applications that need situational awareness through speech recognition.
//!
//! # Architecture
//!
//! The library is organized into several key components:
//!
//! - [`TranscriptionService`]: Main service that orchestrates audio capture and transcription
//! - [`Config`]: Configuration for chunk duration, API endpoint, and model selection
//! - [`TranscriptionEvent`]: Events emitted for successful transcriptions and errors
//!
//! Audio is captured from the default input device, chunked into configurable segments,
//! and sent to OpenAI-compatible transcription APIs. Results are delivered via an
//! event-driven async channel.
//!
//! # Examples
//!
//! ## Basic Usage
//!
//! ```no_run
//! use vtt_rs::{TranscriptionService, Config, TranscriptionEvent};
//!
//! #[tokio::main]
//! async fn main() -> anyhow::Result<()> {
//! let config = Config::default();
//! let api_key = std::env::var("OPENAI_API_KEY")?;
//!
//! let mut service = TranscriptionService::new(config, api_key)?;
//!
//! // Start listening and transcribing
//! let (mut receiver, _stream) = service.start().await?;
//!
//! // Process transcription events
//! while let Some(event) = receiver.recv().await {
//! match event {
//! TranscriptionEvent::Transcription { chunk_id, text } => {
//! println!("Heard: {}", text);
//! }
//! TranscriptionEvent::Error { chunk_id, error } => {
//! eprintln!("Error: {}", error);
//! }
//! }
//! }
//!
//! Ok(())
//! }
//! ```
//!
//! ## Custom Configuration
//!
//! ```no_run
//! use vtt_rs::{Config, TranscriptionService};
//! use std::path::PathBuf;
//!
//! # #[tokio::main]
//! # async fn main() -> anyhow::Result<()> {
//! let config = Config {
//! chunk_duration_secs: 3,
//! model: "whisper-1".to_string(),
//! endpoint: "https://api.openai.com/v1/audio/transcriptions".to_string(),
//! out_file: Some(PathBuf::from("transcripts.log")),
//! };
//!
//! let api_key = std::env::var("OPENAI_API_KEY")?;
//! let mut service = TranscriptionService::new(config, api_key)?;
//! # Ok(())
//! # }
//! ```
pub use ;
pub use ;
// Re-export commonly used types
pub use ;