mirror of
https://github.com/jambonz/speech-utils.git
synced 2026-10-03 23:33:59 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d58954537 | ||
|
|
7c0eafded3 | ||
|
|
ab7d145288 | ||
|
|
11746d3f22 | ||
|
|
3fcfbd10a1 | ||
|
|
df8acbed0e | ||
|
|
4296ed7256 | ||
|
|
f4b271c7b3 |
+2
-8
@@ -2,14 +2,12 @@ const assert = require('assert');
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const bent = require('bent');
|
const bent = require('bent');
|
||||||
const ttsGoogle = require('@google-cloud/text-to-speech');
|
const ttsGoogle = require('@google-cloud/text-to-speech');
|
||||||
//const Polly = require('aws-sdk/clients/polly');
|
|
||||||
const { PollyClient, SynthesizeSpeechCommand } = require('@aws-sdk/client-polly');
|
const { PollyClient, SynthesizeSpeechCommand } = require('@aws-sdk/client-polly');
|
||||||
|
|
||||||
const sdk = require('microsoft-cognitiveservices-speech-sdk');
|
const sdk = require('microsoft-cognitiveservices-speech-sdk');
|
||||||
const TextToSpeechV1 = require('ibm-watson/text-to-speech/v1');
|
const TextToSpeechV1 = require('ibm-watson/text-to-speech/v1');
|
||||||
const { IamAuthenticator } = require('ibm-watson/auth');
|
const { IamAuthenticator } = require('ibm-watson/auth');
|
||||||
const {
|
const {
|
||||||
AudioConfig,
|
|
||||||
ResultReason,
|
ResultReason,
|
||||||
SpeechConfig,
|
SpeechConfig,
|
||||||
SpeechSynthesizer,
|
SpeechSynthesizer,
|
||||||
@@ -302,8 +300,7 @@ const synthMicrosoft = async(logger, {
|
|||||||
if (!content.startsWith('<speak')) content = `<speak>${text}</speak>`;
|
if (!content.startsWith('<speak')) content = `<speak>${text}</speak>`;
|
||||||
}
|
}
|
||||||
speechConfig.speechSynthesisOutputFormat = SpeechSynthesisOutputFormat.Audio16Khz32KBitRateMonoMp3;
|
speechConfig.speechSynthesisOutputFormat = SpeechSynthesisOutputFormat.Audio16Khz32KBitRateMonoMp3;
|
||||||
const config = AudioConfig.fromAudioFileOutput(filePath);
|
const synthesizer = new SpeechSynthesizer(speechConfig);
|
||||||
const synthesizer = new SpeechSynthesizer(speechConfig, config);
|
|
||||||
|
|
||||||
if (content.startsWith('<speak>')) {
|
if (content.startsWith('<speak>')) {
|
||||||
/* microsoft enforces some properties and uses voice xml element so if the user did not supply do it for them */
|
/* microsoft enforces some properties and uses voice xml element so if the user did not supply do it for them */
|
||||||
@@ -329,11 +326,8 @@ const synthMicrosoft = async(logger, {
|
|||||||
break;
|
break;
|
||||||
case ResultReason.SynthesizingAudioCompleted:
|
case ResultReason.SynthesizingAudioCompleted:
|
||||||
stats.increment('tts.count', ['vendor:microsoft', 'accepted:yes']);
|
stats.increment('tts.count', ['vendor:microsoft', 'accepted:yes']);
|
||||||
|
resolve(Buffer.from(result.audioData));
|
||||||
synthesizer.close();
|
synthesizer.close();
|
||||||
fs.readFile(filePath, (err, data) => {
|
|
||||||
if (err) return reject(err);
|
|
||||||
resolve(data);
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logger.info({result}, 'synthAudio: (Microsoft) unexpected result');
|
logger.info({result}, 'synthAudio: (Microsoft) unexpected result');
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@jambonz/speech-utils",
|
"name": "@jambonz/speech-utils",
|
||||||
"version": "0.0.9",
|
"version": "0.0.11",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@jambonz/speech-utils",
|
"name": "@jambonz/speech-utils",
|
||||||
"version": "0.0.9",
|
"version": "0.0.11",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-polly": "^3.303.0",
|
"@aws-sdk/client-polly": "^3.303.0",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@jambonz/speech-utils",
|
"name": "@jambonz/speech-utils",
|
||||||
"version": "0.0.9",
|
"version": "0.0.11",
|
||||||
"description": "TTS-related speech utilities for jambonz",
|
"description": "TTS-related speech utilities for jambonz",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"author": "Dave Horton",
|
"author": "Dave Horton",
|
||||||
|
|||||||
Reference in New Issue
Block a user