echogarden 3.2.0 → 3.4.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 +5 -0
- package/dist/api/Synthesis.d.ts.map +1 -1
- package/dist/api/Synthesis.js +31 -21
- package/dist/api/Synthesis.js.map +1 -1
- package/dist/nlp/TextNormalizer.js +1 -1
- package/dist/nlp/TextNormalizer.js.map +1 -1
- package/dist/synthesis/EspeakTTS.d.ts.map +1 -1
- package/dist/synthesis/EspeakTTS.js +20 -5
- package/dist/synthesis/EspeakTTS.js.map +1 -1
- package/dist/utilities/Timer.d.ts +7 -3
- package/dist/utilities/Timer.d.ts.map +1 -1
- package/dist/utilities/Timer.js +42 -30
- package/dist/utilities/Timer.js.map +1 -1
- package/docs/API.md +51 -34
- package/docs/CLI.md +41 -6
- package/docs/Contributing.md +1 -1
- package/docs/Development.md +22 -18
- package/docs/Engines.md +0 -1
- package/docs/Licenses.md +2 -0
- package/docs/Options.md +56 -4
- package/docs/Releases.md +45 -14
- package/docs/Server.md +14 -5
- package/docs/Tasklist.md +37 -1
- package/docs/Technical.md +1 -0
- package/package.json +16 -14
- package/src/api/Synthesis.ts +39 -27
- package/src/nlp/TextNormalizer.ts +1 -2
- package/src/synthesis/EspeakTTS.ts +21 -6
- package/src/utilities/Timer.ts +57 -37
- package/tsconfig.json +51 -53
- package/dist/encodings/HtmlEscape.d.ts +0 -2
- package/dist/encodings/HtmlEscape.d.ts.map +0 -1
- package/dist/encodings/HtmlEscape.js +0 -30
- package/dist/encodings/HtmlEscape.js.map +0 -1
- package/dist/encodings/LEB128.d.ts +0 -2
- package/dist/encodings/LEB128.d.ts.map +0 -1
- package/dist/encodings/LEB128.js +0 -2
- package/dist/encodings/LEB128.js.map +0 -1
- package/dist/utilities/StringBuilder.d.ts +0 -11
- package/dist/utilities/StringBuilder.d.ts.map +0 -1
- package/dist/utilities/StringBuilder.js +0 -39
- package/dist/utilities/StringBuilder.js.map +0 -1
package/dist/utilities/Timer.js
CHANGED
|
@@ -1,61 +1,73 @@
|
|
|
1
|
-
import { logToStderr
|
|
1
|
+
import { logToStderr } from './Utilities.js';
|
|
2
2
|
export class Timer {
|
|
3
|
+
logger;
|
|
3
4
|
startTime = 0;
|
|
4
|
-
constructor() {
|
|
5
|
+
constructor(logger) {
|
|
6
|
+
if (logger) {
|
|
7
|
+
this.logger = logger;
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
this.logger = logToStderr;
|
|
11
|
+
}
|
|
5
12
|
this.restart();
|
|
6
13
|
}
|
|
14
|
+
// Resets the timer to the current time.
|
|
7
15
|
restart() {
|
|
8
16
|
this.startTime = Timer.currentTime;
|
|
9
17
|
}
|
|
18
|
+
// Elapsed time in milliseconds (monotonic where supported).
|
|
10
19
|
get elapsedTime() {
|
|
11
|
-
// Elapsed time (milliseconds)
|
|
12
20
|
return Timer.currentTime - this.startTime;
|
|
13
21
|
}
|
|
22
|
+
// Elapsed time in seconds.
|
|
14
23
|
get elapsedTimeSeconds() {
|
|
15
|
-
// Elapsed time (seconds)
|
|
16
24
|
return this.elapsedTime / 1000;
|
|
17
25
|
}
|
|
26
|
+
// Returns elapsed ms and restarts the timer.
|
|
18
27
|
getElapsedTimeAndRestart() {
|
|
19
|
-
const
|
|
28
|
+
const elapsed = this.elapsedTime;
|
|
20
29
|
this.restart();
|
|
21
|
-
return
|
|
30
|
+
return elapsed;
|
|
22
31
|
}
|
|
32
|
+
// Logs elapsed time (in ms) and restarts the timer.
|
|
23
33
|
logAndRestart(title, timePrecision = 3) {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
const message = `${title}: ${roundToDigits(elapsedTime, timePrecision)}ms`;
|
|
27
|
-
logToStderr(message);
|
|
28
|
-
//
|
|
34
|
+
const elapsedMs = this.elapsedTime;
|
|
35
|
+
this.logger(`${title}: ${roundToDigits(elapsedMs, timePrecision)}ms`);
|
|
29
36
|
this.restart();
|
|
30
|
-
return
|
|
37
|
+
return elapsedMs;
|
|
31
38
|
}
|
|
39
|
+
// Current high-resolution timestamp in milliseconds since Unix epoch.
|
|
32
40
|
static get currentTime() {
|
|
33
|
-
|
|
34
|
-
this.createTimestampFunction();
|
|
35
|
-
}
|
|
36
|
-
return this.getTimestamp();
|
|
41
|
+
return this.timestampFunc();
|
|
37
42
|
}
|
|
43
|
+
// Current timestamp in microseconds (integer).
|
|
38
44
|
static get microsecondTimestamp() {
|
|
39
45
|
return Math.floor(Timer.currentTime * 1000);
|
|
40
46
|
}
|
|
47
|
+
// Clock setup
|
|
48
|
+
static timestampFunc = Timer.createTimestampFunction();
|
|
41
49
|
static createTimestampFunction() {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return baseTimestamp + nodeTimeMilliseconds;
|
|
48
|
-
};
|
|
49
|
-
baseTimestamp = Date.now() - this.getTimestamp();
|
|
50
|
+
const g = globalThis;
|
|
51
|
+
// 1. Modern standard: performance.now() (Browsers & Node 16+)
|
|
52
|
+
if (typeof g.performance === 'object' && typeof g.performance.now === 'function') {
|
|
53
|
+
const timeOrigin = g.performance.timeOrigin ?? (Date.now() - g.performance.now());
|
|
54
|
+
return () => timeOrigin + g.performance.now();
|
|
50
55
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
// 2. Node.js high resolution timer (BigInt variant, Node 10.4+)
|
|
57
|
+
if (typeof g.process === 'object' && typeof g.process.hrtime === 'function') {
|
|
58
|
+
const startNs = g.process.hrtime.bigint();
|
|
59
|
+
const epochBaseMs = Date.now() - (Number(startNs) / 1e6);
|
|
60
|
+
return () => epochBaseMs + Number(g.process.hrtime.bigint()) / 1e6;
|
|
54
61
|
}
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
// 3. Last-resort fallback (non-monotonic)
|
|
63
|
+
if (typeof Date.now === 'function') {
|
|
64
|
+
return () => Date.now();
|
|
57
65
|
}
|
|
66
|
+
return () => new Date().getTime();
|
|
58
67
|
}
|
|
59
|
-
|
|
68
|
+
}
|
|
69
|
+
export function roundToDigits(value, digits) {
|
|
70
|
+
const factor = 10 ** digits;
|
|
71
|
+
return Math.round(value * factor) / factor;
|
|
60
72
|
}
|
|
61
73
|
//# sourceMappingURL=Timer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Timer.js","sourceRoot":"","sources":["../../src/utilities/Timer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"Timer.js","sourceRoot":"","sources":["../../src/utilities/Timer.ts"],"names":[],"mappings":"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"}
|
package/docs/API.md
CHANGED
|
@@ -3,14 +3,17 @@
|
|
|
3
3
|
**Note**: the API is not fully stable yet. It may change at every new version. There are many methods, types and internal data structures that are not yet exposed.
|
|
4
4
|
|
|
5
5
|
### Importing as a Node.js module
|
|
6
|
+
|
|
6
7
|
To import the `echograden` package as a Node.js module:
|
|
7
8
|
|
|
8
9
|
Install as a dependency in your project:
|
|
10
|
+
|
|
9
11
|
```bash
|
|
10
12
|
npm install echogarden
|
|
11
13
|
```
|
|
12
14
|
|
|
13
15
|
Import with:
|
|
16
|
+
|
|
14
17
|
```ts
|
|
15
18
|
import * as Echogarden from 'echogarden'
|
|
16
19
|
```
|
|
@@ -18,6 +21,7 @@ import * as Echogarden from 'echogarden'
|
|
|
18
21
|
All methods, properties and arguments have TypeScript type information. You can use it to get more detailed and up-to-date type information that may not be covered here.
|
|
19
22
|
|
|
20
23
|
### Related pages
|
|
24
|
+
|
|
21
25
|
* [Options reference](Options.md)
|
|
22
26
|
* [List of all supported engines](Engines.md)
|
|
23
27
|
* [Quick guide to the command line interface](CLI.md)
|
|
@@ -32,10 +36,10 @@ Synthesizes the given input.
|
|
|
32
36
|
* `input`: text to synthesize, can be a `string`, or a `string[]`. When given an array of strings, the elements of the array would be seen as predefined segments (this is useful if you would like to have more control over how segments are split, or your input has a special format requiring a custom splitting method).
|
|
33
37
|
* `options`: synthesis options object
|
|
34
38
|
* `callbacks`: an object containing the optional properties:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
* `onSegment`: a callback that is called whenever a segment has been synthesized
|
|
40
|
+
* `onSentence`: a callback that is called whenever a sentence has been synthesized
|
|
41
|
+
* `abortSignal`: an abort signal (`AbortSignal`)
|
|
42
|
+
* `logLevel`: log level (`string`)
|
|
39
43
|
|
|
40
44
|
#### Returns (via promise):
|
|
41
45
|
|
|
@@ -48,13 +52,16 @@ Synthesizes the given input.
|
|
|
48
52
|
```
|
|
49
53
|
|
|
50
54
|
`audio` may either be a
|
|
55
|
+
|
|
51
56
|
* `RawAudio` object, which is a structure containing the sample rate and raw 32-bit float channels:
|
|
57
|
+
|
|
52
58
|
```ts
|
|
53
59
|
{
|
|
54
60
|
sampleRate: number
|
|
55
61
|
channels: Float32Array[]
|
|
56
62
|
}
|
|
57
63
|
```
|
|
64
|
+
|
|
58
65
|
* A `Uint8Array` containing the audio in encoded form, in the case a particular codec was specified in the `outputAudioFormat.codec` option.
|
|
59
66
|
|
|
60
67
|
#### Segment and sentence event callbacks
|
|
@@ -62,15 +69,19 @@ Synthesizes the given input.
|
|
|
62
69
|
You can optionally pass two `async` callbacks to `synthesize`, `onSegment` and `onSentence`.
|
|
63
70
|
|
|
64
71
|
For example:
|
|
72
|
+
|
|
65
73
|
```ts
|
|
66
74
|
async function onSegment(data: SynthesisSegmentEventData) {
|
|
67
75
|
console.log(data.transcript)
|
|
68
76
|
}
|
|
69
77
|
|
|
70
|
-
const { audio } = await Echogarden.synthesize(
|
|
78
|
+
const { audio } = await Echogarden.synthesize('Hello World!', {
|
|
79
|
+
engine: 'espeak',
|
|
80
|
+
}, onSegment)
|
|
71
81
|
```
|
|
72
82
|
|
|
73
83
|
`SynthesisSegmentEventData` is an object with the structure:
|
|
84
|
+
|
|
74
85
|
```ts
|
|
75
86
|
{
|
|
76
87
|
index: number // Index of part
|
|
@@ -92,8 +103,8 @@ Requests a list of voices for a particular engine.
|
|
|
92
103
|
|
|
93
104
|
* `options`: voice list request options object
|
|
94
105
|
* `callbacks`: an object containing the optional properties:
|
|
95
|
-
|
|
96
|
-
|
|
106
|
+
* `abortSignal`: an abort signal (`AbortSignal`)
|
|
107
|
+
* `logLevel`: log level (`string`)
|
|
97
108
|
|
|
98
109
|
#### Returns (via promise):
|
|
99
110
|
|
|
@@ -113,8 +124,8 @@ Applies speech recognition to the input.
|
|
|
113
124
|
* `input`: can be an audio file path (`string`), encoded audio (`Buffer` or `Uint8array`) or a raw audio object (`RawAudio`)
|
|
114
125
|
* `options`: recognition options object
|
|
115
126
|
* `callbacks`: an object containing the optional properties:
|
|
116
|
-
|
|
117
|
-
|
|
127
|
+
* `abortSignal`: an abort signal (`AbortSignal`)
|
|
128
|
+
* `logLevel`: log level (`string`)
|
|
118
129
|
|
|
119
130
|
#### Returns (via promise):
|
|
120
131
|
|
|
@@ -143,8 +154,8 @@ Aligns input audio with the given transcript.
|
|
|
143
154
|
* `transcript`: the transcript to align to
|
|
144
155
|
* `options`: alignment options object
|
|
145
156
|
* `callbacks`: an object containing the optional properties:
|
|
146
|
-
|
|
147
|
-
|
|
157
|
+
* `abortSignal`: an abort signal (`AbortSignal`)
|
|
158
|
+
* `logLevel`: log level (`string`)
|
|
148
159
|
|
|
149
160
|
#### Returns (via promise):
|
|
150
161
|
|
|
@@ -171,10 +182,11 @@ Translates speech audio directly to a transcript in a different language (only E
|
|
|
171
182
|
* `input`: can be an audio file path (`string`), encoded audio (`Buffer` or `Uint8array`) or a raw audio object (`RawAudio`)
|
|
172
183
|
* `options`: speech translation options object
|
|
173
184
|
* `callbacks`: an object containing the optional properties:
|
|
174
|
-
|
|
175
|
-
|
|
185
|
+
* `abortSignal`: an abort signal (`AbortSignal`)
|
|
186
|
+
* `logLevel`: log level (`string`)
|
|
176
187
|
|
|
177
188
|
#### Returns (via promise):
|
|
189
|
+
|
|
178
190
|
```ts
|
|
179
191
|
{
|
|
180
192
|
transcript: string
|
|
@@ -199,10 +211,11 @@ Translates text to text.
|
|
|
199
211
|
* `input`: string
|
|
200
212
|
* `options`: text translation options object
|
|
201
213
|
* `callbacks`: an object containing the optional properties:
|
|
202
|
-
|
|
203
|
-
|
|
214
|
+
* `abortSignal`: an abort signal (`AbortSignal`)
|
|
215
|
+
* `logLevel`: log level (`string`)
|
|
204
216
|
|
|
205
217
|
#### Returns (via promise):
|
|
218
|
+
|
|
206
219
|
```ts
|
|
207
220
|
{
|
|
208
221
|
text: string
|
|
@@ -227,8 +240,8 @@ Aligns input audio with the given translated transcript.
|
|
|
227
240
|
* `translatedTranscript`: the translated transcript to align to
|
|
228
241
|
* `options`: translation alignment options object
|
|
229
242
|
* `callbacks`: an object containing the optional properties:
|
|
230
|
-
|
|
231
|
-
|
|
243
|
+
* `abortSignal`: an abort signal (`AbortSignal`)
|
|
244
|
+
* `logLevel`: log level (`string`)
|
|
232
245
|
|
|
233
246
|
#### Returns (via promise):
|
|
234
247
|
|
|
@@ -256,8 +269,8 @@ Aligns input audio to both the native language transcript a translated one.
|
|
|
256
269
|
* `translatedTranscript`: the translated transcript to align to
|
|
257
270
|
* `options`: transcript and translation alignment options object
|
|
258
271
|
* `callbacks`: an object containing the optional properties:
|
|
259
|
-
|
|
260
|
-
|
|
272
|
+
* `abortSignal`: an abort signal (`AbortSignal`)
|
|
273
|
+
* `logLevel`: log level (`string`)
|
|
261
274
|
|
|
262
275
|
#### Returns (via promise):
|
|
263
276
|
|
|
@@ -289,8 +302,8 @@ Aligns given timeline with its translated transcript.
|
|
|
289
302
|
* `translatedTranscript`: the translated transcript to align to
|
|
290
303
|
* `options`: timeline translation alignment options object
|
|
291
304
|
* `callbacks`: an object containing the optional properties:
|
|
292
|
-
|
|
293
|
-
|
|
305
|
+
* `abortSignal`: an abort signal (`AbortSignal`)
|
|
306
|
+
* `logLevel`: log level (`string`)
|
|
294
307
|
|
|
295
308
|
#### Returns (via promise):
|
|
296
309
|
|
|
@@ -315,10 +328,11 @@ Detects language of spoken audio.
|
|
|
315
328
|
* `input`: can be an audio file path (`string`), encoded audio (`Buffer` or `Uint8array`) or a raw audio object (`RawAudio`)
|
|
316
329
|
* `options`: speech language detection options object
|
|
317
330
|
* `callbacks`: an object containing the optional properties:
|
|
318
|
-
|
|
319
|
-
|
|
331
|
+
* `abortSignal`: an abort signal (`AbortSignal`)
|
|
332
|
+
* `logLevel`: log level (`string`)
|
|
320
333
|
|
|
321
334
|
#### Returns (via promise):
|
|
335
|
+
|
|
322
336
|
```ts
|
|
323
337
|
{
|
|
324
338
|
detectedLanguage: string
|
|
@@ -334,10 +348,11 @@ Detects language of text.
|
|
|
334
348
|
* `input`: input text as `string`
|
|
335
349
|
* `options`: text language detection options object
|
|
336
350
|
* `callbacks`: an object containing the optional properties:
|
|
337
|
-
|
|
338
|
-
|
|
351
|
+
* `abortSignal`: an abort signal (`AbortSignal`)
|
|
352
|
+
* `logLevel`: log level (`string`)
|
|
339
353
|
|
|
340
354
|
#### Returns (via promise):
|
|
355
|
+
|
|
341
356
|
```ts
|
|
342
357
|
{
|
|
343
358
|
detectedLanguage: string
|
|
@@ -355,10 +370,11 @@ Detects voice activity in audio (non-real-time).
|
|
|
355
370
|
* `input`: can be an audio file path (`string`), encoded audio (`Buffer` or `Uint8array`) or a raw audio object (`RawAudio`)
|
|
356
371
|
* `options`: voice activity detection options object
|
|
357
372
|
* `callbacks`: an object containing the optional properties:
|
|
358
|
-
|
|
359
|
-
|
|
373
|
+
* `abortSignal`: an abort signal (`AbortSignal`)
|
|
374
|
+
* `logLevel`: log level (`string`)
|
|
360
375
|
|
|
361
376
|
#### Returns (via promise):
|
|
377
|
+
|
|
362
378
|
```ts
|
|
363
379
|
{
|
|
364
380
|
timeline: Timeline
|
|
@@ -374,10 +390,11 @@ Tries to reduce background noise in spoken audio.
|
|
|
374
390
|
* `input`: can be an audio file path (`string`), encoded audio (`Buffer` or `Uint8array`) or a raw audio object (`RawAudio`)
|
|
375
391
|
* `options`: denoising options object
|
|
376
392
|
* `callbacks`: an object containing the optional properties:
|
|
377
|
-
|
|
378
|
-
|
|
393
|
+
* `abortSignal`: an abort signal (`AbortSignal`)
|
|
394
|
+
* `logLevel`: log level (`string`)
|
|
379
395
|
|
|
380
396
|
#### Returns (via promise):
|
|
397
|
+
|
|
381
398
|
```ts
|
|
382
399
|
{
|
|
383
400
|
denoisedAudio: RawAudio
|
|
@@ -393,10 +410,11 @@ Attempts to isolate an individual [audio stem](https://en.wikipedia.org/wiki/Ste
|
|
|
393
410
|
* `input`: can be an audio file path (`string`), encoded audio (`Buffer` or `Uint8array`) or a raw audio object (`RawAudio`)
|
|
394
411
|
* `options`: source separation options object
|
|
395
412
|
* `callbacks`: an object containing the optional properties:
|
|
396
|
-
|
|
397
|
-
|
|
413
|
+
* `abortSignal`: an abort signal (`AbortSignal`)
|
|
414
|
+
* `logLevel`: log level (`string`)
|
|
398
415
|
|
|
399
416
|
#### Returns (via promise):
|
|
417
|
+
|
|
400
418
|
```ts
|
|
401
419
|
{
|
|
402
420
|
inputRawAudio: RawAudio
|
|
@@ -414,8 +432,8 @@ Converts a timeline to subtitles.
|
|
|
414
432
|
* `timeline`: timeline object
|
|
415
433
|
* `options`: subtitles configuration object
|
|
416
434
|
* `callbacks`: an object containing the optional properties:
|
|
417
|
-
|
|
418
|
-
|
|
435
|
+
* `abortSignal`: an abort signal (`AbortSignal`)
|
|
436
|
+
* `logLevel`: log level (`string`)
|
|
419
437
|
|
|
420
438
|
#### Returns:
|
|
421
439
|
|
|
@@ -441,7 +459,6 @@ Sets a global option.
|
|
|
441
459
|
|
|
442
460
|
See the [options reference](Options.md) for more details about the available global options.
|
|
443
461
|
|
|
444
|
-
|
|
445
462
|
### `getGlobalOption(key)`
|
|
446
463
|
|
|
447
464
|
Gets a global option.
|
package/docs/CLI.md
CHANGED
|
@@ -9,10 +9,12 @@ echogarden [operation] [one or more inputs..] [one or more outputs...] [options.
|
|
|
9
9
|
Each operation can accept one or more options, in the form `--[optionName]=[value]` (The `=` is required).
|
|
10
10
|
|
|
11
11
|
**Keyboard shortcuts**:
|
|
12
|
+
|
|
12
13
|
* While the program is running, you can press `esc` to exit immediately
|
|
13
14
|
* When audio is playing, you can press `enter` to skip it, `space` to pause/resume, `right` to skip 1 second forward, and `left` to skip 1 second backwards
|
|
14
15
|
|
|
15
16
|
### Related pages
|
|
17
|
+
|
|
16
18
|
* [Options reference](Options.md)
|
|
17
19
|
* [List of all supported engines](Engines.md)
|
|
18
20
|
|
|
@@ -21,41 +23,49 @@ Each operation can accept one or more options, in the form `--[optionName]=[valu
|
|
|
21
23
|
**Task**: Given a text file, synthesize spoken audio for it.
|
|
22
24
|
|
|
23
25
|
This would synthesize "Hello World" and play the result in the terminal:
|
|
26
|
+
|
|
24
27
|
```bash
|
|
25
28
|
echogarden speak "Hello world!"
|
|
26
29
|
```
|
|
27
30
|
|
|
28
31
|
If no language is specified, it would attempt to detect it. This usually works better for longer texts, and may misidentify shorter ones. To ensure the right language is selected, you can specify the language explicitly:
|
|
32
|
+
|
|
29
33
|
```bash
|
|
30
34
|
echogarden speak "Hello world!" --language=en
|
|
31
35
|
```
|
|
32
36
|
|
|
33
37
|
This would save the resulting audio to `result.mp3`:
|
|
38
|
+
|
|
34
39
|
```bash
|
|
35
40
|
echogarden speak "Hello world!" result.mp3 --language=en
|
|
36
41
|
```
|
|
37
42
|
|
|
38
43
|
`speak-file` synthesizes text loaded from a textual file, which can have the extensions `txt`, `html`, `xml`, `ssml`, `srt`, `vtt`:
|
|
44
|
+
|
|
39
45
|
```bash
|
|
40
46
|
echogarden speak-file text.txt result.mp3 --language=en
|
|
41
47
|
```
|
|
42
48
|
|
|
43
49
|
You can specify an engine using the `--engine` option (a full list of engines can be found [here](Engines.md)). This would set the synthesis engine to `pico` (SVOX Pico):
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
echogarden speak-file text.txt result.mp3 --language=en --engine=pico
|
|
53
|
+
```
|
|
47
54
|
|
|
48
55
|
The CLI supports multiple output files. This would synthesize a text file, and save the resulting audio in both `result.mp3` and `result.wav`, as well as subtitles in `result.srt`:
|
|
56
|
+
|
|
49
57
|
```bash
|
|
50
58
|
echogarden speak-file text.txt result.mp3 result.wav result.srt --engine=kokoro --speed=1.1
|
|
51
59
|
```
|
|
52
60
|
|
|
53
61
|
Synthesize a web page (it will try to extract its main article parts and omit the rest):
|
|
62
|
+
|
|
54
63
|
```bash
|
|
55
64
|
echogarden speak-url https://example.com/hola
|
|
56
65
|
```
|
|
57
66
|
|
|
58
67
|
Synthesize a Wikipedia article, in any of its language editions:
|
|
68
|
+
|
|
59
69
|
```bash
|
|
60
70
|
echogarden speak-wikipedia "Psychologie" --language=fr
|
|
61
71
|
```
|
|
@@ -65,11 +75,13 @@ echogarden speak-wikipedia "Psychologie" --language=fr
|
|
|
65
75
|
**Task**: Given an audio recording containing speech, find a textual transcription that best matches it.
|
|
66
76
|
|
|
67
77
|
This would transcribe the audio file `speech.mp3`, and then play the audio, along with the recognized text, in the terminal:
|
|
78
|
+
|
|
68
79
|
```bash
|
|
69
80
|
echogarden transcribe speech.mp3
|
|
70
81
|
```
|
|
71
82
|
|
|
72
83
|
This would transcribe the audio file `speech.mp3` and store the resulting transcription in `result.txt`, subtitles in `result.srt`, and a full timeline tree in `result.json`:
|
|
84
|
+
|
|
73
85
|
```bash
|
|
74
86
|
echogarden transcribe speech.mp3 result.txt result.srt result.json
|
|
75
87
|
```
|
|
@@ -79,11 +91,13 @@ echogarden transcribe speech.mp3 result.txt result.srt result.json
|
|
|
79
91
|
**Task**: Given an audio file and its transcript, try to approximate the timing of the start and end of each spoken word (and its subparts).
|
|
80
92
|
|
|
81
93
|
This would align the audio file `speech.mp3` with the transcript provided in `transcript.txt`, and would play the synchronized result in the terminal:
|
|
94
|
+
|
|
82
95
|
```bash
|
|
83
96
|
echogarden align speech.mp3 transcript.txt
|
|
84
97
|
```
|
|
85
98
|
|
|
86
99
|
This would align the audio file `speech.mp3` with the transcript provided in `transcript.txt`, and store the resulting subtitles in `result.srt`, and a full timeline tree in `result.json`:
|
|
100
|
+
|
|
87
101
|
```bash
|
|
88
102
|
echogarden align speech.mp3 transcript.txt result.srt result.json
|
|
89
103
|
```
|
|
@@ -93,11 +107,13 @@ echogarden align speech.mp3 transcript.txt result.srt result.json
|
|
|
93
107
|
**Task**: Given an audio file containing speech in one language, transcribe it to a second language. The translated transcript should be generated directly from the speech itself, without an intermediate textual translation step.
|
|
94
108
|
|
|
95
109
|
This will detect the spoken language, apply speech translation to English, and play the original audio, synced with the translated transcript:
|
|
110
|
+
|
|
96
111
|
```bash
|
|
97
112
|
echogarden translate-speech speech.mp3
|
|
98
113
|
```
|
|
99
114
|
|
|
100
115
|
To specify the source and target languages explicitly, use the `sourceLanguage` and `targetLanguage` options:
|
|
116
|
+
|
|
101
117
|
```bash
|
|
102
118
|
echogarden translate-speech speech.mp3 translation.txt --sourceLanguage=es --targetLanguage=en
|
|
103
119
|
```
|
|
@@ -107,19 +123,23 @@ echogarden translate-speech speech.mp3 translation.txt --sourceLanguage=es --tar
|
|
|
107
123
|
## Speech-to-translated-transcript alignment
|
|
108
124
|
|
|
109
125
|
### Direct alignment (English target only)
|
|
126
|
+
|
|
110
127
|
**Task**: Given a spoken audio file and its English translated transcript, try to approximate the timing of the start and end of each translated word.
|
|
111
128
|
|
|
112
129
|
This would align the audio file `dutch-speech.mp3` with the translated transcript provided in `english-translation.txt`, and would play the synchronized result in the terminal:
|
|
130
|
+
|
|
113
131
|
```bash
|
|
114
132
|
echogarden align-translation dutch-speech.mp3 english-translation.txt
|
|
115
133
|
```
|
|
116
134
|
|
|
117
135
|
This would align the audio file `dutch-speech.mp3` with the translated transcript provided in `english-translation.txt`, and store the resulting subtitles in `result.srt`, and a full timeline tree in `result.json`:
|
|
136
|
+
|
|
118
137
|
```bash
|
|
119
138
|
echogarden align-translation dutch-speech.mp3 english-translation.txt result.srt result.json
|
|
120
139
|
```
|
|
121
140
|
|
|
122
141
|
### Two-stage alignment (any of 96 source and target languages, combined stages)
|
|
142
|
+
|
|
123
143
|
**Task**: Given a spoken audio file, its transcript, and its translated transcript, try to approximate the timing of the start and end of each translated word.
|
|
124
144
|
|
|
125
145
|
This would align the audio file `dutch-speech.mp3` with the Dutch (native language) transcript provided in `dutch-transcript.txt` and the translated transcript provided in `russian-translation.txt`, and would play the synchronized result in the terminal:
|
|
@@ -153,6 +173,7 @@ This manual two-step approach allows to reuse the already-aligned transcript in
|
|
|
153
173
|
**Stage 1**:
|
|
154
174
|
|
|
155
175
|
Align the audio with its native language transcript, to produce a timeline in the native language:
|
|
176
|
+
|
|
156
177
|
```bash
|
|
157
178
|
echogarden align dutch-speech.mp3 dutch-transcript.txt dutch-timeline.json
|
|
158
179
|
```
|
|
@@ -167,22 +188,24 @@ echogarden align-timeline-translation dutch-timeline.json russian-transcript.txt
|
|
|
167
188
|
|
|
168
189
|
(`--audio` is only used for previewing the result in the terminal. Otherwise, it is not necessary)
|
|
169
190
|
|
|
170
|
-
|
|
171
191
|
## Language detection
|
|
172
192
|
|
|
173
193
|
**Task**: Given audio or textual input, try to identify which language it is spoken or written in.
|
|
174
194
|
|
|
175
195
|
Try to identify the language of an audio file containing speech, and print the probabilities to the terminal:
|
|
196
|
+
|
|
176
197
|
```bash
|
|
177
198
|
echogarden detect-speech-language speech.mp3
|
|
178
199
|
```
|
|
179
200
|
|
|
180
201
|
Try to identify the language of a text file, and print the probabilities to the terminal:
|
|
202
|
+
|
|
181
203
|
```bash
|
|
182
204
|
echogarden detect-text-language story.txt
|
|
183
205
|
```
|
|
184
206
|
|
|
185
207
|
Try to identify the language of a text file, and store the detailed probabilities in a JSON file:
|
|
208
|
+
|
|
186
209
|
```bash
|
|
187
210
|
echogarden detect-text-language story.txt detection-results.json
|
|
188
211
|
```
|
|
@@ -192,11 +215,13 @@ echogarden detect-text-language story.txt detection-results.json
|
|
|
192
215
|
**Task**: Given an audio file, try to classify which parts of the audio contain speech, and which don't.
|
|
193
216
|
|
|
194
217
|
This would apply VAD and play the audio, synchronized with `speech` and `nonspeech` indicators, printed to the terminal.
|
|
218
|
+
|
|
195
219
|
```bash
|
|
196
220
|
echogarden detect-voice-activity speech.mp3
|
|
197
221
|
```
|
|
198
222
|
|
|
199
223
|
This would apply VAD and store the results in a timeline JSON file.
|
|
224
|
+
|
|
200
225
|
```bash
|
|
201
226
|
echogarden detect-voice-activity speech.mp3 timeline.json
|
|
202
227
|
```
|
|
@@ -206,11 +231,13 @@ echogarden detect-voice-activity speech.mp3 timeline.json
|
|
|
206
231
|
**Task**: Attempt to reduce the amount of background noise in a spoken recording.
|
|
207
232
|
|
|
208
233
|
This would apply denoising and play the denoised audio:
|
|
234
|
+
|
|
209
235
|
```bash
|
|
210
236
|
echogarden denoise speech.mp3
|
|
211
237
|
```
|
|
212
238
|
|
|
213
239
|
This would apply denoising, and save the denoised audio to a file:
|
|
240
|
+
|
|
214
241
|
```bash
|
|
215
242
|
echogarden denoise speech.mp3 denoised-speech.mp3
|
|
216
243
|
```
|
|
@@ -220,16 +247,19 @@ echogarden denoise speech.mp3 denoised-speech.mp3
|
|
|
220
247
|
**Task**: Try to isolate a vocal track (or other type of track, depending on model used), from the audio.
|
|
221
248
|
|
|
222
249
|
This would apply source separation and play the isolated audio:
|
|
250
|
+
|
|
223
251
|
```bash
|
|
224
252
|
echogarden isolate voice-with-music.mp3
|
|
225
253
|
```
|
|
226
254
|
|
|
227
255
|
This would apply source separation, and save both the isolated and background audio:
|
|
256
|
+
|
|
228
257
|
```bash
|
|
229
258
|
echogarden isolate voice-with-music.mp3 voice-isolated.mp3
|
|
230
259
|
```
|
|
231
260
|
|
|
232
261
|
Written files would be:
|
|
262
|
+
|
|
233
263
|
```
|
|
234
264
|
voice-isolated.mp3
|
|
235
265
|
voice-isolated.background.mp3
|
|
@@ -256,12 +286,15 @@ echogarden align speech.mp3 transcript.txt parts/[segment].m4a parts/[segment].s
|
|
|
256
286
|
Splitting based on sentences, using a `[sentence]` placeholder, is currently on the to-do list. Please let me know if you find this feature important, and I'll prioritize it.
|
|
257
287
|
|
|
258
288
|
## Audio playback
|
|
289
|
+
|
|
259
290
|
By default, audio isn't played in the terminal when an output file is specified, you can override this behavior by adding `--play`:
|
|
291
|
+
|
|
260
292
|
```bash
|
|
261
293
|
echogarden speak-file text.txt result.mp3 --play
|
|
262
294
|
```
|
|
263
295
|
|
|
264
296
|
Or similarly prevent playback using `--no-play`:
|
|
297
|
+
|
|
265
298
|
```bash
|
|
266
299
|
echogarden transcribe speech.mp3 --no-play
|
|
267
300
|
```
|
|
@@ -281,6 +314,7 @@ When a file named `echogarden.config` is found at the current directory, it will
|
|
|
281
314
|
The configuration file format is simple and has a dedicated section for each command (all `speak-` commands are grouped together under `speak`), `global` section for global API options, and `cli` for common CLI options. `#` is used as a comment character.
|
|
282
315
|
|
|
283
316
|
Example:
|
|
317
|
+
|
|
284
318
|
```conf
|
|
285
319
|
[global]
|
|
286
320
|
|
|
@@ -324,6 +358,7 @@ whisper.temperature = 0.15
|
|
|
324
358
|
You can also use a JSON configuration file format instead, if preferred.
|
|
325
359
|
|
|
326
360
|
Name your file `echogarden.config.json`:
|
|
361
|
+
|
|
327
362
|
```json
|
|
328
363
|
{
|
|
329
364
|
"speak": {
|
|
@@ -342,6 +377,7 @@ Name your file `echogarden.config.json`:
|
|
|
342
377
|
```
|
|
343
378
|
|
|
344
379
|
Flattened property names are also accepted:
|
|
380
|
+
|
|
345
381
|
```json
|
|
346
382
|
{
|
|
347
383
|
"transcribe": {
|
|
@@ -351,7 +387,6 @@ Flattened property names are also accepted:
|
|
|
351
387
|
}
|
|
352
388
|
```
|
|
353
389
|
|
|
354
|
-
|
|
355
390
|
## Information and lists
|
|
356
391
|
|
|
357
392
|
### `list-engines`
|
|
@@ -371,6 +406,7 @@ echogarden list-voices google-cloud
|
|
|
371
406
|
```
|
|
372
407
|
|
|
373
408
|
Saves the voice list in a JSON file:
|
|
409
|
+
|
|
374
410
|
```bash
|
|
375
411
|
echogarden list-voices google-cloud google-cloud-voices.json
|
|
376
412
|
```
|
|
@@ -390,4 +426,3 @@ Uninstall one or more packages
|
|
|
390
426
|
### `list-packages`
|
|
391
427
|
|
|
392
428
|
Show a list of installed packages
|
|
393
|
-
|
package/docs/Contributing.md
CHANGED
|
@@ -11,6 +11,7 @@ First, check the issue tracker, as well as the [task list](Tasklist.md) to see i
|
|
|
11
11
|
If you find the issue you're encountering in the task list, you can still open an issue to discuss it. This allows me to know that someone cares about a particular issue, and I may give it higher priority.
|
|
12
12
|
|
|
13
13
|
There might be some obvious errors that have gone unreported. Especially if:
|
|
14
|
+
|
|
14
15
|
* You're using the macOS architecture: I don't have access to a macOS machine, so personally, I did not and cannot perform testing on that platform.
|
|
15
16
|
* You're using cloud services: There may be changes in the service that will require updating the code. I don't often test they work correctly, since my trial periods in Google, Microsoft and Amazon have all expired, thus testing requires me to use paid requests.
|
|
16
17
|
|
|
@@ -32,7 +33,6 @@ If the problem is serious, you can report it, and we'll see what we can do.
|
|
|
32
33
|
|
|
33
34
|
See the guide for [setting up a development environment](Development.md).
|
|
34
35
|
|
|
35
|
-
|
|
36
36
|
## Notes about licensing
|
|
37
37
|
|
|
38
38
|
The code is currently licensed under GPL-v3, mainly due to one of its core dependencies, [eSpeak-NG](https://github.com/espeak-ng/espeak-ng), having this license.
|