mirror of
https://github.com/prdlk/dotfiles.git
synced 2026-11-08 04:57:36 +00:00
config(git,claude,ssh): templated gitconfig; claude settings/commands/hooks/skills; ssh config
gitconfig: name/email from chezmoi data, gh credential helper by PATH lookup (portable to darwin). claude: no credentials, history, projects, sessions, or plugin caches. ssh config as private_ (0600). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3c691e8dc5
commit
20891f3910
476 files changed
+59086
-7
No files matched your search
@@ -0,0 +1,68 @@
|
||||
# Voice (Experimental)
|
||||
|
||||
Fetch https://developers.cloudflare.com/agents/api-reference/voice/ for complete documentation.
|
||||
|
||||
`@cloudflare/voice` — real-time speech-to-text and text-to-speech for agents. Audio streams over WebSocket.
|
||||
|
||||
```bash
|
||||
npm install @cloudflare/voice
|
||||
```
|
||||
|
||||
## Server
|
||||
|
||||
```typescript
|
||||
import { Agent } from "agents";
|
||||
import { withVoice, WorkersAITTS, WorkersAINova3STT } from "@cloudflare/voice";
|
||||
|
||||
export class VoiceAgent extends withVoice(Agent)<Env> {
|
||||
transcriber = new WorkersAINova3STT(this);
|
||||
tts = new WorkersAITTS(this);
|
||||
|
||||
async onTurn(transcript: string, context: VoiceTurnContext) {
|
||||
const result = streamText({
|
||||
model: createWorkersAI({ binding: this.env.AI })("@cf/meta/llama-4-scout-17b-16e-instruct"),
|
||||
messages: [
|
||||
{ role: "system", content: "You are a voice assistant." },
|
||||
...context.conversationHistory,
|
||||
{ role: "user", content: transcript }
|
||||
]
|
||||
});
|
||||
|
||||
for await (const chunk of result.textStream) {
|
||||
if (context.signal.aborted) break;
|
||||
context.speak(chunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Lifecycle Hooks
|
||||
|
||||
| Hook | Purpose |
|
||||
|------|---------|
|
||||
| `onTurn(transcript, ctx)` | Handle transcribed speech (required) |
|
||||
| `beforeCallStart(conn)` | Auth/validation before call starts |
|
||||
| `onCallStart(conn)` | Call connected |
|
||||
| `onCallEnd(conn)` | Call disconnected |
|
||||
| `onInterrupt()` | User interrupted agent speech |
|
||||
|
||||
## Client (React)
|
||||
|
||||
```tsx
|
||||
import { useVoiceAgent } from "@cloudflare/voice/react";
|
||||
|
||||
function VoiceUI() {
|
||||
const { isConnected, isSpeaking, connect, disconnect } = useVoiceAgent({
|
||||
agent: "VoiceAgent",
|
||||
name: "session-1"
|
||||
});
|
||||
|
||||
return <button onClick={isConnected ? disconnect : connect}>
|
||||
{isConnected ? "End Call" : "Start Call"}
|
||||
</button>;
|
||||
}
|
||||
```
|
||||
|
||||
## STT/TTS Providers
|
||||
|
||||
Workers AI (default), Deepgram, ElevenLabs — install the provider package and swap the `transcriber`/`tts` properties.
|
||||
Reference in new issue
Block a user