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::tools::tts::text_to_speech(
29 &text,
30 crate::tools::tts::TtsProvider::Edge,
31 output,
32 )?;
33 println!("✓ Audio saved: {}", path.display());
34 println!(" → Play: ffplay {} -nodisp -autoexit", path.display());
35 }
36 VoiceCommand::Transcribe {
37 audio_file,
38 language,
39 } => {
40 println!("🎤 Transcribing audio...");
41 let text = crate::tools::stt::transcribe(
42 &audio_file,
43 language.as_deref(),
44 crate::tools::stt::SttBackend::OpenAIApi,
45 )?;
46 println!("✓ Transcription:\n\n{text}");
47 }
48 VoiceCommand::ListProviders => {
49 println!("Available TTS providers:");
50 println!(" edge — Microsoft Edge TTS (free, built-in voices)");
51 println!(" openai — OpenAI TTS API (requires API key)");
52 println!(" say — macOS built-in (free)");
53 println!(" espeak — Linux espeak (free, install: apt install espeak)");
54 println!();
55 println!("Available STT providers:");
56 println!(" openai — OpenAI Whisper API (requires API key)");
57 println!(" whisper — Local whisper CLI (install: pip install openai-whisper)");
58 println!(" whisper-cpp — Local whisper.cpp (fast, no Python needed)");
59 }
60 }
61 Ok(())
62}