Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ serde = { version = "1", features = ["derive"] }
serde_json = "1"
tempfile = "3"
rodio = "0.20"
hound = "3"
qwen3-tts = { git = "https://github.com/TrevorS/qwen3-tts-rs", features = ["hub"], default-features = false }
ratatui = "0.29"
crossterm = "0.28"
Expand Down
23 changes: 19 additions & 4 deletions src/backend/kokoro.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//! Kokoro TTS backend — pure Rust ONNX inference via Python kokoro-onnx bridge.
//! Kokoro TTS backend — ONNX model via Python kokoro-onnx bridge.
//!
//! Cross-platform, no GPU required. Model files (~80MB) downloaded separately.
//! 82M param model, cross-platform. Model files (~80MB) downloaded separately.
//! Note: uses Python subprocess for now. Pure Rust port tracked as future work.

use std::process::Command;

use anyhow::{Context, Result};

use super::{SpeakOptions, TtsBackend};
use crate::audio;
use crate::config;

const MODEL_FILE: &str = "kokoro-v1.0.onnx";
Expand Down Expand Up @@ -122,7 +122,22 @@ sf.write("{out}", samples, sr)
anyhow::bail!("Kokoro TTS failed: {stderr}");
}

audio::play_wav_blocking(&wav_path)?;
// Use afplay on macOS (more reliable), rodio on other platforms
#[cfg(target_os = "macos")]
{
let status = Command::new("afplay")
.arg(&wav_path)
.status()
.context("failed to play audio")?;
if !status.success() {
anyhow::bail!("afplay failed");
}
}
#[cfg(not(target_os = "macos"))]
{
crate::audio::play_wav_blocking(&wav_path)?;
}

let _ = std::fs::remove_file(&wav_path);
Ok(())
}
Expand Down
Loading