Skip to content

feat(tts): Wyoming service discovery and multi-model seeding#32

Open
AsierZunzu wants to merge 1 commit into
mainfrom
feat/wyoming-service-discovery
Open

feat(tts): Wyoming service discovery and multi-model seeding#32
AsierZunzu wants to merge 1 commit into
mainfrom
feat/wyoming-service-discovery

Conversation

@AsierZunzu
Copy link
Copy Markdown
Owner

@AsierZunzu AsierZunzu commented Apr 19, 2026

Summary

  • compose.yaml: Replaced the single tts service with tts-english and tts-spanish; removed PIPER_HOST/PIPER_PORT env vars from narratio and added PIPER_SERVICES: "tts-english:10200,tts-spanish:10200"; updated depends_on accordingly.
  • src/utils/env.ts: Removed PIPER_HOST and PIPER_PORT accessors; added PIPER_SERVICES as a required string accessor (comma-separated host:port pairs).
  • src/db/schema.ts: Added voice TEXT (nullable) and languages TEXT (nullable, stores JSON array) to the ttsServices table.
  • src/db/index.ts: Updated TTS_SERVICES_SQL to include the new columns; added two ALTER TABLE migration statements for existing DBs; updated seedFromEnv to seed from PIPER_SERVICES instead of PIPER_HOST/PIPER_PORT.
  • src/db/tts-services.ts: Added getTtsServiceByHostPort and upsertTtsServiceByHostPort functions; extended InsertTtsServiceParams with optional voice/languages fields.
  • src/services/tts.ts: Added discoverService(host, port) — opens a TCP connection, sends {"type":"describe"}\n, reads until an info event, extracts tts[0].name (voice) and tts[0].languages, returns TtsServiceInfo | null. Returns null on any error (timeout, refused, malformed).
  • src/worker/index.ts: Added seedTtsServices() — parses PIPER_SERVICES, calls discoverService for each endpoint, upserts into tts_services (updates voice/languages if the host:port row exists, inserts with a generated name otherwise), logs discovered voices, and warns about feeds referencing unknown TTS service IDs. Called once at startup before the first runOnce.
  • tests/helpers/schema.ts: Added voice and languages columns to TEST_SCHEMA_SQL so in-memory test DBs match the updated schema.

New env var format

PIPER_SERVICES=host1:port1,host2:port2

Example: PIPER_SERVICES=tts-english:10200,tts-spanish:10200

Startup seeding flow

  1. Worker starts → calls seedTtsServices()
  2. For each host:port in PIPER_SERVICES: send describe → receive info → extract voice + languages
  3. Upsert row in tts_services (insert on first run, update voice/languages on subsequent runs)
  4. Log discovered voice at info level; log a warning for unreachable endpoints
  5. Warn for any feed whose tts_service_id doesn't match a known service

Test plan

  • npm run lint passes (tsc --noEmit, no type errors)
  • npm test passes (103 tests across 11 test files)
  • discoverService returns null gracefully on connection refused / timeout
  • Existing DBs get voice/languages columns via ALTER TABLE migrations without data loss
  • Fresh compose stack starts with two Piper services discovered and seeded

🤖 Generated with Claude Code

@AsierZunzu AsierZunzu force-pushed the feat/wyoming-service-discovery branch from 77b1fef to d24ca0f Compare April 19, 2026 14:54
@AsierZunzu AsierZunzu force-pushed the feat/wyoming-service-discovery branch from d24ca0f to 2ffde6a Compare April 19, 2026 17:29
@AsierZunzu AsierZunzu force-pushed the v2 branch 5 times, most recently from c655ab1 to 5463aff Compare April 20, 2026 16:30
@AsierZunzu AsierZunzu force-pushed the feat/wyoming-service-discovery branch 2 times, most recently from 6521205 to 5b8eddf Compare April 20, 2026 17:14
@AsierZunzu AsierZunzu changed the base branch from v2 to main April 27, 2026 16:30
@AsierZunzu AsierZunzu force-pushed the feat/wyoming-service-discovery branch 2 times, most recently from cc9dae0 to f43dfe8 Compare May 2, 2026 17:20
Replace single PIPER_HOST/PIPER_PORT with PIPER_SERVICES (comma-separated
host:port pairs). On worker startup, send describe→info to each endpoint,
upsert voice and languages into tts_services, and warn for feeds that
reference unknown services.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@AsierZunzu AsierZunzu force-pushed the feat/wyoming-service-discovery branch from f43dfe8 to 4ce5227 Compare May 2, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant