# styayur/ipa-first-tts architecture

> Architecture diagram of the GitHub repository styayur/ipa-first-tts, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/styayur/ipa-first-tts
- Repository: https://github.com/styayur/ipa-first-tts

## Overview

IPA-first TTS application: users generate English IPA from text, edit and validate that IPA, synthesize the edited sequence with Kokoro or the eSpeak fallback, then play or save WAV audio and view estimated phone timing. The graph includes the documented CLI and browser entry points, shared engine, IPA/TTS contracts, and both synthesis routes. Source excerpts show core parsing, adapters, inference, audio, and alignment; some server dispatch details are documented in the README rather than visible in the excerpt.

Main entry points: [`apps/desktop/src/lib.rs`](https://github.com/styayur/ipa-first-tts/blob/main/apps/desktop/src/lib.rs) (Application Engine), [`crates/ipa-core/src/lib.rs`](https://github.com/styayur/ipa-first-tts/blob/main/crates/ipa-core/src/lib.rs) (IPA Parsing and Validation), [`apps/desktop/ui/app.js`](https://github.com/styayur/ipa-first-tts/blob/main/apps/desktop/ui/app.js) (Browser UI), [`apps/desktop/src/server.rs`](https://github.com/styayur/ipa-first-tts/blob/main/apps/desktop/src/server.rs) (Loopback HTTP Server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_browser["Browser UI<br/>[app.js]"]
  node_cli["CLI Commands<br/>[main.rs]"]
  node_http["Loopback HTTP Server<br/>[server.rs]"]
  node_engine["Application Engine<br/>[lib.rs]"]
end

subgraph group_ipa["IPA Processing"]
  node_g2p["eSpeak G2P<br/>[lib.rs]"]
  node_espeak["eSpeak-NG"]
  node_ipa_ir["IPA Parsing and Validation<br/>[lib.rs]"]
end

subgraph group_synthesis["Speech Synthesis"]
  node_tts_contracts["TTS Contracts and Audio<br/>[lib.rs]"]
  node_kokoro_adapter["Kokoro IPA Adapter<br/>[lib.rs]"]
  node_kokoro_runtime["Kokoro Inference<br/>[sherpa.rs]"]
  node_sherpa["sherpa-onnx Runtime"]
  node_fallback["eSpeak TTS Fallback<br/>[lib.rs]"]
end

subgraph group_results["Audio Results"]
  node_alignment["Estimated Alignment<br/>[lib.rs]"]
  node_wav["WAV Encoding<br/>[lib.rs]"]
  node_playback["Playback and Save<br/>[app.js]"]
end

node_user(("User"))

node_user -->|"edits IPA"| node_browser
node_user -->|"runs commands"| node_cli
node_browser -->|"sends API requests"| node_http
node_cli -->|"runs operations"| node_engine
node_http -->|"dispatches requests"| node_engine
node_engine -->|"generates IPA"| node_g2p
node_g2p -->|"runs G2P"| node_espeak
node_g2p -->|"parses output"| node_ipa_ir
node_browser -->|"validates edits"| node_ipa_ir
node_cli -->|"parses supplied IPA"| node_ipa_ir
node_engine -->|"dispatches fallback"| node_fallback
node_engine -->|"dispatches Kokoro"| node_kokoro_runtime
node_fallback -->|"consumes IPA"| node_ipa_ir
node_fallback -->|"synthesizes speech"| node_espeak
node_kokoro_runtime -->|"adapts IPA"| node_kokoro_adapter
node_kokoro_adapter -->|"reads sequence"| node_ipa_ir
node_kokoro_runtime -->|"runs inference"| node_sherpa
node_fallback -->|"returns audio"| node_tts_contracts
node_kokoro_runtime -->|"returns audio"| node_tts_contracts
node_http -->|"estimates timing"| node_alignment
node_alignment -->|"reads audio"| node_tts_contracts
node_tts_contracts -->|"encodes WAV"| node_wav
node_http -->|"serves audio"| node_playback
node_browser -->|"plays or saves"| node_playback

click node_browser "https://github.com/styayur/ipa-first-tts/blob/main/apps/desktop/ui/app.js"
click node_cli "https://github.com/styayur/ipa-first-tts/blob/main/apps/desktop/src/main.rs"
click node_http "https://github.com/styayur/ipa-first-tts/blob/main/apps/desktop/src/server.rs"
click node_engine "https://github.com/styayur/ipa-first-tts/blob/main/apps/desktop/src/lib.rs"
click node_g2p "https://github.com/styayur/ipa-first-tts/blob/main/crates/g2p-espeak/src/lib.rs"
click node_ipa_ir "https://github.com/styayur/ipa-first-tts/blob/main/crates/ipa-core/src/lib.rs"
click node_tts_contracts "https://github.com/styayur/ipa-first-tts/blob/main/crates/tts-core/src/lib.rs"
click node_kokoro_adapter "https://github.com/styayur/ipa-first-tts/blob/main/crates/tts-kokoro/src/lib.rs"
click node_kokoro_runtime "https://github.com/styayur/ipa-first-tts/blob/main/crates/tts-kokoro/src/sherpa.rs"
click node_fallback "https://github.com/styayur/ipa-first-tts/blob/main/crates/g2p-espeak/src/lib.rs"
click node_alignment "https://github.com/styayur/ipa-first-tts/blob/main/crates/alignment-core/src/lib.rs"
click node_wav "https://github.com/styayur/ipa-first-tts/blob/main/crates/tts-core/src/lib.rs"
click node_playback "https://github.com/styayur/ipa-first-tts/blob/main/apps/desktop/ui/app.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_browser,node_cli,node_http,node_engine,node_user toneBlue
class node_g2p,node_espeak,node_ipa_ir toneAmber
class node_tts_contracts,node_kokoro_adapter,node_kokoro_runtime,node_sherpa,node_fallback toneMint
class node_alignment,node_wav,node_playback toneRose
```

## Components

### Application

- [Browser UI](https://github.com/styayur/ipa-first-tts/blob/main/apps/desktop/ui/app.js): `apps/desktop/ui/app.js`
- [CLI Commands](https://github.com/styayur/ipa-first-tts/blob/main/apps/desktop/src/main.rs): `apps/desktop/src/main.rs`
- [Loopback HTTP Server](https://github.com/styayur/ipa-first-tts/blob/main/apps/desktop/src/server.rs): `apps/desktop/src/server.rs`
- [Application Engine](https://github.com/styayur/ipa-first-tts/blob/main/apps/desktop/src/lib.rs): `apps/desktop/src/lib.rs`

### IPA Processing

- [eSpeak G2P](https://github.com/styayur/ipa-first-tts/blob/main/crates/g2p-espeak/src/lib.rs): `crates/g2p-espeak/src/lib.rs`
- **eSpeak-NG**
- [IPA Parsing and Validation](https://github.com/styayur/ipa-first-tts/blob/main/crates/ipa-core/src/lib.rs): `crates/ipa-core/src/lib.rs`

### Speech Synthesis

- [TTS Contracts and Audio](https://github.com/styayur/ipa-first-tts/blob/main/crates/tts-core/src/lib.rs): `crates/tts-core/src/lib.rs`
- [Kokoro IPA Adapter](https://github.com/styayur/ipa-first-tts/blob/main/crates/tts-kokoro/src/lib.rs): `crates/tts-kokoro/src/lib.rs`
- [Kokoro Inference](https://github.com/styayur/ipa-first-tts/blob/main/crates/tts-kokoro/src/sherpa.rs): `crates/tts-kokoro/src/sherpa.rs`
- **sherpa-onnx Runtime**
- [eSpeak TTS Fallback](https://github.com/styayur/ipa-first-tts/blob/main/crates/g2p-espeak/src/lib.rs): `crates/g2p-espeak/src/lib.rs`

### Audio Results

- [Estimated Alignment](https://github.com/styayur/ipa-first-tts/blob/main/crates/alignment-core/src/lib.rs): `crates/alignment-core/src/lib.rs`
- [WAV Encoding](https://github.com/styayur/ipa-first-tts/blob/main/crates/tts-core/src/lib.rs): `crates/tts-core/src/lib.rs`
- [Playback and Save](https://github.com/styayur/ipa-first-tts/blob/main/apps/desktop/ui/app.js): `apps/desktop/ui/app.js`

### Other components

- **User**

## Connections

- User → Browser UI: edits IPA (evidence: `README.md`)
- User → CLI Commands: runs commands (evidence: `README.md`)
- Browser UI → Loopback HTTP Server: sends API requests (evidence: `apps/desktop/ui/app.js`)
- CLI Commands → Application Engine: runs operations (evidence: `apps/desktop/src/main.rs`)
- Loopback HTTP Server → Application Engine: dispatches requests (evidence: `README.md`)
- Application Engine → eSpeak G2P: generates IPA (evidence: `apps/desktop/src/lib.rs`)
- eSpeak G2P → eSpeak-NG: runs G2P (evidence: `README.md`)
- eSpeak G2P → IPA Parsing and Validation: parses output (evidence: `crates/g2p-espeak/src/lib.rs`)
- Browser UI → IPA Parsing and Validation: validates edits (evidence: `README.md`)
- CLI Commands → IPA Parsing and Validation: parses supplied IPA (evidence: `apps/desktop/src/main.rs`)
- Application Engine → eSpeak TTS Fallback: dispatches fallback (evidence: `apps/desktop/src/lib.rs`)
- Application Engine → Kokoro Inference: dispatches Kokoro (evidence: `apps/desktop/src/lib.rs`)
- eSpeak TTS Fallback → IPA Parsing and Validation: consumes IPA (evidence: `crates/g2p-espeak/src/lib.rs`)
- eSpeak TTS Fallback → eSpeak-NG: synthesizes speech (evidence: `README.md`)
- Kokoro Inference → Kokoro IPA Adapter: adapts IPA (evidence: `README.md`)
- Kokoro IPA Adapter → IPA Parsing and Validation: reads sequence (evidence: `crates/tts-kokoro/src/lib.rs`)
- Kokoro Inference → sherpa-onnx Runtime: runs inference (evidence: `README.md`)
- eSpeak TTS Fallback → TTS Contracts and Audio: returns audio (evidence: `crates/g2p-espeak/src/lib.rs`)
- Kokoro Inference → TTS Contracts and Audio: returns audio (evidence: `crates/tts-kokoro/src/sherpa.rs`)
- Loopback HTTP Server → Estimated Alignment: estimates timing (evidence: `apps/desktop/src/server.rs`)
- Estimated Alignment → TTS Contracts and Audio: reads audio (evidence: `crates/alignment-core/src/lib.rs`)
- TTS Contracts and Audio → WAV Encoding: encodes WAV (evidence: `crates/tts-core/src/lib.rs`)
- Loopback HTTP Server → Playback and Save: serves audio (evidence: `README.md`)
- Browser UI → Playback and Save: plays or saves (evidence: `apps/desktop/ui/app.js`)
