mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-13 07:04:50 -06:00
feat(audio): support LPCM and fix waveform distortion
This commit is contained in:
parent
614ad7cbdf
commit
44e0ff2250
@ -58,6 +58,7 @@
|
|||||||
"@prisma/client": "^6.1.0",
|
"@prisma/client": "^6.1.0",
|
||||||
"@sentry/node": "^8.47.0",
|
"@sentry/node": "^8.47.0",
|
||||||
"amqplib": "^0.10.5",
|
"amqplib": "^0.10.5",
|
||||||
|
"audio-decode": "^2.2.3",
|
||||||
"axios": "^1.7.9",
|
"axios": "^1.7.9",
|
||||||
"baileys": "github:EvolutionAPI/Baileys",
|
"baileys": "github:EvolutionAPI/Baileys",
|
||||||
"class-validator": "^0.14.1",
|
"class-validator": "^0.14.1",
|
||||||
|
@ -3024,6 +3024,8 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
inputAudioStream.end(audioBuffer);
|
inputAudioStream.end(audioBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isLpcm = isURL(audio) && /\.lpcm($|\?)/i.test(audio);
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const outputAudioStream = new PassThrough();
|
const outputAudioStream = new PassThrough();
|
||||||
const chunks: Buffer[] = [];
|
const chunks: Buffer[] = [];
|
||||||
@ -3041,7 +3043,14 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
|
|
||||||
ffmpeg.setFfmpegPath(ffmpegPath.path);
|
ffmpeg.setFfmpegPath(ffmpegPath.path);
|
||||||
|
|
||||||
ffmpeg(inputAudioStream)
|
let command = ffmpeg(inputAudioStream);
|
||||||
|
|
||||||
|
if (isLpcm) {
|
||||||
|
this.logger.verbose('Detected LPCM input – applying raw PCM settings');
|
||||||
|
command = command.inputFormat('s16le').inputOptions(['-ar', '24000', '-ac', '1']);
|
||||||
|
}
|
||||||
|
|
||||||
|
command
|
||||||
.outputFormat('ogg')
|
.outputFormat('ogg')
|
||||||
.noVideo()
|
.noVideo()
|
||||||
.audioCodec('libopus')
|
.audioCodec('libopus')
|
||||||
|
Loading…
Reference in New Issue
Block a user