@mastra/voice-cloudflare 0.12.0 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,83 @@
1
+ # Cloudflare
2
+
3
+ The CloudflareVoice class in Mastra provides text-to-speech capabilities using Cloudflare Workers AI. This provider specializes in efficient, low-latency speech synthesis suitable for edge computing environments.
4
+
5
+ ## Usage example
6
+
7
+ ```typescript
8
+ import { CloudflareVoice } from '@mastra/voice-cloudflare'
9
+
10
+ // Initialize with configuration
11
+ const voice = new CloudflareVoice({
12
+ speechModel: {
13
+ name: '@cf/meta/m2m100-1.2b',
14
+ apiKey: 'your-cloudflare-api-token',
15
+ accountId: 'your-cloudflare-account-id',
16
+ },
17
+ speaker: 'en-US-1', // Default voice
18
+ })
19
+
20
+ // Convert text to speech
21
+ const audioStream = await voice.speak('Hello, how can I help you?', {
22
+ speaker: 'en-US-2', // Override default voice
23
+ })
24
+
25
+ // Get available voices
26
+ const speakers = await voice.getSpeakers()
27
+ console.log(speakers)
28
+ ```
29
+
30
+ ## Configuration
31
+
32
+ ### Constructor options
33
+
34
+ **speechModel** (`CloudflareSpeechConfig`): Configuration for text-to-speech synthesis.
35
+
36
+ **speechModel.name** (`string`): Model name to use for TTS.
37
+
38
+ **speechModel.apiKey** (`string`): Cloudflare API token with Workers AI access. Falls back to CLOUDFLARE\_API\_TOKEN environment variable.
39
+
40
+ **speechModel.accountId** (`string`): Cloudflare account ID. Falls back to CLOUDFLARE\_ACCOUNT\_ID environment variable.
41
+
42
+ **speaker** (`string`): Default voice ID for speech synthesis. (Default: `'en-US-1'`)
43
+
44
+ ## Methods
45
+
46
+ ### `speak()`
47
+
48
+ Converts text to speech using Cloudflare's text-to-speech service.
49
+
50
+ **input** (`string | NodeJS.ReadableStream`): Text or text stream to convert to speech.
51
+
52
+ **options** (`Options`): Configuration options.
53
+
54
+ **options.speaker** (`string`): Voice ID to use for speech synthesis.
55
+
56
+ **options.format** (`string`): Output audio format.
57
+
58
+ Returns: `Promise<NodeJS.ReadableStream>`
59
+
60
+ ### `getSpeakers()`
61
+
62
+ Returns an array of available voice options, where each node contains:
63
+
64
+ **voiceId** (`string`): Unique identifier for the voice (e.g., 'en-US-1')
65
+
66
+ **language** (`string`): Language code of the voice (e.g., 'en-US')
67
+
68
+ ## Notes
69
+
70
+ - API tokens can be provided via constructor options or environment variables (CLOUDFLARE\_API\_TOKEN and CLOUDFLARE\_ACCOUNT\_ID)
71
+ - Cloudflare Workers AI is optimized for edge computing with low latency
72
+ - This provider only supports text-to-speech (TTS) functionality, not speech-to-text (STT)
73
+ - The service integrates well with other Cloudflare Workers products
74
+ - For production use, ensure your Cloudflare account has the appropriate Workers AI subscription
75
+ - Voice options are more limited compared to some other providers, but performance at the edge is excellent
76
+
77
+ ## Related providers
78
+
79
+ If you need speech-to-text capabilities in addition to text-to-speech, consider using one of these providers:
80
+
81
+ - [OpenAI](https://mastra.ai/reference/voice/openai) - Provides both TTS and STT
82
+ - [Google](https://mastra.ai/reference/voice/google) - Provides both TTS and STT
83
+ - [Azure](https://mastra.ai/reference/voice/azure) - Provides both TTS and STT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/voice-cloudflare",
3
- "version": "0.12.0",
3
+ "version": "0.12.1",
4
4
  "description": "Mastra Cloudflare AI voice integration",
5
5
  "type": "module",
6
6
  "files": [
@@ -24,21 +24,21 @@
24
24
  },
25
25
  "license": "Apache-2.0",
26
26
  "dependencies": {
27
- "cloudflare": "^4.5.0"
27
+ "cloudflare": "^5.2.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@cloudflare/workers-types": "^4.20251111.0",
31
- "@types/node": "22.13.17",
32
- "@vitest/coverage-v8": "4.0.12",
33
- "@vitest/ui": "4.0.12",
34
- "eslint": "^9.37.0",
35
- "tsup": "^8.5.0",
30
+ "@cloudflare/workers-types": "^4.20260316.1",
31
+ "@types/node": "22.19.15",
32
+ "@vitest/coverage-v8": "4.0.18",
33
+ "@vitest/ui": "4.0.18",
34
+ "eslint": "^9.39.4",
35
+ "tsup": "^8.5.1",
36
36
  "typescript": "^5.9.3",
37
- "vitest": "4.0.16",
38
- "zod": "^3.25.76",
39
- "@internal/lint": "0.0.54",
40
- "@internal/types-builder": "0.0.29",
41
- "@mastra/core": "1.0.0"
37
+ "vitest": "4.0.18",
38
+ "zod": "^4.3.6",
39
+ "@internal/lint": "0.0.75",
40
+ "@internal/types-builder": "0.0.50",
41
+ "@mastra/core": "1.18.0"
42
42
  },
43
43
  "keywords": [
44
44
  "mastra",
@@ -68,7 +68,6 @@
68
68
  },
69
69
  "scripts": {
70
70
  "build": "tsup --silent --config tsup.config.ts",
71
- "postbuild": "pnpx tsx ../../scripts/generate-package-docs.ts voice/cloudflare",
72
71
  "build:watch": "tsup --watch --silent --config tsup.config.ts",
73
72
  "test": "vitest run",
74
73
  "test:watch": "vitest watch",
@@ -1,32 +0,0 @@
1
- # @mastra/voice-cloudflare Documentation
2
-
3
- > Embedded documentation for coding agents
4
-
5
- ## Quick Start
6
-
7
- ```bash
8
- # Read the skill overview
9
- cat docs/SKILL.md
10
-
11
- # Get the source map
12
- cat docs/SOURCE_MAP.json
13
-
14
- # Read topic documentation
15
- cat docs/<topic>/01-overview.md
16
- ```
17
-
18
- ## Structure
19
-
20
- ```
21
- docs/
22
- ├── SKILL.md # Entry point
23
- ├── README.md # This file
24
- ├── SOURCE_MAP.json # Export index
25
- ├── agents/ (1 files)
26
- ├── voice/ (2 files)
27
- ```
28
-
29
- ## Version
30
-
31
- Package: @mastra/voice-cloudflare
32
- Version: 0.12.0