app
Adom TTS — Text to Speech
Public Made by Adomby adom
Adom's shared voice service. Reads your AI's answers back to you while you drive, and renders perfectly-timed voiceover tracks for your demo videos — so you never record your own voice.
//! Bake the production service-tts URL into the binary at compile time.
//!
//! Precedence:
//! 1. $SERVICE_TTS_URL (set by wiki-publish / release CI)
//! 2. `url` field scraped from ../service-tts/service.json (dev)
//! 3. Local dev fallback http://127.0.0.1:8783
use std::{fs, path::PathBuf};
fn main() {
println!("cargo:rerun-if-env-changed=SERVICE_TTS_URL");
println!("cargo:rerun-if-changed=../service-tts/service.json");
let url = std::env::var("SERVICE_TTS_URL")
.or_else(|_| read_url_from_service_json())
.unwrap_or_else(|_| "http://127.0.0.1:8783".to_string());
println!("cargo:rustc-env=SERVICE_TTS_URL={}", url);
}
fn read_url_from_service_json() -> Result<String, std::io::Error> {
let manifest = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let svc_json = manifest.parent()
.map(|p| p.join("service-tts").join("service.json"))
.ok_or_else(|| std::io::Error::new(std::io::ErrorKind::NotFound, "sibling"))?;
let svc_json = svc_json.canonicalize()?;
let contents = fs::read_to_string(&svc_json)?;
for line in contents.lines() {
if let Some(rest) = line.split_once("\"url\"") {
if let Some(v) = rest.1.split('"').nth(1) {
return Ok(v.to_string());
}
}
}
Err(std::io::Error::new(std::io::ErrorKind::NotFound, "no url in service.json"))
}