Voice AI
All recipes
TypeScriptIntermediate

Push-to-Talk

Gate the microphone with press-to-talk for deliberate voice turns.

Recipe prompt

Paste into Cursor, Claude Code, v0, or your coding agent
Use with your coding agent
You are implementing the "Push-to-Talk" recipe in this project.

Read the recipe markdown first:
https://raw.githubusercontent.com/Therealratoshen/recipe-push-to-talk/main/docs/ai/RECIPE.md

Use the source repository for cross-reference:
https://github.com/Therealratoshen/recipe-push-to-talk

Build this recipe into the user's app using the markdown as the implementation guide. Inspect related source files through the repository links when the recipe points to them. Ask before installing new dependencies.

Recipe

Rendered from the configured recipe markdown.

Raw

Push-to-Talk Voice Agent

Copyable prompt for coding agents Build and run the Agora Conversational AI push-to-talk recipe in this repo. Read AGENTS.md and docs/ai/RECIPE.md fully. Copy .env.example to .env.local and fill Agora + LLM + TTS credentials. Run npm install --legacy-peer-deps && npm run dev. Open localhost:3000, start a conversation, and verify the agent only hears you while Push-to-Talk is engaged (hold or toggle). Do not remove the mic publish gate in lib/ptt.ts.

What you build

A browser ConvoAI client where microphone uplink is gated by push-to-talk (hold-to-talk or latch toggle). Use this in noisy rooms or when deliberate turns beat full-duplex barge-in.

Prerequisites

  • Node.js 20+
  • Agora App ID + App Certificate
  • LLM API key + TTS vendor credentials (see .env.example)

Run

cp .env.example .env.local
npm install --legacy-peer-deps
npm run dev

Open http://localhost:3000 → start conversation.

Verification

  1. Join/start agent with PTT idle — speaking should not elicit an agent reply.
  2. Hold (or latch) Push-to-Talk, speak a short question — agent should answer.
  3. Release PTT — further speech should not be heard by the agent.
  4. npm test passes.

Non-goals

  • SIP / phone calling
  • Multi-agent handoff (see Agora agent-handoff recipe instead)
  • Custom LLM gateway unless required by your starter