@fonos/marytts
Advanced tools
Comparing version 0.0.87 to 0.0.88
@@ -1,3 +0,3 @@ | ||
import {AbstractTTS} from "@fonos/tts"; | ||
import {MaryTTSConfig, MarySynthOptions} from "./types"; | ||
import { AbstractTTS } from "@fonos/tts"; | ||
import { MaryTTSConfig, MarySynthOptions } from "./types"; | ||
/** | ||
@@ -25,26 +25,26 @@ * @classdesc The default TTS engine in a Fonos deployment. | ||
export default class MaryTTS extends AbstractTTS { | ||
serviceUrl: string; | ||
/** | ||
* Constructs a new MaryTTS object. | ||
* | ||
* @see module:tts:AbstractTTS | ||
* @param {DefaultConfig} config - Configuration of the marytts | ||
*/ | ||
constructor(config: MaryTTSConfig); | ||
/** | ||
* Init of the marytts constructor | ||
* | ||
* @param {DefaultConfig} config - Configuration of the marytts | ||
*/ | ||
init(config: MaryTTSConfig): void; | ||
/** | ||
* @inherit | ||
* | ||
* @param {string} text - Text that will be synthesized | ||
* @param {OptionsInterface} options - Options of the marytts, locale and voice | ||
* @return {Promise<String>} | ||
* For more information: http://marytts.phonetik.uni-muenchen.de:59125/documentation.html | ||
* Advice: On windows the command "which" that sox library uses is not the same. In windows is "where" instead | ||
*/ | ||
synthesize(text: string, options?: MarySynthOptions): Promise<string>; | ||
serviceUrl: string; | ||
/** | ||
* Constructs a new MaryTTS object. | ||
* | ||
* @see module:tts:AbstractTTS | ||
* @param {DefaultConfig} config - Configuration of the marytts | ||
*/ | ||
constructor(config: MaryTTSConfig); | ||
/** | ||
* Init of the marytts constructor | ||
* | ||
* @param {DefaultConfig} config - Configuration of the marytts | ||
*/ | ||
init(config: MaryTTSConfig): void; | ||
/** | ||
* @inherit | ||
* | ||
* @param {string} text - Text that will be synthesized | ||
* @param {OptionsInterface} options - Options of the marytts, locale and voice | ||
* @return {Promise<String>} | ||
* For more information: http://marytts.phonetik.uni-muenchen.de:59125/documentation.html | ||
* Advice: On windows the command "which" that sox library uses is not the same. In windows is "where" instead | ||
*/ | ||
synthesize(text: string, options?: MarySynthOptions): Promise<string>; | ||
} |
"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 }); | ||
/* | ||
@@ -53,68 +51,49 @@ * Copyright (C) 2021 by Fonoster Inc (https://fonoster.com) | ||
class MaryTTS extends tts_1.AbstractTTS { | ||
/** | ||
* Constructs a new MaryTTS object. | ||
* | ||
* @see module:tts:AbstractTTS | ||
* @param {DefaultConfig} config - Configuration of the marytts | ||
*/ | ||
constructor(config) { | ||
super("mary-tts"); | ||
this.init(config); | ||
} | ||
/** | ||
* Init of the marytts constructor | ||
* | ||
* @param {DefaultConfig} config - Configuration of the marytts | ||
*/ | ||
init(config) { | ||
const q = `INPUT_TYPE=TEXT&AUDIO=WAVE_FILE&OUTPUT_TYPE=AUDIO&LOCALE=${config.locale}`; | ||
this.serviceUrl = `http://${config.host}:${config.port}/process?${q}`; | ||
logger_1.default.log( | ||
"debug", | ||
`@fonos/tts.MaryTTS.constructor [initializing with config: ${JSON.stringify( | ||
config | ||
)}]` | ||
); | ||
logger_1.default.log( | ||
"verbose", | ||
`@fonos/tts.MaryTTS.constructor [serviceUrl: ${this.serviceUrl}]` | ||
); | ||
} | ||
/** | ||
* @inherit | ||
* | ||
* @param {string} text - Text that will be synthesized | ||
* @param {OptionsInterface} options - Options of the marytts, locale and voice | ||
* @return {Promise<String>} | ||
* For more information: http://marytts.phonetik.uni-muenchen.de:59125/documentation.html | ||
* Advice: On windows the command "which" that sox library uses is not the same. In windows is "where" instead | ||
*/ | ||
synthesize(text, options = {locale: "EN_US", voice: ""}) { | ||
const pathToFile = path_1.default.join( | ||
"/tmp", | ||
tts_1.computeFilename(text, options) | ||
); | ||
logger_1.default.log( | ||
"debug", | ||
`@fonos/tts.MaryTTS.synthesize [text: ${text}, options: ${JSON.stringify( | ||
options | ||
)}]` | ||
); | ||
return new Promise((resolve, reject) => { | ||
const query = tts_1.optionsToQueryString(options); | ||
http_1.default.get( | ||
`${this.serviceUrl}&INPUT_TEXT=${encodeURI(text)}&${query}`, | ||
(response) => { | ||
const {statusCode} = response; | ||
if (statusCode !== 200) { | ||
reject(new Error(`Request failed status code: ${statusCode}`)); | ||
return; | ||
} | ||
response.pipe(fs_1.default.createWriteStream(pathToFile)); | ||
resolve(pathToFile); | ||
} | ||
); | ||
}); | ||
} | ||
/** | ||
* Constructs a new MaryTTS object. | ||
* | ||
* @see module:tts:AbstractTTS | ||
* @param {DefaultConfig} config - Configuration of the marytts | ||
*/ | ||
constructor(config) { | ||
super("mary-tts"); | ||
this.init(config); | ||
} | ||
/** | ||
* Init of the marytts constructor | ||
* | ||
* @param {DefaultConfig} config - Configuration of the marytts | ||
*/ | ||
init(config) { | ||
const q = `INPUT_TYPE=TEXT&AUDIO=WAVE_FILE&OUTPUT_TYPE=AUDIO&LOCALE=${config.locale}`; | ||
this.serviceUrl = `http://${config.host}:${config.port}/process?${q}`; | ||
logger_1.default.log("debug", `@fonos/tts.MaryTTS.constructor [initializing with config: ${JSON.stringify(config)}]`); | ||
logger_1.default.log("verbose", `@fonos/tts.MaryTTS.constructor [serviceUrl: ${this.serviceUrl}]`); | ||
} | ||
/** | ||
* @inherit | ||
* | ||
* @param {string} text - Text that will be synthesized | ||
* @param {OptionsInterface} options - Options of the marytts, locale and voice | ||
* @return {Promise<String>} | ||
* For more information: http://marytts.phonetik.uni-muenchen.de:59125/documentation.html | ||
* Advice: On windows the command "which" that sox library uses is not the same. In windows is "where" instead | ||
*/ | ||
synthesize(text, options = { locale: "EN_US", voice: "" }) { | ||
const pathToFile = path_1.default.join("/tmp", tts_1.computeFilename(text, options)); | ||
logger_1.default.log("debug", `@fonos/tts.MaryTTS.synthesize [text: ${text}, options: ${JSON.stringify(options)}]`); | ||
return new Promise((resolve, reject) => { | ||
const query = tts_1.optionsToQueryString(options); | ||
http_1.default.get(`${this.serviceUrl}&INPUT_TEXT=${encodeURI(text)}&${query}`, (response) => { | ||
const { statusCode } = response; | ||
if (statusCode !== 200) { | ||
reject(new Error(`Request failed status code: ${statusCode}`)); | ||
return; | ||
} | ||
response.pipe(fs_1.default.createWriteStream(pathToFile)); | ||
resolve(pathToFile); | ||
}); | ||
}); | ||
} | ||
} | ||
exports.default = MaryTTS; |
export interface MarySynthOptions { | ||
locale: string; | ||
voice?: string; | ||
locale: string; | ||
voice?: string; | ||
} | ||
export interface MaryTTSConfig { | ||
host: string; | ||
port: string | number; | ||
locale: string; | ||
host: string; | ||
port: string | number; | ||
locale: string; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", {value: true}); | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
{ | ||
"name": "@fonos/marytts", | ||
"version": "0.0.87", | ||
"version": "0.0.88", | ||
"description": "Concrete implementation of AbstractTTS", | ||
@@ -32,12 +32,13 @@ "author": "Pedro Sanders <psanders@fonoster.com>", | ||
"dependencies": { | ||
"@fonos/logger": "^0.0.87", | ||
"@fonos/tts": "^0.0.87", | ||
"deepmerge": "^4.2.2" | ||
"@fonos/logger": "^0.0.88", | ||
"@fonos/tts": "^0.0.88" | ||
}, | ||
"devDependencies": { | ||
"dotenv": "^8.2.0", | ||
"chai": "^4.3.4", | ||
"chai-as-promised": "^7.1.1", | ||
"rimraf": "^3.0.2", | ||
"typescript": "^4.1.5" | ||
"sinon": "^10.0.0", | ||
"sinon-chai": "^3.6.0" | ||
}, | ||
"gitHead": "f432bd97cab50bfebfe2be9847cc5e2ff890c750" | ||
"gitHead": "cb5c86eae9d3982c4ec62d0faa33c085eb9141e8" | ||
} |
8037
2
5
156
+ Added@fonos/logger@0.0.88(transitive)
+ Added@fonos/tts@0.0.88(transitive)
+ Added@sinonjs/commons@1.8.63.0.1(transitive)
+ Added@sinonjs/fake-timers@11.3.17.1.2(transitive)
+ Added@sinonjs/samsam@6.1.3(transitive)
+ Added@sinonjs/text-encoding@0.7.3(transitive)
+ Addedassertion-error@1.1.0(transitive)
+ Addedchai@4.5.0(transitive)
+ Addedchai-as-promised@7.1.2(transitive)
+ Addedcheck-error@1.0.3(transitive)
+ Addeddeep-eql@4.1.4(transitive)
+ Addeddiff@4.0.2(transitive)
+ Addedget-func-name@2.0.2(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedjust-extend@6.2.0(transitive)
+ Addedlodash.get@4.4.2(transitive)
+ Addedloupe@2.3.7(transitive)
+ Addednise@5.1.9(transitive)
+ Addedpath-to-regexp@6.3.0(transitive)
+ Addedpathval@1.1.1(transitive)
+ Addedsinon@10.0.1(transitive)
+ Addedsinon-chai@3.7.0(transitive)
+ Addedsupports-color@7.2.0(transitive)
+ Addedtype-detect@4.0.84.1.0(transitive)
- Removeddeepmerge@^4.2.2
- Removed@fonos/logger@0.0.87(transitive)
- Removed@fonos/tts@0.0.87(transitive)
- Removeddeepmerge@4.3.1(transitive)
Updated@fonos/logger@^0.0.88
Updated@fonos/tts@^0.0.88