Skip to content

feat: add prompt TTS endpoints - #72

Merged
wavekat-eason merged 2 commits into
mainfrom
feat/prompt-tts
Oct 17, 2026
Merged

wavekat-eason merged 2 commits into
mainfrom
feat/prompt-tts

Conversation

@wavekat-eason

Copy link
Copy Markdown
Contributor

Summary

Part of the outbound-call-flow work: the WaveKat Voice daemon will render a call flow's prompt text to audio through the platform's existing TTS before it dials. This adds typed wrappers for the voice-prompt generator endpoints so wavekat-voice can consume them.

API

New Client methods (src/voice.rs):

  • generate_prompt(&self, &VoicePromptGenerateRequest) -> Result<VoicePromptGenerated> — POST /api/voice/prompts/generate
  • prompt_bytes(&self, prompt_id: &str) -> Result<Vec<u8>> — GET /api/voice/prompts/{id}/bytes
  • generated_prompt_bytes(&self, &VoicePromptGenerated) -> Result<Vec<u8>> — follows the response's own bytesUrl (saved, ephemeral or anon clip). Refuses anything that isn't a rooted /api/ path, so the bearer is never sent off-origin
  • prompt_voices(&self) -> Result<VoicePromptVoices> — GET /api/voice/prompts/voices (voices + retired)
  • prompt_config(&self) -> Result<VoicePromptConfig> — GET /api/voice/prompts/config

Types: VoicePromptGenerateRequest (new(text, voice_id); format, preset, ephemeral), VoicePromptFormat (ulaw_8000|pcm_8000|pcm_16000|mp3), VoicePromptPreset (none|digits|phone|hours), VoicePromptGenerated, VoicePromptQuota, VoicePromptVoice(s), VoicePromptConfig (+ effective_max_chars()), VoicePromptAnonAllowance.

Errors: one new Error::VoicePrompt(VoicePromptError) variant. VoicePromptError is #[non_exhaustive]:

  • TextTooLong { max_chars: Option<u32> } — the platform doesn't send the cap, so the client reads it back from /prompts/config on a best-effort basis
  • QuotaExceeded { kind: Monthly|AnonDaily|AnonBudget, used, limit, resets_at } — used/limit are read only if the platform sends them (today it sends resetsAt only)
  • UnknownVoice { voice_id }, ProviderFailed
  • turnstile_failed (403) and unauthenticated (400) both mean the session didn't resolve, so they map to the existing Error::Unauthorized

Note: adding a variant to Error (which isn't #[non_exhaustive]) breaks any consumer that matches it exhaustively.

Dependencies / coordination

  • ephemeral needs the sibling wavekat-platform PR that adds the optional ephemeral body field to generate. It's skipped from the body when false, so older servers get the same body as before. Until that PR deploys, ephemeral: true is probably ignored or rejected by validation, depending on how the route treats unknown keys.
  • Version collision: draft feat: add call task pull, claim and attempt sync #71 (feat/call-tasks) also targets the next release, 0.0.36. release-plz will bump whichever lands first; the other gets the next version. Version not hand-bumped here.

Test plan

  • cargo test --workspace: 140 passed. New tests use a scripted one-connection-per-response loopback server, the same std::net approach as client.rs. They cover the request body (with and without ephemeral), success parsing, each error-code mapping, the text-too-long cap lookup (and the fallback when config fails), bytes routes, the off-origin refusal, voices and config.
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo fmt --all -- --check
  • Manual check against a deployed platform once the ephemeral PR lands

🤖 Generated with Claude Code

https://claude.ai/code/session_01QGHE3tcTFWUtjDUxNxTWNG

wavekat-eason and others added 2 commits October 17, 2026 17:44
Typed wrappers for the platform's voice-prompt generator so the voice
daemon can render a call flow's prompt text to audio before dialing:

- Client::generate_prompt (POST /api/voice/prompts/generate), with an
  optional `ephemeral` flag that is omitted from the body when false
- Client::prompt_bytes / generated_prompt_bytes for the clip audio
- Client::prompt_voices and Client::prompt_config

Refusals map to Error::VoicePrompt(VoicePromptError) — text too long
(with the cap, read back from the config route), quota exceeded,
unknown voice, provider failure — and a session that didn't resolve
maps to Error::Unauthorized.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QGHE3tcTFWUtjDUxNxTWNG
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QGHE3tcTFWUtjDUxNxTWNG
@wavekat-eason
wavekat-eason marked this pull request as ready for review October 17, 2026 07:10
@wavekat-eason
wavekat-eason merged commit efbabbc into main Oct 17, 2026
1 check passed
@wavekat-eason
wavekat-eason deleted the feat/prompt-tts branch October 17, 2026 07:11
@github-actions github-actions Bot mentioned this pull request Oct 17, 2026
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