fix(voice/tts): use /health endpoint for Chatterbox availability check

/v1/models returns 404 on Chatterbox — use /health instead.
All other backends keep using /v1/models.
This commit is contained in:
Myka 2026-02-17 13:03:56 +03:00
parent ef5c2de460
commit b21ff3e6c9

View file

@ -201,19 +201,25 @@ func (s *KokoroSynthesizer) Synthesize(ctx context.Context, text string) (string
return tmpFile.Name(), nil return tmpFile.Name(), nil
} }
// IsAvailable checks if the Kokoro TTS server is reachable. // IsAvailable checks if the TTS server is reachable.
// Chatterbox uses /health; all others use /v1/models.
func (s *KokoroSynthesizer) IsAvailable() bool { func (s *KokoroSynthesizer) IsAvailable() bool {
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel() defer cancel()
req, err := http.NewRequestWithContext(ctx, "GET", s.apiBase+"/v1/models", nil) endpoint := "/v1/models"
if s.isChatterbox() {
endpoint = "/health"
}
req, err := http.NewRequestWithContext(ctx, "GET", s.apiBase+endpoint, nil)
if err != nil { if err != nil {
return false return false
} }
resp, err := s.httpClient.Do(req) resp, err := s.httpClient.Do(req)
if err != nil { if err != nil {
logger.DebugCF("voice", "Kokoro TTS health check failed", map[string]interface{}{ logger.DebugCF("voice", "TTS health check failed", map[string]interface{}{
"error": err.Error(), "error": err.Error(),
}) })
return false return false
@ -221,9 +227,10 @@ func (s *KokoroSynthesizer) IsAvailable() bool {
defer resp.Body.Close() defer resp.Body.Close()
available := resp.StatusCode == http.StatusOK available := resp.StatusCode == http.StatusOK
logger.DebugCF("voice", "Kokoro TTS availability", map[string]interface{}{ logger.DebugCF("voice", "TTS availability", map[string]interface{}{
"available": available, "available": available,
"status_code": resp.StatusCode, "status_code": resp.StatusCode,
"endpoint": endpoint,
}) })
return available return available
} }