use clap::{Parser, Subcommand};
mod espeak;
mod interactive;
mod kokoro;
mod playback;
mod test;
#[derive(Parser)]
#[command(name = "ronnex")]
#[command(about = "ONNX Runtime Rust example application", long_about = None)]
struct Cli {
#[command(subcommand)]
command: Option<Commands>,
}
#[derive(Subcommand)]
enum Commands {
Test {
#[arg(value_enum)]
name: TestName,
#[arg(short, long)]
text: Option<String>,
#[arg(long)]
no_play: bool,
},
}
#[derive(clap::ValueEnum, Clone)]
enum TestName {
Identity,
Kokoro,
AnalyzeIpa,
KokoroChat,
Espeak,
EspeakTokenizer,
DirectPhonemes,
RawTokens,
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let cli = Cli::parse();
match cli.command {
Some(Commands::Test {
name,
text,
no_play,
}) => match name {
TestName::Identity => {
test::identity_test::run_identity()?;
}
TestName::Kokoro => {
if let Some(custom_text) = text {
test::kokoro_test::run_kokoro_with_text(&custom_text, no_play)?;
} else {
test::kokoro_test::run_kokoro(no_play)?;
}
}
TestName::AnalyzeIpa => {
test::analyze_ipa::analyze_ipa_in_kokoro()?;
}
TestName::KokoroChat => {
interactive::run_interactive()?;
}
TestName::Espeak => {
test::test_espeak::test_espeak()?;
}
TestName::EspeakTokenizer => {
test::test_espeak_tokenizer::test_espeak_tokenizer()?;
}
TestName::DirectPhonemes => {
test::test_direct_phonemes::test_direct_phonemes()?;
}
TestName::RawTokens => {
test::test_raw_tokens::test_raw_tokens()?;
}
},
None => {
println!("No command specified. Use --help for usage information.");
}
}
Ok(())
}