fix(core.gbapp): Added IBM for TTS and removed MSFT while it does not compile on AZR.

This commit is contained in:
Rodrigo Rodriguez 2021-12-31 08:26:41 -03:00
parent 2a816049bc
commit 12c9bea167

View file

@ -306,25 +306,26 @@ export class GBConversationalService {
const params = {
text: text,
accept: 'audio/ogg;codecs=vorbis', // ; rate=44100
accept: 'audio/wav; rate=44100',
voice: 'pt-BR_IsabelaVoice'
};
// Migrated to IBM from MSFT, as it own package do not compile on Azure Web App.
let res = await textToSpeech.synthesize(params);
const waveFilename = `work/tmp${name}.pcm`;
let audio = '';
audio = await textToSpeech.repairWavHeaderStream(res.result);
fs.writeFileSync(waveFilename, audio);
const oggFilenameOnly = `tmp${name}.ogg`;
const oggFilename = `work/${oggFilenameOnly}`;
let body = '';
res.result.on('data',(chunck) => {
body += chunck;
});
res.result.on('end', () => {
fs.writeFileSync(oggFilename, body);
res.statusCode = 200;
const output = fs.createWriteStream(oggFilename);
const transcoder = new prism.FFmpeg({
args: ['-analyzeduration', '0', '-loglevel', '0', '-f', 'opus', '-ar', '16000', '-ac', '1']
});
fs.createReadStream(waveFilename).pipe(transcoder).pipe(output);
let url = urlJoin(GBServer.globals.publicAddress, 'audios', oggFilenameOnly);
resolve(url);