Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

msedge-tts-browserify

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

msedge-tts-browserify - npm Package Compare versions

Comparing version 1.3.4 to 1.4.0

2

dist/index.d.ts

@@ -1,2 +0,2 @@

export { MsEdgeTTS, Voice, ProsodyOptions } from "./MsEdgeTTS";
export { MsEdgeTTS, type Voice, ProsodyOptions } from "./MsEdgeTTS";
export { OUTPUT_FORMAT } from "./OUTPUT_FORMAT";

@@ -3,0 +3,0 @@ export { PITCH } from "./PITCH";

import { OUTPUT_FORMAT } from "./OUTPUT_FORMAT";
import { PITCH } from "./PITCH";
import { RATE } from "./RATE";
import { VOLUME } from "./VOLUME";
import type { PITCH } from "./PITCH";
import type { RATE } from "./RATE";
import type { VOLUME } from "./VOLUME";
type T = "data" | "close" | "end";
declare class s {
eventListeners: {
[key: string]: ((...arg: any[]) => void)[];
[key in T]: ((...arg: any[]) => void)[];
};
end: boolean;
constructor();
push(item: any): void;
on(eventName: string, callback: (...arg: any[]) => void): void;
emit(eventName: string, data: any): void;
on(eventName: T, callback: (...arg: any[]) => void): void;
onData(cb: (data: Uint8Array) => void): void;
onClose(cb: () => void): void;
onEnd(cb: (metadata: metadata) => void): void;
emit(eventName: T, data: any): void;
}

@@ -24,2 +26,14 @@ export type Voice = {

};
type metadata = {
Type: "WordBoundary" | "SentenceBoundary";
Data: {
Offset: number;
Duration: number;
text: {
Text: string;
Length: number;
BoundaryType: "WordBoundary" | "SentenceBoundary";
};
};
}[];
export declare class ProsodyOptions {

@@ -26,0 +40,0 @@ /**

@@ -16,29 +16,12 @@ "use strict";

function generateRandomValue(length) {
let cryptoObj = window.crypto;
let randomValues = new Uint8Array(length);
const cryptoObj = window.crypto;
const randomValues = new Uint8Array(length);
cryptoObj.getRandomValues(randomValues);
return Array.from(randomValues, function (byte) {
return ("0" + byte.toString(16)).slice(-2);
}).join("");
return Array.from(randomValues, (byte) => `0${byte.toString(16)}`.slice(-2)).join("");
}
class s {
constructor() {
this.eventListeners = {};
this.end = false;
this.eventListeners = {};
this.eventListeners = { end: [], close: [], data: [] };
this.eventListeners = { end: [], close: [], data: [] };
}
push(item) {
if (item) {
this.emit("data", item);
}
else {
if (!this.end) {
this.emit("end", null);
this.end = true;
}
else {
this.emit("closed", null);
}
}
}
on(eventName, callback) {

@@ -50,7 +33,16 @@ if (!this.eventListeners[eventName]) {

}
onData(cb) {
this.eventListeners.data.push(cb);
}
onClose(cb) {
this.eventListeners.close.push(cb);
}
onEnd(cb) {
this.eventListeners.end.push(cb);
}
emit(eventName, data) {
if (this.eventListeners[eventName]) {
this.eventListeners[eventName].forEach((callback) => {
for (const callback of this.eventListeners[eventName]) {
callback(data);
});
}
}

@@ -103,3 +95,3 @@ }

for (let i = 1; i <= 3 && this._ws.readyState !== this._ws.OPEN; i++) {
if (i == 1) {
if (i === 1) {
this._startTime = Date.now();

@@ -116,2 +108,3 @@ }

this._ws.binaryType = "arraybuffer";
const datas = [];
return new Promise((resolve, reject) => {

@@ -126,6 +119,6 @@ this._ws.onopen = () => {

"metadataoptions": {
"sentenceBoundaryEnabled": "false",
"wordBoundaryEnabled": "false"
"sentenceBoundaryEnabled": "true",
"wordBoundaryEnabled": "true"
},
"outputFormat": "${this._outputFormat}"
"outputFormat": "${this._outputFormat}"
}

@@ -146,3 +139,3 @@ }

// end of turn, close stream
this._queue[requestId].push(null);
this._queue[requestId].emit("end", datas);
}

@@ -158,2 +151,7 @@ else if (message.includes("Path:response")) {

this._log("UNKNOWN MESSAGE", message);
if (message.includes("Path:audio.metadata")) {
const startIndex = message.indexOf("{");
const t = message.slice(startIndex);
datas.push(JSON.parse(t).Metadata[0]);
}
}

@@ -168,7 +166,7 @@ }

for (const requestId in this._queue) {
this._queue[requestId].push(null);
this._queue[requestId].emit("close", null);
}
};
this._ws.onerror = function (error) {
reject("Connect Error: " + error);
this._ws.onerror = (error) => {
reject(`Connect Error: ${error}`);
};

@@ -180,3 +178,3 @@ });

const audioData = m.slice(index, m.length);
this._queue[requestId].push(audioData);
this._queue[requestId].emit("data", audioData);
this._log("receive audio chunk size: ", audioData === null || audioData === void 0 ? void 0 : audioData.length);

@@ -190,3 +188,3 @@ }

${input}
</prosody>
</prosody>
</voice>

@@ -273,3 +271,3 @@ </speak>`;

const request = `X-RequestId:${requestId}\r\nContent-Type:application/ssml+xml\r\nPath:ssml\r\n\r\n
` + requestSSML.trim();
${requestSSML.trim()}`;
// https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/speech-synthesis-markup

@@ -276,0 +274,0 @@ const readable = new s();

{
"name": "msedge-tts-browserify",
"version": "1.3.4",
"version": "1.4.0",
"description": "An Azure Speech Service module that uses the Microsoft Edge Read Aloud API.",

@@ -17,3 +17,5 @@ "author": "xushengfeng",

"devDependencies": {
"typescript": "^4.3.2"
"@biomejs/biome": "^1.8.3",
"typescript": "^4.3.2",
"vite": "^5.4.0"
},

@@ -20,0 +22,0 @@ "dependencies": {

@@ -5,3 +5,3 @@ # MsEdgeTTS

msedge-tts-browserify clone from [Migushthe2nd/MsEdgeTTS](https://github/Migushthe2nd/MsEdgeTTS), which based on nodejs. To better use it on browser, I rewrite some codes--remove node `stream`, `fs` and `crypto`, replace `axios` with `fetch`. This repo **only** support browser but nodejs.
msedge-tts-browserify clone from [Migushthe2nd/MsEdgeTTS](https://github.com/Migushthe2nd/MsEdgeTTS/tree/2a74a806e18aa595d69f6f5d03481965a6e78820), which based on nodejs. To better use it on browser, I rewrite some codes--remove node `stream`, `fs` and `crypto`, replace `axios` with `fetch`. This repo **only** support browser but nodejs.

@@ -8,0 +8,0 @@ An simple Azure Speech Service module that uses the Microsoft Edge Read Aloud API.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc