@mastra/voice-cloudflare
Version:
Mastra Cloudflare AI voice integration
73 lines (51 loc) • 1.51 kB
Markdown
Cloudflare Voice integration for Mastra, providing Text-to-Speech (TTS) capabilities using open source speech models.
```bash
npm install @mastra/voice-cloudflare
```
The module requires the following environment variables:
If using Cloudflare Native Bindings:
`./wrangler.jsonc`
```json
"ai": {
"binding": "AI",
},
```
If using Cloudflare REST API:
```bash
CLOUDFLARE_AI_API_KEY=your_api_key
CLOUDFLARE_ACCOUNT_ID=your_account_id
```
```typescript
import { CloudflareVoice } from '@mastra/voice-cloudflare';
// Native Bindings
const voice = new CloudflareVoice({
binding: env.AI,
listeningModel: {
model: '@cf/openai/whisper-large-v3-turbo',
},
});
// REST API
const voice = new CloudflareVoice({
listeningModel: {
apiKey: 'YOUR_API_KEY',
model: '@cf/openai/whisper-large-v3-turbo',
account_id: 'YOUR_ACC_ID',
},
});
// Generate Text from an audio stream
const text = await voice.listen(audioStream);
```
- Open source models
The following speech-to-text models are available:
| Model | Description |
| ----------------------------------- | ------------------------------ |
| `@cf/openai/whisper-tiny-en` | Lightweight English-only model |
| `@cf/openai/whisper` | Standard multilingual model |
| `@cf/openai/whisper-large-v3-turbo` | High-accuracy turbo model |