Proxy that converts LaTex notation into spoken language #477
Replies: 2 comments
|
this is so useful. i regularly convert books to excellent audiobooks using abogen and some of them have latex math which kokoro awfully reads like literal text. thanks for this. i'll try it out in my next conversion that has math. as a suggestion, setups are often different like with my case. i'd suggest making tts-latex-proxy into a generic text processor that works on text from stdin and outputs the translated output to stdout. this would make it usable in almost any scenario. you can keep the server functionality behind a script flag. |
|
@HanFarJR @w0nd3r365 This is a great addition idea. I took a possible first crack at it as native normalization below. https://github.com/remsky/Kokoro-FastAPI/tree/feat/latex-normalization |
Uh oh!
There was an error while loading. Please reload this page.
Why I made it
Kokoro-FastAPI has a specific gap in their utility. They read LaTeX markup character by character rather than converting it to spoken language. When encountering math notation, the TTS engine will hear "dollar sign backslash frac open brace…" instead of "x squared plus one over two". My tts-latex-proxy solves this problem.
Kokoro-FastAPI and other TTS-engines are rendered useless for scientific notation without a preprocessing layer that converts said notation to spoken English like so:
What it does
The proxy intercepts
/v1/audio/speechrequests, processes the input text, then forwards the cleaned version to your TTS backend. All other API calls (models, health checks) pass through transparently.Before / After
$\frac{a}{b}$$E = mc^2$$\int_0^1 f(x) dx$$\alpha + \beta$$\sqrt{x^2 + y^2}$$\sum_{i=1}^{n} x_i$$P(A \cup B)$Markdown formatting (
**bold**,# Headers,[links](url), bullet lists, tables) is stripped silently.All reactions