1use std::path::PathBuf;
6
7pub enum VoiceCommand {
9 Speak {
11 text: String,
12 output: Option<PathBuf>,
13 },
14 Transcribe {
16 audio_file: PathBuf,
17 language: Option<String>,
18 },
19 ListProviders,
21}
22
23pub fn handle_voice(cmd: VoiceCommand) -> anyhow::Result<()> {
25 match cmd {
26 VoiceCommand::Speak { text, output } => {
27 println!("🔊 Converting text to speech...");
28 let path = crate::tts::text_to_speech(&text, crate::tts::TtsProvider::Edge, output)?;
29 println!("✓ Audio saved: {}", path.display());
30 println!(" → Play: ffplay {} -nodisp -autoexit", path.display());
31 }
32 VoiceCommand::Transcribe {
33 audio_file,
34 language,
35 } => {
36 println!("🎤 Transcribing audio...");
37 let text = crate::stt::transcribe(
38 &audio_file,
39 language.as_deref(),
40 crate::stt::SttBackend::OpenAIApi,
41 )?;
42 println!("✓ Transcription:\n\n{text}");
43 }
44 VoiceCommand::ListProviders => {
45 println!("Available TTS providers:");
46 println!(" edge — Microsoft Edge TTS (free, built-in voices)");
47 println!(" openai — OpenAI TTS API (requires API key)");
48 println!(" say — macOS built-in (free)");
49 println!(" espeak — Linux espeak (free, install: apt install espeak)");
50 println!();
51 println!("Available STT providers:");
52 println!(" openai — OpenAI Whisper API (requires API key)");
53 println!(" whisper — Local whisper CLI (install: pip install openai-whisper)");
54 println!(" whisper-cpp — Local whisper.cpp (fast, no Python needed)");
55 }
56 }
57 Ok(())
58}