Skip to content

feat: add terminal-tts demo - #29

Open
luke-speechify wants to merge 2 commits into
mainfrom
feat/terminal-tts
Open

feat: add terminal-tts demo#29
luke-speechify wants to merge 2 commits into
mainfrom
feat/terminal-tts

Conversation

@luke-speechify

Copy link
Copy Markdown
Contributor

Pairs with the upcoming speechify.ai post "Text-to-speech from your terminal: a CLI demo with the Speechify API".

What this demo does

A terminal-styled web playground for Speechify text-to-speech. The page renders a monospace "terminal" where you type a command like:

speechify say "hello world" --voice geffen_32 --model simba-3.2

Hitting enter parses the quoted text and --voice / --model flags client-side, POSTs { text, voiceId, model } to a server route, plays the returned audio, and prints shell-style output. Also supports voices, help, clear, and Up/Down command history.

The original idea — reading text aloud straight from the command line — can't be hosted as a shared page, so this is a hostable adaptation. The real CLI ships alongside it in cli/say.mjs: a standalone, dependency-free Node script (native fetch + node:fs) that calls POST https://api.speechify.ai/v1/audio/speech with your env key and writes an MP3 (or pipes to a player). Documented in the README under "Run it as a real CLI".

Key handling and gating

  • Server-side key: all synthesis in the web app goes through app/api/say/route.ts (Node runtime, client.audio.speech, returns base64 MP3). SPEECHIFY_API_KEY never reaches the browser; @speechify/api is marked server-external.
  • Turnstile: the widget renders near the terminal, and every gated fetch attaches the x-turnstile-token header. Fails open locally when TURNSTILE_SECRET_KEY is unset.
  • The cli/say.mjs script reads the key from your own shell environment — it runs on your machine, not in a browser.

Hosting registration

  • vercel.json — added a terminal-tts service + a /terminal-tts/:path* rewrite (before the / and catch-all rewrites).
  • pnpm-workspace.yaml — added demos/terminal-tts.
  • pnpm generate — regenerated the README table and site manifest.
  • Dev port 8769 (unique across demos).

Verification

  • pnpm --filter terminal-tts build succeeds (build + typecheck ✅).
  • Live API call ✅ — ran the shipped cli/say.mjs against the real endpoint with the default geffen_32 / simba-3.2; got a valid 44 KB MP3 back (the web route sends the identical request body via the SDK).

A terminal-styled web playground for Speechify text-to-speech: type a
'speechify say' command, hit enter, and the browser posts it to a Node
route that holds the API key and returns audio. Ships the real,
dependency-free cli/say.mjs so the same thing runs in a genuine shell.

Registers the demo as a Vercel Service and workspace package.
@vercel

vercel Bot commented Aug 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
speechify-api-demos Ready Ready Preview Aug 21, 2026 12:17am

Request Review

@luke-speechify luke-speechify left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Demo queue review — terminal-tts:

  • CLI matches the DRG-374 thesis: dependency-free cli/say.mjs calling POST https://api.speechify.ai/v1/audio/speech with model simba-3.2, key via SPEECHIFY_API_KEY. Endpoint, voice and model defaults match the other TypeScript demos and the docs.
  • Key stays server-side: the Next.js playground proxies through route handlers; the CLI reads .env locally. No client key exposure.
  • demo.json (order 205) + pnpm-workspace.yaml + vercel.json + regenerated README/index are all in this PR — hosted signal and generated outputs in sync.

Not approved (leaving approval to Luke per merge policy). One note: this is the canonical CLI demo for the Text-to-speech from your terminal post; a duplicate cli-tts PR was opened and withdrawn.

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