Repository navigation
feat: add prompt TTS endpoints - #72
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-voicecan consume them.API
New
Clientmethods (src/voice.rs):generate_prompt(&self, &VoicePromptGenerateRequest) -> Result<VoicePromptGenerated>—POST /api/voice/prompts/generateprompt_bytes(&self, prompt_id: &str) -> Result<Vec<u8>>—GET /api/voice/prompts/{id}/bytesgenerated_prompt_bytes(&self, &VoicePromptGenerated) -> Result<Vec<u8>>— follows the response's ownbytesUrl(saved, ephemeral or anon clip). Refuses anything that isn't a rooted/api/path, so the bearer is never sent off-originprompt_voices(&self) -> Result<VoicePromptVoices>—GET /api/voice/prompts/voices(voices+retired)prompt_config(&self) -> Result<VoicePromptConfig>—GET /api/voice/prompts/configTypes:
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.VoicePromptErroris#[non_exhaustive]:TextTooLong { max_chars: Option<u32> }— the platform doesn't send the cap, so the client reads it back from/prompts/configon a best-effort basisQuotaExceeded { kind: Monthly|AnonDaily|AnonBudget, used, limit, resets_at }—used/limitare read only if the platform sends them (today it sendsresetsAtonly)UnknownVoice { voice_id },ProviderFailedturnstile_failed(403) andunauthenticated(400) both mean the session didn't resolve, so they map to the existingError::UnauthorizedNote: adding a variant to
Error(which isn't#[non_exhaustive]) breaks any consumer that matches it exhaustively.Dependencies / coordination
ephemeralneeds the sibling wavekat-platform PR that adds the optionalephemeralbody field to generate. It's skipped from the body whenfalse, so older servers get the same body as before. Until that PR deploys,ephemeral: trueis probably ignored or rejected by validation, depending on how the route treats unknown keys.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 samestd::netapproach asclient.rs. They cover the request body (with and withoutephemeral), 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 warningscargo fmt --all -- --checkephemeralPR lands🤖 Generated with Claude Code
https://claude.ai/code/session_01QGHE3tcTFWUtjDUxNxTWNG