gspeak 0.0.4 → 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/README.md +25 -4
- package/dist/src/gSpeak.js +8 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,11 +8,12 @@
|
|
|
8
8
|
|
|
9
9
|
A TypeScript rewrite of [gtts](https://www.npmjs.com/package/gtts) — drop-in compatible.
|
|
10
10
|
|
|
11
|
-
[](https://github.com/GlobalTechInfo/gspeak/blob/main/LICENSE)
|
|
12
11
|
[](https://codecov.io/gh/GlobalTechInfo/gspeak)
|
|
13
|
-
[](https://npmjs.com/package/gspeak)
|
|
14
13
|
[](https://www.codefactor.io/repository/github/GlobalTechInfo/gspeak)
|
|
15
14
|
[](https://npmjs.com/package/gspeak)
|
|
15
|
+
[](https://jsr.io/@globaltech/gspeak)
|
|
16
|
+
|
|
16
17
|
|
|
17
18
|
</div>
|
|
18
19
|
|
|
@@ -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
|
---
|
|
@@ -116,6 +126,17 @@ const tts = new gSpeak('Hello', 'en', true) // 3rd param enables debug logging
|
|
|
116
126
|
|
|
117
127
|
---
|
|
118
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
|
+
|
|
119
140
|
## 🖥️ CLI
|
|
120
141
|
|
|
121
142
|
```bash
|
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/package.json
CHANGED