From f4b271c7b3a026a53c41eda95c06f45f6693ffe7 Mon Sep 17 00:00:00 2001 From: Quan HL Date: Sat, 1 Apr 2023 06:36:15 +0700 Subject: [PATCH 1/3] fix: user synthesized audio data directly from microsoft sdk --- lib/synth-audio.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/synth-audio.js b/lib/synth-audio.js index d0796f9..1fe45fd 100644 --- a/lib/synth-audio.js +++ b/lib/synth-audio.js @@ -302,8 +302,7 @@ const synthMicrosoft = async(logger, { if (!content.startsWith('${text}`; } speechConfig.speechSynthesisOutputFormat = SpeechSynthesisOutputFormat.Audio16Khz32KBitRateMonoMp3; - const config = AudioConfig.fromAudioFileOutput(filePath); - const synthesizer = new SpeechSynthesizer(speechConfig, config); + const synthesizer = new SpeechSynthesizer(speechConfig); if (content.startsWith('')) { /* microsoft enforces some properties and uses voice xml element so if the user did not supply do it for them */ @@ -330,10 +329,7 @@ const synthMicrosoft = async(logger, { case ResultReason.SynthesizingAudioCompleted: stats.increment('tts.count', ['vendor:microsoft', 'accepted:yes']); synthesizer.close(); - fs.readFile(filePath, (err, data) => { - if (err) return reject(err); - resolve(data); - }); + resolve(result.audioData()); break; default: logger.info({result}, 'synthAudio: (Microsoft) unexpected result'); From 4296ed72562c905001bdc2e3458d9af57179efb2 Mon Sep 17 00:00:00 2001 From: Quan HL Date: Sat, 1 Apr 2023 06:37:33 +0700 Subject: [PATCH 2/3] fix: user synthesized audio data directly from microsoft sdk --- lib/synth-audio.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/synth-audio.js b/lib/synth-audio.js index 1fe45fd..79ce7cf 100644 --- a/lib/synth-audio.js +++ b/lib/synth-audio.js @@ -9,7 +9,6 @@ const sdk = require('microsoft-cognitiveservices-speech-sdk'); const TextToSpeechV1 = require('ibm-watson/text-to-speech/v1'); const { IamAuthenticator } = require('ibm-watson/auth'); const { - AudioConfig, ResultReason, SpeechConfig, SpeechSynthesizer, From df8acbed0ec06bbd4f2907d9021c9eddfb232f7a Mon Sep 17 00:00:00 2001 From: Quan HL Date: Sat, 1 Apr 2023 06:58:55 +0700 Subject: [PATCH 3/3] fix: audioData is getter --- lib/synth-audio.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/synth-audio.js b/lib/synth-audio.js index 79ce7cf..9067c89 100644 --- a/lib/synth-audio.js +++ b/lib/synth-audio.js @@ -328,7 +328,7 @@ const synthMicrosoft = async(logger, { case ResultReason.SynthesizingAudioCompleted: stats.increment('tts.count', ['vendor:microsoft', 'accepted:yes']); synthesizer.close(); - resolve(result.audioData()); + resolve(result.audioData); break; default: logger.info({result}, 'synthAudio: (Microsoft) unexpected result');