mirror of
https://github.com/jambonz/jambonz-api-server.git
synced 2026-10-04 02:04:18 +00:00
fix azure cannot download mp3 if encodingMp3 = true
This commit is contained in:
@@ -96,17 +96,27 @@ router.post('/Synthesize', async(req, res) => {
|
|||||||
let readStream = fs.createReadStream(filePath);
|
let readStream = fs.createReadStream(filePath);
|
||||||
if (['nuance', 'nvidia'].includes(cred.vendor) ||
|
if (['nuance', 'nvidia'].includes(cred.vendor) ||
|
||||||
(
|
(
|
||||||
process.env.JAMBONES_TTS_TRIM_SILENCE &&
|
(process.env.JAMBONES_TTS_TRIM_SILENCE || !process.env.JAMBONES_DISABLE_TTS_STREAMING) &&
|
||||||
['microsoft', 'azure'].includes(cred.vendor)
|
['microsoft', 'azure'].includes(cred.vendor)
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
if (encodingMp3) {
|
if (encodingMp3) {
|
||||||
readStream = readStream
|
readStream = pipeline(
|
||||||
.pipe(new PCMToMP3Encoder({
|
readStream,
|
||||||
|
new PCMToMP3Encoder({
|
||||||
channels: 1,
|
channels: 1,
|
||||||
sampleRate: 8000,
|
sampleRate: 8000,
|
||||||
bitRate: 128
|
bitRate: 128
|
||||||
}, logger));
|
}, logger),
|
||||||
|
(err) => {
|
||||||
|
if (err) {
|
||||||
|
logger.error('ttscache/Synthesize failed:', err);
|
||||||
|
if (!res.headersSent) {
|
||||||
|
res.status(500).end('Server error');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
contentType = 'application/octet-stream';
|
contentType = 'application/octet-stream';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user