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.81 to 0.0.82

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,39 +9,37 @@ * @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;

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

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

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

@@ -37,2 +41,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;

@@ -18,12 +20,16 @@ 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
);
};

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

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

@@ -50,6 +57,9 @@ .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);

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

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

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

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.81",
"version": "0.0.82",
"description": "Fonos TTS module",
"author": "Pedro Sanders <sanderspedro@gmail.com>",
"author": "Pedro Sanders <psanders@fonoster.com>",
"homepage": "https://github.com/fonoster/fonos#readme",

@@ -41,3 +41,3 @@ "license": "MIT",

},
"gitHead": "983ae83264743dc9696719ed1ca9c01d6a392ff9"
"gitHead": "a49e32b68668455295898ec4c98cca76a9a5b3c8"
}
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