New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@fonos/tts

Package Overview
Dependencies
Maintainers
1
Versions
138
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fonos/tts - npm Package Compare versions

Comparing version 0.0.87 to 0.0.88

60

dist/abstract_tts.d.ts

@@ -7,32 +7,32 @@ /**

export default abstract class AbstractTTS {
name: string;
/**
* Constructs a new AbstractTTS object.
*
* @param {string} name friendly name for the TTS engine
* @see module:tts:MaryTTS
*/
constructor(name: string);
/**
* Converts a text to audio.
*
* @param {string} text - Text to convert to a audio sound
* @param {Object} options - An object pass to the final implementation with
* settings for the TTS engine
* @returns {string} The path to the synthesized audio
*/
synthesizeSync(text: string, options: any): string;
/**
* Converts a text to audio.
*
* @param {string} text - Text to convert to a audio sound
* @param {Object} options - An object pass to the final implementation with
* settings for the TTS engine
* @returns {string} The path to the synthesized audio
*/
abstract synthesize(text: string, options?: any): Promise<string>;
/**
* Gets the name of the TTS engine
*/
getName(): string;
name: string;
/**
* Constructs a new AbstractTTS object.
*
* @param {string} name friendly name for the TTS engine
* @see module:tts:MaryTTS
*/
constructor(name: string);
/**
* Converts a text to audio.
*
* @param {string} text - Text to convert to a audio sound
* @param {Object} options - An object pass to the final implementation with
* settings for the TTS engine
* @returns {string} The path to the synthesized audio
*/
synthesizeSync(text: string, options: any): string;
/**
* Converts a text to audio.
*
* @param {string} text - Text to convert to a audio sound
* @param {Object} options - An object pass to the final implementation with
* settings for the TTS engine
* @returns {string} The path to the synthesized audio
*/
abstract synthesize(text: string, options?: any): Promise<string>;
/**
* Gets the name of the TTS engine
*/
getName(): string;
}
"use strict";
Object.defineProperty(exports, "__esModule", {value: true});
Object.defineProperty(exports, "__esModule", { value: true });
/**

@@ -9,37 +9,39 @@ * @classdesc A building block for new TTS engines. You might use this class

class AbstractTTS {
/**
* Constructs a new AbstractTTS object.
*
* @param {string} name friendly name for the TTS engine
* @see module:tts:MaryTTS
*/
constructor(name) {
this.name = name;
}
/**
* Converts a text to audio.
*
* @param {string} text - Text to convert to a audio sound
* @param {Object} options - An object pass to the final implementation with
* settings for the TTS engine
* @returns {string} The path to the synthesized audio
*/
synthesizeSync(text, options) {
const sleep = require("sync").sleep;
let result;
let error;
this.synthesize(text, options)
.then((r) => (result = r))
.catch((e) => (error = e));
while (result === undefined && error === undefined) sleep(100);
if (error) throw error;
return result;
}
/**
* Gets the name of the TTS engine
*/
getName() {
return this.name;
}
/**
* Constructs a new AbstractTTS object.
*
* @param {string} name friendly name for the TTS engine
* @see module:tts:MaryTTS
*/
constructor(name) {
this.name = name;
}
/**
* Converts a text to audio.
*
* @param {string} text - Text to convert to a audio sound
* @param {Object} options - An object pass to the final implementation with
* settings for the TTS engine
* @returns {string} The path to the synthesized audio
*/
synthesizeSync(text, options) {
const sleep = require("sync").sleep;
let result;
let error;
this.synthesize(text, options)
.then((r) => (result = r))
.catch((e) => (error = e));
while (result === undefined && error === undefined)
sleep(100);
if (error)
throw error;
return result;
}
/**
* Gets the name of the TTS engine
*/
getName() {
return this.name;
}
}
exports.default = AbstractTTS;
import AbstractTTS from "./abstract_tts";
export * from "./utils";
export {AbstractTTS};
export { AbstractTTS };
"use strict";
var __createBinding =
(this && this.__createBinding) ||
(Object.create
? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, {
enumerable: true,
get: function () {
return m[k];
}
});
}
: function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar =
(this && this.__exportStar) ||
function (m, exports) {
for (var p in m)
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p))
__createBinding(exports, m, p);
};
var __importDefault =
(this && this.__importDefault) ||
function (mod) {
return mod && mod.__esModule ? mod : {default: mod};
};
Object.defineProperty(exports, "__esModule", {value: true});
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AbstractTTS = void 0;

@@ -32,0 +17,0 @@ const abstract_tts_1 = __importDefault(require("./abstract_tts"));

@@ -10,7 +10,3 @@ /**

*/
declare const computeFilename: (
text: string,
options?: any,
format?: string
) => string;
declare const computeFilename: (text: string, options?: any, format?: string) => string;
/**

@@ -41,2 +37,2 @@ * Takes a json object and creates a query formatted string

declare const transcodeSync: (fileIn: string, fileOut: string) => string;
export {computeFilename, transcode, transcodeSync, optionsToQueryString};
export { computeFilename, transcode, transcodeSync, optionsToQueryString };
"use strict";
var __importDefault =
(this && this.__importDefault) ||
function (mod) {
return mod && mod.__esModule ? mod : {default: mod};
};
Object.defineProperty(exports, "__esModule", {value: true});
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.optionsToQueryString = exports.transcodeSync = exports.transcode = exports.computeFilename = void 0;

@@ -20,16 +18,12 @@ const crypto_1 = __importDefault(require("crypto"));

const computeFilename = (text, options = {}, format = "wav") => {
const flat = require("flat");
let c = text;
if (options.cachingFields) {
const flatObj = flat(options);
c = options.cachingFields
.map((opt) => flatObj[opt])
.sort()
.join();
}
return (
crypto_1.default.createHash("md5").update(`${text},${c}`).digest("hex") +
"." +
format
);
const flat = require("flat");
let c = text;
if (options.cachingFields) {
const flatObj = flat(options);
c = options.cachingFields
.map((opt) => flatObj[opt])
.sort()
.join();
}
return (crypto_1.default.createHash("md5").update(`${text},${c}`).digest("hex") + "." + format);
};

@@ -43,4 +37,3 @@ exports.computeFilename = computeFilename;

*/
const optionsToQueryString = (obj) =>
Object.keys(obj)
const optionsToQueryString = (obj) => Object.keys(obj)
.map((key) => `${key}=${obj[key].toString()}`)

@@ -57,9 +50,6 @@ .join("&");

*/
const transcode = (fileIn, fileOut) =>
new Promise((resolve, reject) => {
const transcode = (fileIn, fileOut) => new Promise((resolve, reject) => {
// We need a new instance to avoid collisions
const sox = require("sox-audio")();
sox.on("error", (err, stdout, stderr) =>
reject(`Cannot process audio: ${err.message}`)
);
sox.on("error", (err, stdout, stderr) => reject(`Cannot process audio: ${err.message}`));
sox.input(fileIn);

@@ -70,3 +60,3 @@ // TODO: Investigate other formats that can produce a better audio quality

sox.on("end", () => resolve(fileOut));
});
});
exports.transcode = transcode;

@@ -82,12 +72,14 @@ /**

const transcodeSync = (fileIn, fileOut) => {
const sleep = require("sync").sleep;
let result;
let error;
transcode(fileIn, fileOut)
.then((r) => (result = r))
.catch((e) => (error = e));
while (result === undefined && error === undefined) sleep(100);
if (error) throw error;
return result;
const sleep = require("sync").sleep;
let result;
let error;
transcode(fileIn, fileOut)
.then((r) => (result = r))
.catch((e) => (error = e));
while (result === undefined && error === undefined)
sleep(100);
if (error)
throw error;
return result;
};
exports.transcodeSync = transcodeSync;
{
"name": "@fonos/tts",
"version": "0.0.87",
"version": "0.0.88",
"description": "Fonos TTS module",

@@ -32,3 +32,7 @@ "author": "Pedro Sanders <psanders@fonoster.com>",

"dependencies": {
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
"flat": "^5.0.2",
"sinon": "^10.0.0",
"sinon-chai": "^3.6.0",
"sox-audio": "^0.3.0",

@@ -39,6 +43,5 @@ "sync": "^0.2.5"

"dotenv": "^8.2.0",
"rimraf": "^3.0.2",
"typescript": "^4.1.5"
"rimraf": "^3.0.2"
},
"gitHead": "f432bd97cab50bfebfe2be9847cc5e2ff890c750"
"gitHead": "cb5c86eae9d3982c4ec62d0faa33c085eb9141e8"
}
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