Kokoro TTS half-close causing silent fallback to Groq #3
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_agent#3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Kokoro local TTS provider failing silently, causing all voice requests to fall back to Groq cloud TTS.
Root Cause
In hero_voice_tts_unix(), the code used tokio::io::split() to split the Unix stream, then called writer.shutdown() (sending a TCP FIN / half-close) before reading the response. The Kokoro server doesn't handle half-close properly — it sees the FIN and drops the connection, returning 0 bytes. This caused the Kokoro provider to always fail, silently falling back to Groq.
Related Issues:
Implementation Spec: Fix Kokoro TTS Half-Close Causing Silent Fallback to Groq
Objective
Fix a bug where the Kokoro TTS provider always failed silently due to a TCP half-close, causing every TTS request to fall back to the Groq cloud provider. Additionally, correct the default aibroker endpoint port and path, and reduce TTS text truncation length.
Requirements
Connection: closeinstead of socket shutdown./ui.File Modified
crates/hero_agent_server/src/routes.rs-- All changes are in this single file.Implementation Plan
Step 1: Fix half-close in
hero_voice_tts_unix()tokio::io::split(stream)-- usemut streamdirectlywriter.shutdown()call (root cause)Connection: closeheader to signal end of requeststreaminstead of split readerStep 2: Update default aibroker port
chat()function: 9997 -> 9988voice_tts()function: 9997 -> 9988, plus append/uito pathStep 3: Reduce TTS text truncation
Acceptance Criteria
writer.shutdown()call inhero_voice_tts_unix()Connection: closeheader present in Unix socket HTTP requestchat()andvoice_tts()/uipathTest Results
All tests passed across all crates:
Note: 14 compiler warnings present (unused imports, unused variables, dead code) but no errors.
Implementation Summary
Changes Made
All changes in
crates/hero_agent_server/src/routes.rs:Fixed half-close in
hero_voice_tts_unix()(root cause)tokio::io::split(stream)-- now usesmut streamdirectlywriter.shutdown()call that sent TCP FIN, causing Kokoro to drop the connectionConnection: closeheader to signal end-of-request via HTTP insteadreaderto directstreamUpdated default aibroker port from 9997 to 9988 in both
chat()andvoice_tts()Updated voice TTS fallback URL to include
/uipath segmentReduced TTS text truncation from 3000 to 1000 characters
Test Results
Notes
Pull request opened: #4
This PR implements the changes discussed in this issue.