fix(core.gbapp): Added IBM for TTS and removed MSFT while it does not compile on AZR.
This commit is contained in:
parent
2a816049bc
commit
12c9bea167
1 changed files with 12 additions and 11 deletions
|
@ -306,25 +306,26 @@ export class GBConversationalService {
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
text: text,
|
text: text,
|
||||||
accept: 'audio/ogg;codecs=vorbis', // ; rate=44100
|
accept: 'audio/wav; rate=44100',
|
||||||
voice: 'pt-BR_IsabelaVoice'
|
voice: 'pt-BR_IsabelaVoice'
|
||||||
};
|
};
|
||||||
|
|
||||||
// Migrated to IBM from MSFT, as it own package do not compile on Azure Web App.
|
// Migrated to IBM from MSFT, as it own package do not compile on Azure Web App.
|
||||||
|
|
||||||
let res = await textToSpeech.synthesize(params);
|
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 oggFilenameOnly = `tmp${name}.ogg`;
|
||||||
const oggFilename = `work/${oggFilenameOnly}`;
|
const oggFilename = `work/${oggFilenameOnly}`;
|
||||||
|
const output = fs.createWriteStream(oggFilename);
|
||||||
let body = '';
|
const transcoder = new prism.FFmpeg({
|
||||||
res.result.on('data',(chunck) => {
|
args: ['-analyzeduration', '0', '-loglevel', '0', '-f', 'opus', '-ar', '16000', '-ac', '1']
|
||||||
body += chunck;
|
|
||||||
});
|
|
||||||
|
|
||||||
res.result.on('end', () => {
|
|
||||||
fs.writeFileSync(oggFilename, body);
|
|
||||||
res.statusCode = 200;
|
|
||||||
});
|
});
|
||||||
|
fs.createReadStream(waveFilename).pipe(transcoder).pipe(output);
|
||||||
|
|
||||||
let url = urlJoin(GBServer.globals.publicAddress, 'audios', oggFilenameOnly);
|
let url = urlJoin(GBServer.globals.publicAddress, 'audios', oggFilenameOnly);
|
||||||
resolve(url);
|
resolve(url);
|
||||||
|
|
Loading…
Add table
Reference in a new issue