@andresaya/edge-tts 1.8.3 → 1.9.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 +173 -43
- package/dist/browser/edge-tts.esm.js +487 -287
- package/dist/browser/edge-tts.esm.js.map +4 -4
- package/dist/browser/edge-tts.esm.min.js +20 -16
- package/dist/browser/edge-tts.esm.min.js.map +4 -4
- package/dist/browser/edge-tts.umd.js +487 -287
- package/dist/browser/edge-tts.umd.js.map +4 -4
- package/dist/browser/edge-tts.umd.min.js +20 -16
- package/dist/browser/edge-tts.umd.min.js.map +4 -4
- package/dist/cli/edge-tts.js +2 -1
- package/dist/commands/SynthesizeCommand.js +19 -3
- package/dist/commands/VoiceListCommand.js +6 -2
- package/dist/config/constants.js +2 -1
- package/dist/core/base.d.ts +33 -0
- package/dist/core/base.js +187 -0
- package/dist/core/clock.d.ts +3 -0
- package/dist/core/clock.js +20 -0
- package/dist/core/crypto.d.ts +8 -0
- package/dist/core/crypto.js +14 -0
- package/dist/core/errors.d.ts +9 -0
- package/dist/core/errors.js +15 -0
- package/dist/core/protocol.d.ts +23 -0
- package/dist/core/protocol.js +206 -0
- package/dist/core/session.d.ts +24 -0
- package/dist/core/session.js +87 -0
- package/dist/core/subtitles.d.ts +7 -0
- package/dist/core/subtitles.js +24 -0
- package/dist/core/types.d.ts +53 -0
- package/dist/core/types.js +2 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +6 -1
- package/dist/services/EdgeTTS.d.ts +18 -41
- package/dist/services/EdgeTTS.js +79 -376
- package/package.json +3 -2
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export interface Voice {
|
|
2
|
+
Name: string;
|
|
3
|
+
ShortName: string;
|
|
4
|
+
Gender: string;
|
|
5
|
+
Locale: string;
|
|
6
|
+
FriendlyName: string;
|
|
7
|
+
LocalName: string;
|
|
8
|
+
DisplayName?: string;
|
|
9
|
+
LocaleName?: string;
|
|
10
|
+
VoiceType?: string;
|
|
11
|
+
SecondaryLocaleList?: string[];
|
|
12
|
+
VoiceTag?: {
|
|
13
|
+
TailoredScenarios: string[];
|
|
14
|
+
VoicePersonalities: string[];
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export type OutputFormat = 'audio-24khz-48kbitrate-mono-mp3' | 'audio-24khz-96kbitrate-mono-mp3' | 'webm-24khz-16bit-mono-opus';
|
|
18
|
+
export interface SynthesisOptions {
|
|
19
|
+
pitch?: string | number;
|
|
20
|
+
rate?: string | number;
|
|
21
|
+
volume?: string | number;
|
|
22
|
+
outputFormat?: OutputFormat | (string & {});
|
|
23
|
+
signal?: AbortSignal;
|
|
24
|
+
timeout?: number;
|
|
25
|
+
}
|
|
26
|
+
export interface WordBoundary {
|
|
27
|
+
type: "WordBoundary";
|
|
28
|
+
offset: number;
|
|
29
|
+
duration: number;
|
|
30
|
+
text: string;
|
|
31
|
+
}
|
|
32
|
+
export interface SentenceBoundary {
|
|
33
|
+
type: "SentenceBoundary";
|
|
34
|
+
offset: number;
|
|
35
|
+
duration: number;
|
|
36
|
+
text: string;
|
|
37
|
+
}
|
|
38
|
+
export interface EdgeTTSOptions {
|
|
39
|
+
wssUrl?: string;
|
|
40
|
+
voicesUrl?: string;
|
|
41
|
+
secMsGecVersion?: string;
|
|
42
|
+
headers?: Record<string, string>;
|
|
43
|
+
timeout?: number;
|
|
44
|
+
voicesCacheTtl?: number;
|
|
45
|
+
}
|
|
46
|
+
export interface SynthesisResult {
|
|
47
|
+
audio: Uint8Array;
|
|
48
|
+
format: string;
|
|
49
|
+
outputFormat: string;
|
|
50
|
+
wordBoundaries: WordBoundary[];
|
|
51
|
+
sentenceBoundaries: SentenceBoundary[];
|
|
52
|
+
duration: number;
|
|
53
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
export { EdgeTTS, type Voice, type SynthesisOptions, type WordBoundary } from './services/EdgeTTS';
|
|
2
2
|
export { Constants } from './config/constants';
|
|
3
|
+
export { EdgeTTSError, type EdgeTTSErrorCode } from './core/errors';
|
|
4
|
+
export { toSRT, toVTT } from './core/subtitles';
|
|
5
|
+
export type { EdgeTTSOptions, OutputFormat, SentenceBoundary, SynthesisResult } from './core/types';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Constants = exports.EdgeTTS = void 0;
|
|
3
|
+
exports.toVTT = exports.toSRT = exports.EdgeTTSError = 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
6
|
var constants_1 = require("./config/constants");
|
|
7
7
|
Object.defineProperty(exports, "Constants", { enumerable: true, get: function () { return constants_1.Constants; } });
|
|
8
|
+
var errors_1 = require("./core/errors");
|
|
9
|
+
Object.defineProperty(exports, "EdgeTTSError", { enumerable: true, get: function () { return errors_1.EdgeTTSError; } });
|
|
10
|
+
var subtitles_1 = require("./core/subtitles");
|
|
11
|
+
Object.defineProperty(exports, "toSRT", { enumerable: true, get: function () { return subtitles_1.toSRT; } });
|
|
12
|
+
Object.defineProperty(exports, "toVTT", { enumerable: true, get: function () { return subtitles_1.toVTT; } });
|
|
@@ -1,50 +1,28 @@
|
|
|
1
1
|
import { Buffer } from 'buffer';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
LocalName: string;
|
|
9
|
-
}
|
|
10
|
-
export interface SynthesisOptions {
|
|
11
|
-
pitch?: string | number;
|
|
12
|
-
rate?: string | number;
|
|
13
|
-
volume?: string | number;
|
|
14
|
-
outputFormat?: string;
|
|
15
|
-
}
|
|
16
|
-
export interface WordBoundary {
|
|
17
|
-
type: "WordBoundary";
|
|
18
|
-
offset: number;
|
|
19
|
-
duration: number;
|
|
20
|
-
text: string;
|
|
21
|
-
}
|
|
22
|
-
export declare class EdgeTTS {
|
|
23
|
-
private audio_stream;
|
|
24
|
-
private audio_format;
|
|
25
|
-
private output_format;
|
|
26
|
-
private word_boundaries;
|
|
2
|
+
import { EdgeTTSCore } from '../core/base';
|
|
3
|
+
import type { SocketLike } from '../core/session';
|
|
4
|
+
import type { EdgeTTSOptions, SynthesisOptions, SynthesisResult } from '../core/types';
|
|
5
|
+
export type { Voice, SynthesisOptions, WordBoundary } from '../core/types';
|
|
6
|
+
export declare class EdgeTTS extends EdgeTTSCore {
|
|
7
|
+
protected readonly defaultVoice = "en-US-AnaNeural";
|
|
27
8
|
private ws;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
9
|
+
constructor(options?: EdgeTTSOptions);
|
|
10
|
+
generateSecMsGec: (trustedClientToken: string) => Promise<string>;
|
|
11
|
+
generate(text: string, voice?: string, options?: SynthesisOptions): Promise<SynthesisResult & {
|
|
12
|
+
audio: Buffer;
|
|
13
|
+
}>;
|
|
14
|
+
protected openSocket(url: string): SocketLike;
|
|
15
|
+
protected requestVoices(url: string): Promise<any[]>;
|
|
16
|
+
protected buildSSML(text: string, voice: string, options: SynthesisOptions): string;
|
|
17
|
+
protected timestamp(): string;
|
|
18
|
+
protected socketError(event: unknown, opened: boolean): Error;
|
|
19
|
+
protected recoverHandshake(): Promise<boolean>;
|
|
20
|
+
private serverTime;
|
|
33
21
|
private validatePitch;
|
|
34
22
|
private validateRate;
|
|
35
23
|
private validateVolume;
|
|
36
|
-
synthesize(text: string, voice?: string, options?: SynthesisOptions): Promise<void>;
|
|
37
|
-
private escapeXML;
|
|
38
|
-
private getSSML;
|
|
39
24
|
private nowRFC1123;
|
|
40
|
-
private parseRFC1123;
|
|
41
|
-
private buildTTSConfigMessage;
|
|
42
|
-
synthesizeStream(text: string, voice?: string, options?: SynthesisOptions): AsyncGenerator<Uint8Array, void, unknown>;
|
|
43
|
-
private processAudioData;
|
|
44
|
-
private parseMetadata;
|
|
45
|
-
generateSecMsGec: (trustedClientToken: string) => Promise<string>;
|
|
46
25
|
getDuration(): number;
|
|
47
|
-
private getFileExtension;
|
|
48
26
|
getAudioInfo(): {
|
|
49
27
|
size: number;
|
|
50
28
|
format: string;
|
|
@@ -55,5 +33,4 @@ export declare class EdgeTTS {
|
|
|
55
33
|
toBase64(): string;
|
|
56
34
|
toBuffer(): Buffer;
|
|
57
35
|
saveMetadata(outputPath: string): Promise<void>;
|
|
58
|
-
getWordBoundaries(): WordBoundary[];
|
|
59
36
|
}
|