gspeak 0.0.3 → 1.0.0
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/LICENSE +1 -1
- package/README.md +78 -16
- package/dist/src/gSpeak.js +8 -1
- package/dist/src/languages.js +82 -15
- package/package.json +30 -8
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -4,14 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
# gspeak
|
|
6
6
|
|
|
7
|
-
**Google Text to Speech for Node.js
|
|
7
|
+
**Google Text to Speech for Node.js**
|
|
8
8
|
|
|
9
9
|
A TypeScript rewrite of [gtts](https://www.npmjs.com/package/gtts) — drop-in compatible.
|
|
10
10
|
|
|
11
|
-
[](https://codecov.io/gh/GlobalTechInfo/gspeak)
|
|
12
|
+
[](https://npmjs.com/package/gspeak)
|
|
13
13
|
[](https://www.codefactor.io/repository/github/GlobalTechInfo/gspeak)
|
|
14
14
|
[](https://npmjs.com/package/gspeak)
|
|
15
|
+
[](https://jsr.io/@globaltech/gspeak)
|
|
16
|
+
|
|
15
17
|
|
|
16
18
|
</div>
|
|
17
19
|
|
|
@@ -20,10 +22,9 @@ A TypeScript rewrite of [gtts](https://www.npmjs.com/package/gtts) — drop-in c
|
|
|
20
22
|
## ✨ Features
|
|
21
23
|
|
|
22
24
|
- 🔊 Convert any text to speech using **Google TTS**
|
|
23
|
-
- 📦 **Zero deprecated dependencies**
|
|
24
25
|
- 🔷 Full **TypeScript** support
|
|
25
26
|
- 🔗 **Drop-in replacement** for `gtts`
|
|
26
|
-
- 🌍 **
|
|
27
|
+
- 🌍 **81 languages** supported
|
|
27
28
|
- 💾 Save to file or stream directly
|
|
28
29
|
- 🖥️ **CLI** included
|
|
29
30
|
|
|
@@ -31,16 +32,26 @@ A TypeScript rewrite of [gtts](https://www.npmjs.com/package/gtts) — drop-in c
|
|
|
31
32
|
|
|
32
33
|
## 📦 Installation
|
|
33
34
|
|
|
35
|
+
### Node.js (NPM)
|
|
36
|
+
|
|
34
37
|
```bash
|
|
35
38
|
npm i gspeak
|
|
36
39
|
```
|
|
37
40
|
|
|
41
|
+
### Deno / Bun / Modern (JSR)
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
deno add @globaltech/gspeak
|
|
45
|
+
# or
|
|
46
|
+
npx jsr add @globaltech/gspeak
|
|
47
|
+
```
|
|
38
48
|
---
|
|
39
49
|
|
|
40
50
|
## 🚀 Quick Start
|
|
41
51
|
|
|
42
52
|
```ts
|
|
43
53
|
import { gSpeak } from 'gspeak'
|
|
54
|
+
// Use 'jsr:@globaltech/gspeak' for Deno
|
|
44
55
|
|
|
45
56
|
const tts = new gSpeak('Hello world', 'en')
|
|
46
57
|
tts.save('/tmp/hello.mp3', (err) => {
|
|
@@ -48,7 +59,6 @@ tts.save('/tmp/hello.mp3', (err) => {
|
|
|
48
59
|
console.log('Saved to /tmp/hello.mp3')
|
|
49
60
|
})
|
|
50
61
|
```
|
|
51
|
-
|
|
52
62
|
---
|
|
53
63
|
|
|
54
64
|
## 📥 Import
|
|
@@ -58,7 +68,7 @@ import { gSpeak } from 'gspeak' // ESM ✅
|
|
|
58
68
|
|
|
59
69
|
const { gSpeak } = require('gspeak') // CJS ✅
|
|
60
70
|
|
|
61
|
-
|
|
71
|
+
import { gSpeak } from 'jsr:@globaltech/gspeak' // JSR ✅
|
|
62
72
|
```
|
|
63
73
|
|
|
64
74
|
---
|
|
@@ -95,6 +105,19 @@ app.listen(3000, () => {
|
|
|
95
105
|
})
|
|
96
106
|
```
|
|
97
107
|
|
|
108
|
+
### List all supported languages
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
import { LANGUAGES } from 'gspeak'
|
|
112
|
+
|
|
113
|
+
console.log(LANGUAGES)
|
|
114
|
+
// { af: 'Afrikaans', sq: 'Albanian', ... }
|
|
115
|
+
|
|
116
|
+
// or via the static getter
|
|
117
|
+
import { gSpeak } from 'gspeak'
|
|
118
|
+
console.log(gSpeak.languages)
|
|
119
|
+
```
|
|
120
|
+
|
|
98
121
|
### Debug mode
|
|
99
122
|
|
|
100
123
|
```ts
|
|
@@ -103,6 +126,17 @@ const tts = new gSpeak('Hello', 'en', true) // 3rd param enables debug logging
|
|
|
103
126
|
|
|
104
127
|
---
|
|
105
128
|
|
|
129
|
+
### 🛡️ Deno Permissions
|
|
130
|
+
If you are using this package in Deno, you must grant network and file system access:
|
|
131
|
+
```bash
|
|
132
|
+
deno run --allow-net=translate.google.com --allow-write=/tmp main.ts
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
- --allow-net: Required to connect to the Google TTS API.
|
|
136
|
+
- --allow-write: Required only if you use the .save() method.
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
106
140
|
## 🖥️ CLI
|
|
107
141
|
|
|
108
142
|
```bash
|
|
@@ -118,18 +152,23 @@ gspeak "Hello Google Text to Speech" -l en -o /tmp/hello.mp3
|
|
|
118
152
|
|
|
119
153
|
---
|
|
120
154
|
|
|
121
|
-
## 🌍 Supported Languages
|
|
155
|
+
## 🌍 Supported Languages (81 total)
|
|
122
156
|
|
|
123
157
|
| Code | Language |
|
|
124
158
|
|------|----------|
|
|
125
159
|
| `af` | Afrikaans |
|
|
126
160
|
| `sq` | Albanian |
|
|
161
|
+
| `am` | Amharic |
|
|
127
162
|
| `ar` | Arabic |
|
|
128
|
-
| `
|
|
163
|
+
| `eu` | Basque |
|
|
164
|
+
| `bn` | Bengali |
|
|
165
|
+
| `bs` | Bosnian |
|
|
166
|
+
| `bg` | Bulgarian |
|
|
167
|
+
| `my` | Burmese |
|
|
129
168
|
| `ca` | Catalan |
|
|
130
169
|
| `zh` | Chinese |
|
|
131
|
-
| `zh-cn` | Chinese (
|
|
132
|
-
| `zh-tw` | Chinese (
|
|
170
|
+
| `zh-cn` | Chinese (Simplified) |
|
|
171
|
+
| `zh-tw` | Chinese (Traditional) |
|
|
133
172
|
| `zh-yue` | Chinese (Cantonese) |
|
|
134
173
|
| `hr` | Croatian |
|
|
135
174
|
| `cs` | Czech |
|
|
@@ -137,43 +176,67 @@ gspeak "Hello Google Text to Speech" -l en -o /tmp/hello.mp3
|
|
|
137
176
|
| `nl` | Dutch |
|
|
138
177
|
| `en` | English |
|
|
139
178
|
| `en-au` | English (Australia) |
|
|
179
|
+
| `en-ca` | English (Canada) |
|
|
180
|
+
| `en-in` | English (India) |
|
|
181
|
+
| `en-ie` | English (Ireland) |
|
|
140
182
|
| `en-uk` | English (United Kingdom) |
|
|
141
183
|
| `en-us` | English (United States) |
|
|
142
|
-
| `
|
|
184
|
+
| `en-za` | English (South Africa) |
|
|
185
|
+
| `et` | Estonian |
|
|
186
|
+
| `fil` | Filipino |
|
|
143
187
|
| `fi` | Finnish |
|
|
144
188
|
| `fr` | French |
|
|
189
|
+
| `fr-ca` | French (Canada) |
|
|
190
|
+
| `fr-fr` | French (France) |
|
|
191
|
+
| `gl` | Galician |
|
|
145
192
|
| `de` | German |
|
|
146
193
|
| `el` | Greek |
|
|
147
|
-
| `
|
|
194
|
+
| `gu` | Gujarati |
|
|
195
|
+
| `ha` | Hausa |
|
|
196
|
+
| `iw` | Hebrew |
|
|
148
197
|
| `hi` | Hindi |
|
|
149
198
|
| `hu` | Hungarian |
|
|
150
199
|
| `is` | Icelandic |
|
|
151
200
|
| `id` | Indonesian |
|
|
152
201
|
| `it` | Italian |
|
|
153
202
|
| `ja` | Japanese |
|
|
203
|
+
| `jw` | Javanese |
|
|
204
|
+
| `kn` | Kannada |
|
|
205
|
+
| `km` | Khmer |
|
|
154
206
|
| `ko` | Korean |
|
|
155
207
|
| `la` | Latin |
|
|
156
208
|
| `lv` | Latvian |
|
|
157
|
-
| `
|
|
209
|
+
| `lt` | Lithuanian |
|
|
210
|
+
| `ms` | Malay |
|
|
211
|
+
| `ml` | Malayalam |
|
|
212
|
+
| `mr` | Marathi |
|
|
213
|
+
| `ne` | Nepali |
|
|
158
214
|
| `no` | Norwegian |
|
|
159
215
|
| `pl` | Polish |
|
|
160
216
|
| `pt` | Portuguese |
|
|
161
217
|
| `pt-br` | Portuguese (Brazil) |
|
|
218
|
+
| `pt-pt` | Portuguese (Portugal) |
|
|
219
|
+
| `pa` | Punjabi |
|
|
162
220
|
| `ro` | Romanian |
|
|
163
221
|
| `ru` | Russian |
|
|
164
222
|
| `sr` | Serbian |
|
|
223
|
+
| `si` | Sinhala |
|
|
165
224
|
| `sk` | Slovak |
|
|
166
225
|
| `es` | Spanish |
|
|
167
226
|
| `es-es` | Spanish (Spain) |
|
|
168
227
|
| `es-us` | Spanish (United States) |
|
|
228
|
+
| `su` | Sundanese |
|
|
169
229
|
| `sw` | Swahili |
|
|
170
230
|
| `sv` | Swedish |
|
|
231
|
+
| `tl` | Tagalog |
|
|
171
232
|
| `ta` | Tamil |
|
|
233
|
+
| `te` | Telugu |
|
|
172
234
|
| `th` | Thai |
|
|
173
235
|
| `tr` | Turkish |
|
|
236
|
+
| `uk` | Ukrainian |
|
|
237
|
+
| `ur` | Urdu |
|
|
174
238
|
| `vi` | Vietnamese |
|
|
175
239
|
| `cy` | Welsh |
|
|
176
|
-
|
|
177
240
|
---
|
|
178
241
|
|
|
179
242
|
## 🔄 Migrating from `gtts`
|
|
@@ -205,4 +268,3 @@ MIT © [Qasim Ali](https://github.com/GlobalTechInfo)
|
|
|
205
268
|
Made with ❤️ — Thanks for using **gspeak**!
|
|
206
269
|
|
|
207
270
|
</div>
|
|
208
|
-
|
package/dist/src/gSpeak.js
CHANGED
|
@@ -90,7 +90,14 @@ class gSpeak {
|
|
|
90
90
|
_minimize(str, delim, max_size) {
|
|
91
91
|
if (str.length <= max_size)
|
|
92
92
|
return [str];
|
|
93
|
-
|
|
93
|
+
// Find the LAST delimiter within the first max_size chars. If the split would
|
|
94
|
+
// leave an empty head (idx === 0, no leading delimiter) or no delimiter at
|
|
95
|
+
// all, take a hard slice of max_size so we always make progress. This bounds
|
|
96
|
+
// recursion depth and avoids infinite recursion / stack overflow on long
|
|
97
|
+
// no-delimiter runs (CJK, URLs, long tokens).
|
|
98
|
+
const idx = str.lastIndexOf(delim, max_size - 1);
|
|
99
|
+
if (idx <= 0)
|
|
100
|
+
return [str.substring(0, max_size), ...this._minimize(str.substring(max_size), delim, max_size)];
|
|
94
101
|
return [str.substring(0, idx), ...this._minimize(str.substring(idx), delim, max_size)];
|
|
95
102
|
}
|
|
96
103
|
static get languages() {
|
package/dist/src/languages.js
CHANGED
|
@@ -1,20 +1,87 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const LANGUAGES = {
|
|
4
|
-
'af': 'Afrikaans',
|
|
5
|
-
'
|
|
6
|
-
'
|
|
7
|
-
'
|
|
8
|
-
'
|
|
9
|
-
'
|
|
10
|
-
'
|
|
11
|
-
'
|
|
12
|
-
'
|
|
13
|
-
'
|
|
14
|
-
'
|
|
15
|
-
'
|
|
16
|
-
'
|
|
17
|
-
'
|
|
18
|
-
'
|
|
4
|
+
'af': 'Afrikaans',
|
|
5
|
+
'sq': 'Albanian',
|
|
6
|
+
'am': 'Amharic',
|
|
7
|
+
'ar': 'Arabic',
|
|
8
|
+
'eu': 'Basque',
|
|
9
|
+
'bn': 'Bengali',
|
|
10
|
+
'bs': 'Bosnian',
|
|
11
|
+
'bg': 'Bulgarian',
|
|
12
|
+
'my': 'Burmese',
|
|
13
|
+
'ca': 'Catalan',
|
|
14
|
+
'zh': 'Chinese',
|
|
15
|
+
'zh-yue': 'Chinese (Cantonese)',
|
|
16
|
+
'zh-hk': 'Chinese (Cantonese, Hong Kong)',
|
|
17
|
+
'zh-cn': 'Chinese (Simplified)',
|
|
18
|
+
'zh-tw': 'Chinese (Traditional)',
|
|
19
|
+
'hr': 'Croatian',
|
|
20
|
+
'cs': 'Czech',
|
|
21
|
+
'da': 'Danish',
|
|
22
|
+
'nl': 'Dutch',
|
|
23
|
+
'en': 'English',
|
|
24
|
+
'en-au': 'English (Australia)',
|
|
25
|
+
'en-ca': 'English (Canada)',
|
|
26
|
+
'en-in': 'English (India)',
|
|
27
|
+
'en-ie': 'English (Ireland)',
|
|
28
|
+
'en-za': 'English (South Africa)',
|
|
29
|
+
'en-uk': 'English (United Kingdom)',
|
|
30
|
+
'en-us': 'English (United States)',
|
|
31
|
+
'et': 'Estonian',
|
|
32
|
+
'fil': 'Filipino',
|
|
33
|
+
'fi': 'Finnish',
|
|
34
|
+
'fr': 'French',
|
|
35
|
+
'fr-ca': 'French (Canada)',
|
|
36
|
+
'fr-fr': 'French (France)',
|
|
37
|
+
'gl': 'Galician',
|
|
38
|
+
'de': 'German',
|
|
39
|
+
'el': 'Greek',
|
|
40
|
+
'gu': 'Gujarati',
|
|
41
|
+
'ha': 'Hausa',
|
|
42
|
+
'iw': 'Hebrew',
|
|
43
|
+
'hi': 'Hindi',
|
|
44
|
+
'hu': 'Hungarian',
|
|
45
|
+
'is': 'Icelandic',
|
|
46
|
+
'id': 'Indonesian',
|
|
47
|
+
'it': 'Italian',
|
|
48
|
+
'ja': 'Japanese',
|
|
49
|
+
'jw': 'Javanese',
|
|
50
|
+
'kn': 'Kannada',
|
|
51
|
+
'km': 'Khmer',
|
|
52
|
+
'ko': 'Korean',
|
|
53
|
+
'la': 'Latin',
|
|
54
|
+
'lv': 'Latvian',
|
|
55
|
+
'lt': 'Lithuanian',
|
|
56
|
+
'ms': 'Malay',
|
|
57
|
+
'ml': 'Malayalam',
|
|
58
|
+
'mr': 'Marathi',
|
|
59
|
+
'ne': 'Nepali',
|
|
60
|
+
'no': 'Norwegian',
|
|
61
|
+
'pl': 'Polish',
|
|
62
|
+
'pt': 'Portuguese',
|
|
63
|
+
'pt-br': 'Portuguese (Brazil)',
|
|
64
|
+
'pt-pt': 'Portuguese (Portugal)',
|
|
65
|
+
'pa': 'Punjabi',
|
|
66
|
+
'ro': 'Romanian',
|
|
67
|
+
'ru': 'Russian',
|
|
68
|
+
'sr': 'Serbian',
|
|
69
|
+
'si': 'Sinhala',
|
|
70
|
+
'sk': 'Slovak',
|
|
71
|
+
'es': 'Spanish',
|
|
72
|
+
'es-es': 'Spanish (Spain)',
|
|
73
|
+
'es-us': 'Spanish (United States)',
|
|
74
|
+
'su': 'Sundanese',
|
|
75
|
+
'sw': 'Swahili',
|
|
76
|
+
'sv': 'Swedish',
|
|
77
|
+
'tl': 'Tagalog',
|
|
78
|
+
'ta': 'Tamil',
|
|
79
|
+
'te': 'Telugu',
|
|
80
|
+
'th': 'Thai',
|
|
81
|
+
'tr': 'Turkish',
|
|
82
|
+
'uk': 'Ukrainian',
|
|
83
|
+
'ur': 'Urdu',
|
|
84
|
+
'vi': 'Vietnamese',
|
|
85
|
+
'cy': 'Welsh',
|
|
19
86
|
};
|
|
20
87
|
exports.default = LANGUAGES;
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gspeak",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Google Text to Speech — a modern TypeScript rewrite of gtts with zero deprecated dependencies",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
7
7
|
"bin": {
|
|
8
|
-
"gspeak": "dist/bin/gspeak.js"
|
|
8
|
+
"gspeak": "./dist/bin/gspeak.js"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"dist"
|
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
"build": "tsc -p .",
|
|
16
16
|
"prepublishOnly": "npm run build",
|
|
17
17
|
"lint": "eslint src/**/*.ts bin/**/*.ts",
|
|
18
|
-
"test": "
|
|
18
|
+
"test": "vitest run",
|
|
19
|
+
"test:coverage": "vitest run --coverage",
|
|
20
|
+
"verify": "npm run build && npx ts-node verify-languages.ts"
|
|
19
21
|
},
|
|
20
22
|
"keywords": [
|
|
21
23
|
"google",
|
|
@@ -34,17 +36,16 @@
|
|
|
34
36
|
"yargs": "^18.0.0"
|
|
35
37
|
},
|
|
36
38
|
"devDependencies": {
|
|
37
|
-
"@types/mocha": "^10.0.0",
|
|
38
39
|
"@types/node": "^22.0.0",
|
|
39
40
|
"@types/yargs": "^17.0.0",
|
|
40
41
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
41
42
|
"@typescript-eslint/parser": "^8.0.0",
|
|
43
|
+
"@vitest/coverage-v8": "^4.1.0",
|
|
42
44
|
"eslint": "^9.0.0",
|
|
43
|
-
"mocha": "^11.0.0",
|
|
44
45
|
"rimraf": "^6.0.0",
|
|
45
|
-
"ts-node": "^10.9.2",
|
|
46
46
|
"typescript": "^5.0.0",
|
|
47
|
-
"typescript-eslint": "^8.0.0"
|
|
47
|
+
"typescript-eslint": "^8.0.0",
|
|
48
|
+
"vitest": "^4.1.0"
|
|
48
49
|
},
|
|
49
50
|
"publishConfig": {
|
|
50
51
|
"provenance": true
|
|
@@ -56,5 +57,26 @@
|
|
|
56
57
|
"bugs": {
|
|
57
58
|
"url": "https://github.com/GlobalTechInfo/gspeak/issues"
|
|
58
59
|
},
|
|
59
|
-
"homepage": "https://github.com/GlobalTechInfo/gspeak#readme"
|
|
60
|
+
"homepage": "https://github.com/GlobalTechInfo/gspeak#readme",
|
|
61
|
+
"vitest": {
|
|
62
|
+
"coverage": {
|
|
63
|
+
"provider": "v8",
|
|
64
|
+
"include": [
|
|
65
|
+
"src/**/*.ts"
|
|
66
|
+
],
|
|
67
|
+
"exclude": [
|
|
68
|
+
"src/index.ts"
|
|
69
|
+
],
|
|
70
|
+
"reporter": [
|
|
71
|
+
"text",
|
|
72
|
+
"html"
|
|
73
|
+
],
|
|
74
|
+
"thresholds": {
|
|
75
|
+
"lines": 100,
|
|
76
|
+
"functions": 100,
|
|
77
|
+
"branches": 100,
|
|
78
|
+
"statements": 100
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
60
82
|
}
|