mirror of
https://github.com/jambonz/speech-utils.git
synced 2026-07-04 19:31:49 +00:00
Merge pull request #17 from jambonz/fix/imterim_audio_cut
fix: use synthesized audio data directly from microsoft sdk
This commit is contained in:
+2
-7
@@ -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,
|
||||
@@ -302,8 +301,7 @@ const synthMicrosoft = async(logger, {
|
||||
if (!content.startsWith('<speak')) content = `<speak>${text}</speak>`;
|
||||
}
|
||||
speechConfig.speechSynthesisOutputFormat = SpeechSynthesisOutputFormat.Audio16Khz32KBitRateMonoMp3;
|
||||
const config = AudioConfig.fromAudioFileOutput(filePath);
|
||||
const synthesizer = new SpeechSynthesizer(speechConfig, config);
|
||||
const synthesizer = new SpeechSynthesizer(speechConfig);
|
||||
|
||||
if (content.startsWith('<speak>')) {
|
||||
/* microsoft enforces some properties and uses voice xml element so if the user did not supply do it for them */
|
||||
@@ -330,10 +328,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');
|
||||
|
||||
Reference in New Issue
Block a user