實踐教程
本教程目錄
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
bash
cp .env.example .env.local
npm install --legacy-peer-deps
npm run devOpen http://localhost:3000 → start conversation.
Verification
- Join/start agent with PTT idle — speaking should not elicit an agent reply.
- Hold (or latch) Push-to-Talk, speak a short question — agent should answer.
- Release PTT — further speech should not be heard by the agent.
npm testpasses.
Non-goals
- SIP / phone calling
- Multi-agent handoff (see Agora
agent-handoffrecipe instead) - Custom LLM gateway unless required by your starter
# 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
```bash
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