Compare commits

..
8 Commits
Author SHA1 Message Date
Dave Horton 0d58954537 bump version 2023-04-01 10:48:05 -04:00
Dave Horton 7c0eafded3 Merge pull request #18 from jambonz/fix/microsoft-buffer
fix: microsft retrun arrayBuffer not buffer, convert it now to buffer
2023-04-01 10:46:40 -04:00
Quan HL ab7d145288 fix: microsft retrun arrayBuffer not buffer, convert it now to buffer 2023-04-01 13:39:33 +07:00
Dave Horton 11746d3f22 bump version and minor changes 2023-03-31 20:05:07 -04:00
Dave Horton 3fcfbd10a1 Merge pull request #17 from jambonz/fix/imterim_audio_cut
fix: use synthesized audio data directly from microsoft sdk
2023-03-31 20:03:38 -04:00
Quan HL df8acbed0e fix: audioData is getter 2023-04-01 06:58:55 +07:00
Quan HL 4296ed7256 fix: user synthesized audio data directly from microsoft sdk 2023-04-01 06:37:33 +07:00
Quan HL f4b271c7b3 fix: user synthesized audio data directly from microsoft sdk 2023-04-01 06:36:15 +07:00
3 changed files with 5 additions and 11 deletions
+2 -8
View File
@@ -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');
+2 -2
View File
@@ -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
View File
@@ -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",