@andresaya/edge-tts 1.7.0 → 1.7.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 +113 -3
- package/dist/cli/edge-tts.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
## Features
|
|
7
7
|
|
|
8
8
|
- **Text-to-Speech**: Convert text into natural-sounding speech using Microsoft Edge's TTS capabilities.
|
|
9
|
+
- **TypeScript Support**: Full TypeScript support with comprehensive type definitions included.
|
|
10
|
+
- **Multiple Audio Formats**: Support for 36+ audio formats (MP3, WebM, OGG, WAV, PCM, and more).
|
|
9
11
|
- **Multiple Voices**: Access a variety of voices to suit your project's needs.
|
|
10
12
|
- **Voice Filtering**: Filter voices by language and gender for better selection.
|
|
11
13
|
- **Audio Information**: Get detailed information about generated audio (size, duration, format).
|
|
@@ -27,6 +29,69 @@ bun add @andresaya/edge-tts
|
|
|
27
29
|
npm install @andresaya/edge-tts
|
|
28
30
|
```
|
|
29
31
|
|
|
32
|
+
## TypeScript Support
|
|
33
|
+
|
|
34
|
+
Edge TTS is written in **TypeScript** and includes full type definitions. No additional `@types` packages are needed.
|
|
35
|
+
|
|
36
|
+
### Available Types
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import {
|
|
40
|
+
EdgeTTS,
|
|
41
|
+
Constants,
|
|
42
|
+
Voice,
|
|
43
|
+
SynthesisOptions,
|
|
44
|
+
WordBoundary
|
|
45
|
+
} from '@andresaya/edge-tts';
|
|
46
|
+
|
|
47
|
+
// Voice interface
|
|
48
|
+
interface Voice {
|
|
49
|
+
Name: string;
|
|
50
|
+
ShortName: string;
|
|
51
|
+
Gender: 'Male' | 'Female';
|
|
52
|
+
Locale: string;
|
|
53
|
+
FriendlyName: string;
|
|
54
|
+
LocalName: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Synthesis options
|
|
58
|
+
interface SynthesisOptions {
|
|
59
|
+
pitch?: string | number; // e.g., '+20Hz' or 20
|
|
60
|
+
rate?: string | number; // e.g., '50%' or 50
|
|
61
|
+
volume?: string | number; // e.g., '90%' or 90
|
|
62
|
+
inputType?: 'auto' | 'ssml' | 'text'; // Default: 'auto'
|
|
63
|
+
outputFormat?: string; // e.g., Constants.OUTPUT_FORMAT.AUDIO_24KHZ_96KBITRATE_MONO_MP3
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Word boundary metadata
|
|
67
|
+
interface WordBoundary {
|
|
68
|
+
type: "WordBoundary";
|
|
69
|
+
offset: number;
|
|
70
|
+
duration: number;
|
|
71
|
+
text: string;
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Type-Safe Usage Example
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
import { EdgeTTS, SynthesisOptions, Constants } from '@andresaya/edge-tts';
|
|
79
|
+
|
|
80
|
+
const tts = new EdgeTTS();
|
|
81
|
+
|
|
82
|
+
const options: SynthesisOptions = {
|
|
83
|
+
pitch: '+10Hz',
|
|
84
|
+
rate: '100%',
|
|
85
|
+
volume: '90%',
|
|
86
|
+
outputFormat: Constants.OUTPUT_FORMAT.WEBM_24KHZ_16BIT_MONO_OPUS
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
await tts.synthesize("TypeScript example", 'en-US-AriaNeural', options);
|
|
90
|
+
|
|
91
|
+
const info = tts.getAudioInfo(); // Returns: { size: number; format: string; estimatedDuration: number }
|
|
92
|
+
const boundaries = tts.getWordBoundaries(); // Returns: WordBoundary[]
|
|
93
|
+
```
|
|
94
|
+
|
|
30
95
|
## Usage
|
|
31
96
|
|
|
32
97
|
### Command-Line Interface
|
|
@@ -146,12 +211,57 @@ await tts.synthesize("Hello, world!", 'en-US-AriaNeural');
|
|
|
146
211
|
#### Advanced Synthesis with Options
|
|
147
212
|
```js
|
|
148
213
|
await tts.synthesize("Hello, world!", 'en-US-AriaNeural', {
|
|
149
|
-
rate: '50%',
|
|
150
|
-
volume: '90%',
|
|
151
|
-
pitch: '+20Hz'
|
|
214
|
+
rate: '50%', // Speech rate: -100% to +200% (or number)
|
|
215
|
+
volume: '90%', // Speech volume: -100% to +100% (or number)
|
|
216
|
+
pitch: '+20Hz', // Voice pitch: -100Hz to +100Hz (or number)
|
|
217
|
+
outputFormat: 'audio-24khz-96kbitrate-mono-mp3' // Audio output format
|
|
152
218
|
});
|
|
153
219
|
```
|
|
154
220
|
|
|
221
|
+
#### Audio Output Formats
|
|
222
|
+
|
|
223
|
+
Edge TTS supports multiple audio formats. You can specify the format using the `outputFormat` option:
|
|
224
|
+
|
|
225
|
+
```js
|
|
226
|
+
import { EdgeTTS, Constants } from '@andresaya/edge-tts';
|
|
227
|
+
|
|
228
|
+
const tts = new EdgeTTS();
|
|
229
|
+
|
|
230
|
+
// High quality MP3
|
|
231
|
+
await tts.synthesize("Hello!", 'en-US-AriaNeural', {
|
|
232
|
+
outputFormat: Constants.OUTPUT_FORMAT.AUDIO_24KHZ_96KBITRATE_MONO_MP3
|
|
233
|
+
});
|
|
234
|
+
await tts.toFile('./output/audio'); // Automatically saved as .mp3
|
|
235
|
+
|
|
236
|
+
// WebM/Opus for web
|
|
237
|
+
await tts.synthesize("Hello!", 'en-US-AriaNeural', {
|
|
238
|
+
outputFormat: Constants.OUTPUT_FORMAT.WEBM_24KHZ_16BIT_MONO_OPUS
|
|
239
|
+
});
|
|
240
|
+
await tts.toFile('./output/audio'); // Automatically saved as .webm
|
|
241
|
+
|
|
242
|
+
// Lossless WAV
|
|
243
|
+
await tts.synthesize("Hello!", 'en-US-AriaNeural', {
|
|
244
|
+
outputFormat: Constants.OUTPUT_FORMAT.RIFF_24KHZ_16BIT_MONO_PCM
|
|
245
|
+
});
|
|
246
|
+
await tts.toFile('./output/audio'); // Automatically saved as .wav
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
**Available formats (all 36 tested and compatible):**
|
|
250
|
+
|
|
251
|
+
- **MP3 Formats** (Streaming): 16kHz, 24kHz, 48kHz with various bitrates (32-192 kbps)
|
|
252
|
+
- **Opus Formats** (Streaming): Audio, WebM, and OGG containers
|
|
253
|
+
- **WAV/PCM Formats** (Non-streaming): RIFF (8-48 kHz) and RAW variants
|
|
254
|
+
- **Specialized Codecs**: AMR-WB, G.722, TrueSilk, A-law, μ-law
|
|
255
|
+
|
|
256
|
+
See `Constants.OUTPUT_FORMAT` for the complete list. The file extension is automatically detected based on the format.
|
|
257
|
+
|
|
258
|
+
**Format recommendations:**
|
|
259
|
+
- 🌐 **Web streaming**: `WEBM_24KHZ_16BIT_MONO_OPUS` or `AUDIO_24KHZ_96KBITRATE_MONO_MP3`
|
|
260
|
+
- 📱 **Mobile apps**: `AUDIO_24KHZ_48KBITRATE_MONO_MP3`
|
|
261
|
+
- 💾 **High quality**: `AUDIO_48KHZ_192KBITRATE_MONO_MP3` or `RIFF_48KHZ_16BIT_MONO_PCM`
|
|
262
|
+
- ⚡ **Low bandwidth**: `AUDIO_16KHZ_32KBITRATE_MONO_MP3`
|
|
263
|
+
|
|
264
|
+
|
|
155
265
|
#### Streaming Synthesis
|
|
156
266
|
```js
|
|
157
267
|
// Stream audio data in real-time
|
package/dist/cli/edge-tts.js
CHANGED
|
@@ -6,7 +6,7 @@ const VoiceListCommand_1 = require("../commands/VoiceListCommand");
|
|
|
6
6
|
const commander_1 = require("commander");
|
|
7
7
|
const program = new commander_1.Command();
|
|
8
8
|
program
|
|
9
|
-
.version('1.7.
|
|
9
|
+
.version('1.7.2')
|
|
10
10
|
.addCommand(SynthesizeCommand_1.SynthesizeCommand)
|
|
11
11
|
.addCommand(VoiceListCommand_1.VoiceListCommand);
|
|
12
12
|
try {
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { EdgeTTS, type Voice, type SynthesisOptions } from './services/EdgeTTS';
|
|
1
|
+
export { EdgeTTS, type Voice, type SynthesisOptions, type WordBoundary } from './services/EdgeTTS';
|
|
2
|
+
export { Constants } from './config/constants';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EdgeTTS = void 0;
|
|
3
|
+
exports.Constants = exports.EdgeTTS = void 0;
|
|
4
4
|
var EdgeTTS_1 = require("./services/EdgeTTS");
|
|
5
5
|
Object.defineProperty(exports, "EdgeTTS", { enumerable: true, get: function () { return EdgeTTS_1.EdgeTTS; } });
|
|
6
|
+
var constants_1 = require("./config/constants");
|
|
7
|
+
Object.defineProperty(exports, "Constants", { enumerable: true, get: function () { return constants_1.Constants; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andresaya/edge-tts",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.2",
|
|
4
4
|
"description": "Edge TTS is a package that allows access to the online text-to-speech service used by Microsoft Edge without the need for Microsoft Edge, Windows, or an API key.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"browser": "dist/browser/edge-tts.esm.js",
|