@andresaya/edge-tts 1.4.4 → 1.5.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.
@@ -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.4.4')
9
+ .version('1.5.0')
10
10
  .addCommand(SynthesizeCommand_1.SynthesizeCommand)
11
11
  .addCommand(VoiceListCommand_1.VoiceListCommand);
12
12
  try {
@@ -1,7 +1,32 @@
1
1
  export declare const Constants: {
2
2
  TRUSTED_CLIENT_TOKEN: string;
3
+ BASE_URL: string;
3
4
  WSS_URL: string;
4
5
  VOICES_URL: string;
5
- USER_AGENT: string;
6
+ CHROMIUM_FULL_VERSION: string;
7
+ CHROMIUM_MAJOR_VERSION: string;
6
8
  VERSION_MS_GEC: string;
9
+ token32(): string;
10
+ getBaseHeaders(): {
11
+ 'User-Agent': string;
12
+ 'Accept-Encoding': string;
13
+ 'Accept-Language': string;
14
+ Cookie: string;
15
+ };
16
+ WSS_HEADERS: {
17
+ Pragma: string;
18
+ 'Cache-Control': string;
19
+ Origin: string;
20
+ 'Sec-WebSocket-Protocol': string;
21
+ 'Sec-WebSocket-Version': string;
22
+ 'User-Agent': string;
23
+ };
24
+ VOICE_HEADERS: {
25
+ 'Sec-CH-UA': string;
26
+ 'Sec-CH-UA-Mobile': string;
27
+ Accept: string;
28
+ 'Sec-Fetch-Site': string;
29
+ 'Sec-Fetch-Mode': string;
30
+ 'Sec-Fetch-Dest': string;
31
+ };
7
32
  };
@@ -3,8 +3,42 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Constants = void 0;
4
4
  exports.Constants = {
5
5
  TRUSTED_CLIENT_TOKEN: '6A5AA1D4EAFF4E9FB37E23D68491D6F4',
6
- WSS_URL: 'ws://api.msedgeservices.com/tts/cognitiveservices/websocket/v1',
6
+ BASE_URL: 'https://api.msedgeservices.com/tts/cognitiveservices',
7
+ WSS_URL: 'wss://api.msedgeservices.com/tts/cognitiveservices/websocket/v1',
7
8
  VOICES_URL: 'https://api.msedgeservices.com/tts/cognitiveservices/voices/list',
8
- USER_AGENT: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0',
9
- VERSION_MS_GEC: '1-140.0.3485.14'
9
+ CHROMIUM_FULL_VERSION: '142.0.3595.0',
10
+ CHROMIUM_MAJOR_VERSION: '142',
11
+ VERSION_MS_GEC: '1-142.0.3595',
12
+ token32() {
13
+ const bytes = new Uint8Array(16);
14
+ crypto.getRandomValues(bytes);
15
+ return Array.from(bytes)
16
+ .map(b => b.toString(16).padStart(2, '0'))
17
+ .join('')
18
+ .toUpperCase();
19
+ },
20
+ getBaseHeaders() {
21
+ return {
22
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 Edg/142.0.0.0',
23
+ 'Accept-Encoding': 'gzip, deflate, br, zstd',
24
+ 'Accept-Language': 'es,es-ES;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6,es-CO;q=0.5,es-MX;q=0.4',
25
+ 'Cookie': 'MUID=' + this.token32()
26
+ };
27
+ },
28
+ WSS_HEADERS: {
29
+ 'Pragma': 'no-cache',
30
+ 'Cache-Control': 'no-cache',
31
+ 'Origin': 'chrome-extension://jdiccldimpdaibmpdkjnbmckianbfold',
32
+ 'Sec-WebSocket-Protocol': 'synthesize',
33
+ 'Sec-WebSocket-Version': '13',
34
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 Edg/142.0.0.0'
35
+ },
36
+ VOICE_HEADERS: {
37
+ 'Sec-CH-UA': '" Not;A Brand";v="99", "Microsoft Edge";v="140", "Chromium";v="140"',
38
+ 'Sec-CH-UA-Mobile': '?0',
39
+ 'Accept': '*/*',
40
+ 'Sec-Fetch-Site': 'none',
41
+ 'Sec-Fetch-Mode': 'cors',
42
+ 'Sec-Fetch-Dest': 'empty'
43
+ }
10
44
  };
@@ -36,9 +36,7 @@ class EdgeTTS {
36
36
  });
37
37
  const response = await new Promise((resolve, reject) => {
38
38
  const req = https_1.default.request(`${constants_1.Constants.VOICES_URL}?Ocp-Apim-Subscription-Key=${constants_1.Constants.TRUSTED_CLIENT_TOKEN}&Sec-MS-GEC=${secMsGEC}&Sec-MS-GEC-Version=${constants_1.Constants.VERSION_MS_GEC}`, {
39
- headers: {
40
- "User-Agent": constants_1.Constants.USER_AGENT
41
- },
39
+ headers: constants_1.Constants.getBaseHeaders(),
42
40
  agent: httpsAgent
43
41
  }, (res) => {
44
42
  let data = '';
@@ -117,9 +115,7 @@ class EdgeTTS {
117
115
  const reqId = this.generateUUID();
118
116
  const url = `${constants_1.Constants.WSS_URL}?Ocp-Apim-Subscription-Key=${constants_1.Constants.TRUSTED_CLIENT_TOKEN}&Sec-MS-GEC=${secMsGEC}&Sec-MS-GEC-Version=${constants_1.Constants.VERSION_MS_GEC}&ConnectionId=${reqId}`;
119
117
  this.ws = new ws_1.default(url, {
120
- headers: {
121
- "User-Agent": constants_1.Constants.USER_AGENT
122
- },
118
+ headers: constants_1.Constants.getBaseHeaders(),
123
119
  rejectUnauthorized: false
124
120
  });
125
121
  const SSML_text = this.getSSML(text, voice, options);
@@ -259,9 +255,7 @@ class EdgeTTS {
259
255
  const secMsGEC = await this.generateSecMsGec(constants_1.Constants.TRUSTED_CLIENT_TOKEN);
260
256
  const url = `${constants_1.Constants.WSS_URL}?Ocp-Apim-Subscription-Key=${constants_1.Constants.TRUSTED_CLIENT_TOKEN}&Sec-MS-GEC=${secMsGEC}&Sec-MS-GEC-Version=${constants_1.Constants.VERSION_MS_GEC}&ConnectionId=${reqId}`;
261
257
  this.ws = new ws_1.default(url, {
262
- headers: {
263
- "User-Agent": constants_1.Constants.USER_AGENT
264
- },
258
+ headers: constants_1.Constants.getBaseHeaders(),
265
259
  rejectUnauthorized: false
266
260
  });
267
261
  const SSML_text = this.getSSML(text, voice, options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andresaya/edge-tts",
3
- "version": "1.4.4",
3
+ "version": "1.5.0",
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
  "keywords": [