package server import ( "regexp" "strings" ) // kokoroVoices is the built-in fallback list of voices shipped with Kokoro-FastAPI. // Used when the live GET /v1/audio/voices request to Kokoro fails. // Grouped by language prefix: // // af_ / am_ American English female / male // bf_ / bm_ British English female / male // ef_ / em_ Spanish female / male // ff_ French female // hf_ / hm_ Hindi female / male // if_ / im_ Italian female / male // jf_ / jm_ Japanese female / male // pf_ / pm_ Portuguese female / male // zf_ / zm_ Chinese female / male var kokoroVoices = []string{ // American English "af_alloy", "af_aoede", "af_bella", "af_heart", "af_jadzia", "af_jessica", "af_kore", "af_nicole", "af_nova", "af_river", "af_sarah", "af_sky", "am_adam", "am_echo", "am_eric", "am_fenrir", "am_liam", "am_michael", "am_onyx", "am_puck", // British English "bf_alice", "bf_emma", "bf_lily", "bm_daniel", "bm_fable", "bm_george", "bm_lewis", // Spanish "ef_dora", "em_alex", // French "ff_siwis", // Hindi "hf_alpha", "hf_beta", "hm_omega", "hm_psi", // Italian "if_sara", "im_nicola", // Japanese "jf_alpha", "jf_gongitsune", "jf_nezumi", "jf_tebukuro", "jm_kumo", // Portuguese "pf_dora", "pm_alex", // Chinese "zf_xiaobei", "zf_xiaoni", "zf_xiaoxiao", "zf_xiaoyi", "zm_yunjian", "zm_yunxi", "zm_yunxia", "zm_yunyang", } // stripMarkdown removes common markdown syntax from src, returning plain text // suitable for TTS or display. Not a full markdown parser — handles the most // common constructs (headings, bold/italic, code blocks, links, blockquotes). func stripMarkdown(src string) string { src = regexp.MustCompile(`(?m)^#{1,6}\s+`).ReplaceAllString(src, "") src = regexp.MustCompile(`\*{1,3}|_{1,3}`).ReplaceAllString(src, "") src = regexp.MustCompile("(?s)```.*?```").ReplaceAllString(src, "") src = regexp.MustCompile("`[^`]*`").ReplaceAllString(src, "") src = regexp.MustCompile(`\[([^\]]+)\]\([^)]+\)`).ReplaceAllString(src, "$1") src = regexp.MustCompile(`!\[[^\]]*\]\([^)]+\)`).ReplaceAllString(src, "") src = regexp.MustCompile(`(?m)^>\s?`).ReplaceAllString(src, "") src = regexp.MustCompile(`(?m)^[-*_]{3,}\s*$`).ReplaceAllString(src, "") src = regexp.MustCompile(`\n{3,}`).ReplaceAllString(src, "\n\n") return strings.TrimSpace(src) }