pub mod openai_stt;
pub mod openai_tts;
pub mod voicebox_stt;
pub mod voicebox_tts;
#[cfg(feature = "local-stt")]
pub mod local_whisper;
#[cfg(feature = "local-tts")]
pub mod local_tts;
mod service;
pub use service::{synthesize, synthesize_speech, transcribe, transcribe_audio};
#[cfg(feature = "local-stt")]
pub use service::{preload_local_whisper, transcribe_audio_local};
pub fn local_stt_available() -> bool {
if !cfg!(feature = "local-stt") {
return false;
}
#[cfg(target_arch = "x86_64")]
{
std::is_x86_feature_detected!("avx2")
}
#[cfg(not(target_arch = "x86_64"))]
{
true }
}
pub fn local_tts_available() -> bool {
#[cfg(feature = "local-tts")]
{
static AVAILABLE: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
*AVAILABLE.get_or_init(|| {
let python_ok = std::process::Command::new("python3")
.arg("--version")
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null())
.status()
.map(|s| s.success())
.unwrap_or(false);
if !python_ok {
return false;
}
std::process::Command::new("python3")
.args(["-c", "import venv"])
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null())
.status()
.map(|s| s.success())
.unwrap_or(false)
})
}
#[cfg(not(feature = "local-tts"))]
{
false
}
}