🎯 Objective & Overview
Integrate a dedicated, lightweight Text-to-Speech (TTS) engine service—primarily Kokoro-FastAPI (CPU/GPU, Apache 2.0, 82M params) or AllTalk TTS—into LocalLLMServerManager. Provide full process lifecycle management and an OpenAI-compatible /v1/audio/speech proxy.
📂 Files & Components to Touch
- Configuration (
LocalLLMServerManager.Shared/Models/AppSettings.cs):
- Add:
string AudioEngineExecutablePath = "" (Path to python script, binary, or docker command)
string AudioEngineUrl = "http://127.0.0.1:8880"
string PreferredAudioVoice = "af_heart"
- Process Management (
Services/AiEngineManager.cs & Interfaces/IAiEngineManager.cs):
- Add
Task<bool> StartAudioEngineAsync(string executablePath, ILogger logger)
- Add
Task<bool> StopAudioEngineAsync(ILogger logger)
- Add
Process? AudioProcess { get; }
- Endpoints (
Endpoints/EngineEndpoints.cs & Endpoints/ModelProxyEndpoints.cs):
POST /api/audio/start — Spawns the audio engine process or starts the docker container.
POST /api/audio/stop — Gracefully stops the process.
POST /v1/audio/speech — Proxies OpenAI-format speech requests to AudioEngineUrl/v1/audio/speech.
GET /api/audio/voices — Returns list of available voice profiles.
- Tool Discovery (
Services/ToolDiscoveryService.cs):
- Auto-detect local Kokoro/AllTalk installations and Docker container availability.
🔌 API Contract
POST /v1/audio/speech (OpenAI Compatibility Standard)
{
"model": "kokoro",
"input": "The quick brown fox jumps over the lazy dog.",
"voice": "af_heart",
"response_format": "mp3",
"speed": 1.0
}
Response: 200 OK with binary audio/mpeg or audio/wav stream.
🛠️ Step-by-Step Implementation Guide
- Update
AppSettings.cs with the new audio configuration properties.
- Implement start/stop process handlers in
AiEngineManager.cs.
- Add the proxy route in
ModelProxyEndpoints.cs streaming chunked audio responses directly back to the HTTP client.
- Update UI settings in
SettingsTabControl.axaml to display the Audio Engine status, path, and test voice synthesizer.
🧪 Verification
dotnet build
dotnet test --filter Category!=LiveExternal
npm run lint & npx tsc --noEmit
🎯 Objective & Overview
Integrate a dedicated, lightweight Text-to-Speech (TTS) engine service—primarily Kokoro-FastAPI (CPU/GPU, Apache 2.0, 82M params) or AllTalk TTS—into
LocalLLMServerManager. Provide full process lifecycle management and an OpenAI-compatible/v1/audio/speechproxy.📂 Files & Components to Touch
LocalLLMServerManager.Shared/Models/AppSettings.cs):string AudioEngineExecutablePath = ""(Path to python script, binary, or docker command)string AudioEngineUrl = "http://127.0.0.1:8880"string PreferredAudioVoice = "af_heart"Services/AiEngineManager.cs&Interfaces/IAiEngineManager.cs):Task<bool> StartAudioEngineAsync(string executablePath, ILogger logger)Task<bool> StopAudioEngineAsync(ILogger logger)Process? AudioProcess { get; }Endpoints/EngineEndpoints.cs&Endpoints/ModelProxyEndpoints.cs):POST /api/audio/start— Spawns the audio engine process or starts the docker container.POST /api/audio/stop— Gracefully stops the process.POST /v1/audio/speech— Proxies OpenAI-format speech requests toAudioEngineUrl/v1/audio/speech.GET /api/audio/voices— Returns list of available voice profiles.Services/ToolDiscoveryService.cs):🔌 API Contract
POST /v1/audio/speech(OpenAI Compatibility Standard){ "model": "kokoro", "input": "The quick brown fox jumps over the lazy dog.", "voice": "af_heart", "response_format": "mp3", "speed": 1.0 }Response:
200 OKwith binaryaudio/mpegoraudio/wavstream.🛠️ Step-by-Step Implementation Guide
AppSettings.cswith the new audio configuration properties.AiEngineManager.cs.ModelProxyEndpoints.csstreaming chunked audio responses directly back to the HTTP client.SettingsTabControl.axamlto display the Audio Engine status, path, and test voice synthesizer.🧪 Verification
dotnet builddotnet test --filter Category!=LiveExternalnpm run lint&npx tsc --noEmit