@mastra/voice-google 0.14.2-alpha.0 → 0.14.2
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.
- package/README.md +7 -204
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# @mastra/voice-google
|
|
2
2
|
|
|
3
|
-
Google Cloud
|
|
4
|
-
|
|
5
|
-
> Note: This package replaces the deprecated @mastra/speech-google package, combining both speech synthesis and recognition capabilities.
|
|
3
|
+
Add Google Cloud text-to-speech and speech-to-text to Mastra with configurable voices, languages, audio encoding, streaming, and authentication.
|
|
6
4
|
|
|
7
5
|
## Installation
|
|
8
6
|
|
|
@@ -10,48 +8,6 @@ Google Cloud Voice integration for Mastra, providing both Text-to-Speech (TTS) a
|
|
|
10
8
|
npm install @mastra/voice-google
|
|
11
9
|
```
|
|
12
10
|
|
|
13
|
-
## Configuration
|
|
14
|
-
|
|
15
|
-
The module supports multiple authentication methods:
|
|
16
|
-
|
|
17
|
-
### Option 1: API Key (Development)
|
|
18
|
-
|
|
19
|
-
Use an API key from [Google Cloud Console](https://console.cloud.google.com/apis/credentials):
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
GOOGLE_API_KEY=your_api_key
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
### Option 2: Service Account (Recommended)
|
|
26
|
-
|
|
27
|
-
Use a service account key file:
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
### Option 3: Vertex AI (Recommended for Production)
|
|
34
|
-
|
|
35
|
-
Use OAuth authentication with Google Cloud Platform for enterprise deployments:
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
# Set project ID
|
|
39
|
-
GOOGLE_CLOUD_PROJECT=your_project_id
|
|
40
|
-
|
|
41
|
-
# Optional: Set location (defaults to us-central1)
|
|
42
|
-
GOOGLE_CLOUD_LOCATION=us-central1
|
|
43
|
-
|
|
44
|
-
# Authenticate via gcloud CLI
|
|
45
|
-
gcloud auth application-default login
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Or use a service account:
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json
|
|
52
|
-
GOOGLE_CLOUD_PROJECT=your_project_id
|
|
53
|
-
```
|
|
54
|
-
|
|
55
11
|
## Usage
|
|
56
12
|
|
|
57
13
|
### Standard Usage
|
|
@@ -84,167 +40,14 @@ const audioStream = await voice.speak('Hello from Mastra!', {
|
|
|
84
40
|
const text = await voice.listen(audioStream);
|
|
85
41
|
```
|
|
86
42
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
For enterprise deployments, use Vertex AI mode which provides better integration with Google Cloud infrastructure:
|
|
90
|
-
|
|
91
|
-
```typescript
|
|
92
|
-
import { GoogleVoice } from '@mastra/voice-google';
|
|
93
|
-
|
|
94
|
-
// Initialize with Vertex AI
|
|
95
|
-
const voice = new GoogleVoice({
|
|
96
|
-
vertexAI: true,
|
|
97
|
-
project: 'your-gcp-project',
|
|
98
|
-
location: 'us-central1', // Optional, defaults to 'us-central1'
|
|
99
|
-
speaker: 'en-US-Studio-O',
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
// Works the same as standard mode
|
|
103
|
-
const audioStream = await voice.speak('Hello from Vertex AI!');
|
|
104
|
-
const text = await voice.listen(audioStream);
|
|
105
|
-
|
|
106
|
-
// Check if using Vertex AI
|
|
107
|
-
console.log(voice.isUsingVertexAI()); // true
|
|
108
|
-
console.log(voice.getProject()); // 'your-gcp-project'
|
|
109
|
-
console.log(voice.getLocation()); // 'us-central1'
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### Vertex AI with Service Account
|
|
113
|
-
|
|
114
|
-
```typescript
|
|
115
|
-
import { GoogleVoice } from '@mastra/voice-google';
|
|
116
|
-
|
|
117
|
-
const voice = new GoogleVoice({
|
|
118
|
-
vertexAI: true,
|
|
119
|
-
project: 'your-gcp-project',
|
|
120
|
-
location: 'us-central1',
|
|
121
|
-
speechModel: {
|
|
122
|
-
keyFilename: '/path/to/service-account.json',
|
|
123
|
-
},
|
|
124
|
-
listeningModel: {
|
|
125
|
-
keyFilename: '/path/to/service-account.json',
|
|
126
|
-
},
|
|
127
|
-
});
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
### Vertex AI with In-Memory Credentials
|
|
131
|
-
|
|
132
|
-
```typescript
|
|
133
|
-
import { GoogleVoice } from '@mastra/voice-google';
|
|
134
|
-
|
|
135
|
-
const voice = new GoogleVoice({
|
|
136
|
-
vertexAI: true,
|
|
137
|
-
project: 'your-gcp-project',
|
|
138
|
-
speechModel: {
|
|
139
|
-
credentials: {
|
|
140
|
-
client_email: 'service-account@project.iam.gserviceaccount.com',
|
|
141
|
-
private_key: '-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----',
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
|
-
});
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
## API Reference
|
|
148
|
-
|
|
149
|
-
### Constructor Options
|
|
150
|
-
|
|
151
|
-
| Option | Type | Description |
|
|
152
|
-
| ---------------- | ------------------- | ------------------------------------------------ |
|
|
153
|
-
| `speechModel` | `GoogleModelConfig` | Configuration for TTS |
|
|
154
|
-
| `listeningModel` | `GoogleModelConfig` | Configuration for STT |
|
|
155
|
-
| `speaker` | `string` | Default voice ID (default: `'en-US-Casual-K'`) |
|
|
156
|
-
| `vertexAI` | `boolean` | Enable Vertex AI mode (default: `false`) |
|
|
157
|
-
| `project` | `string` | Google Cloud project ID (required for Vertex AI) |
|
|
158
|
-
| `location` | `string` | Google Cloud region (default: `'us-central1'`) |
|
|
159
|
-
|
|
160
|
-
### GoogleModelConfig
|
|
161
|
-
|
|
162
|
-
| Option | Type | Description |
|
|
163
|
-
| ------------- | -------- | ------------------------------------- |
|
|
164
|
-
| `apiKey` | `string` | Google Cloud API key |
|
|
165
|
-
| `keyFilename` | `string` | Path to service account JSON key file |
|
|
166
|
-
| `credentials` | `object` | In-memory service account credentials |
|
|
167
|
-
|
|
168
|
-
### Methods
|
|
169
|
-
|
|
170
|
-
#### `speak(input, options?)`
|
|
171
|
-
|
|
172
|
-
Converts text to speech.
|
|
173
|
-
|
|
174
|
-
- `input`: `string | NodeJS.ReadableStream` - Text to convert
|
|
175
|
-
- `options.speaker`: Override default voice
|
|
176
|
-
- `options.languageCode`: Language code (e.g., `'en-US'`)
|
|
177
|
-
- `options.audioConfig`: Audio encoding options
|
|
178
|
-
|
|
179
|
-
Returns: `Promise<NodeJS.ReadableStream>` - Audio stream
|
|
180
|
-
|
|
181
|
-
#### `listen(audioStream, options?)`
|
|
182
|
-
|
|
183
|
-
Converts speech to text.
|
|
184
|
-
|
|
185
|
-
- `audioStream`: `NodeJS.ReadableStream` - Audio to transcribe
|
|
186
|
-
- `options.config`: Recognition configuration
|
|
187
|
-
|
|
188
|
-
Returns: `Promise<string>` - Transcribed text
|
|
189
|
-
|
|
190
|
-
#### `getSpeakers(options?)`
|
|
191
|
-
|
|
192
|
-
Lists available voices.
|
|
193
|
-
|
|
194
|
-
- `options.languageCode`: Filter by language (default: `'en-US'`)
|
|
195
|
-
|
|
196
|
-
Returns: `Promise<Array<{ voiceId: string, languageCodes: string[] }>>`
|
|
197
|
-
|
|
198
|
-
#### `isUsingVertexAI()`
|
|
199
|
-
|
|
200
|
-
Returns `true` if Vertex AI mode is enabled.
|
|
201
|
-
|
|
202
|
-
#### `getProject()`
|
|
203
|
-
|
|
204
|
-
Returns the configured Google Cloud project ID.
|
|
205
|
-
|
|
206
|
-
#### `getLocation()`
|
|
207
|
-
|
|
208
|
-
Returns the configured Google Cloud location/region.
|
|
209
|
-
|
|
210
|
-
## Features
|
|
211
|
-
|
|
212
|
-
- Neural Text-to-Speech synthesis
|
|
213
|
-
- Speech-to-Text recognition
|
|
214
|
-
- Multiple voice options across different languages
|
|
215
|
-
- Streaming support for both speech and transcription
|
|
216
|
-
- High-quality audio processing
|
|
217
|
-
- Natural-sounding voice synthesis
|
|
218
|
-
- **Vertex AI support for enterprise deployments**
|
|
219
|
-
|
|
220
|
-
## Required Permissions for Vertex AI
|
|
221
|
-
|
|
222
|
-
When using Vertex AI, ensure your service account or user has the appropriate IAM roles and OAuth scopes:
|
|
223
|
-
|
|
224
|
-
### IAM Roles
|
|
225
|
-
|
|
226
|
-
**For Text-to-Speech:**
|
|
227
|
-
|
|
228
|
-
- `roles/texttospeech.admin` - Text-to-Speech Admin (full access)
|
|
229
|
-
- `roles/texttospeech.editor` - Text-to-Speech Editor (create and manage)
|
|
230
|
-
- `roles/texttospeech.viewer` - Text-to-Speech Viewer (read-only)
|
|
231
|
-
|
|
232
|
-
**For Speech-to-Text:**
|
|
233
|
-
|
|
234
|
-
- `roles/speech.client` - Speech-to-Text Client
|
|
235
|
-
|
|
236
|
-
### OAuth Scopes
|
|
237
|
-
|
|
238
|
-
**For synchronous Text-to-Speech synthesis:**
|
|
43
|
+
## Documentation
|
|
239
44
|
|
|
240
|
-
-
|
|
45
|
+
- [Google](https://mastra.ai/integrations/voice/google)
|
|
241
46
|
|
|
242
|
-
|
|
47
|
+
## Changelog
|
|
243
48
|
|
|
244
|
-
|
|
245
|
-
- `operations.get` - Get operation status
|
|
246
|
-
- `operations.list` - List operations
|
|
49
|
+
See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/voice/google/CHANGELOG.md) for version history and release notes.
|
|
247
50
|
|
|
248
|
-
##
|
|
51
|
+
## Support
|
|
249
52
|
|
|
250
|
-
|
|
53
|
+
We have an [open community Discord](https://discord.gg/mastra-ai). Come and say hello and let us know if you have any questions or need any help getting things running.
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mastra-voice-google
|
|
|
3
3
|
description: Documentation for @mastra/voice-google. Use when working with @mastra/voice-google APIs, configuration, or implementation.
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@mastra/voice-google"
|
|
6
|
-
version: "0.14.2
|
|
6
|
+
version: "0.14.2"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/voice-google",
|
|
3
|
-
"version": "0.14.2
|
|
3
|
+
"version": "0.14.2",
|
|
4
4
|
"description": "Mastra Google voice integration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"tsx": "^4.23.1",
|
|
36
36
|
"typescript": "^7.0.2",
|
|
37
37
|
"vitest": "4.1.10",
|
|
38
|
-
"@internal/
|
|
39
|
-
"@internal/
|
|
40
|
-
"@internal/voice": "0.0.
|
|
38
|
+
"@internal/lint": "0.0.130",
|
|
39
|
+
"@internal/types-builder": "0.0.105",
|
|
40
|
+
"@internal/voice": "0.0.28"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"zod": "^3.25.0 || ^4.0.0"
|