mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-13 07:04:50 -06:00
Merge pull request #1574 from edisonmartinsmkt/develop
feat(audio): support LPCM and fix waveform distortion
This commit is contained in:
commit
9e1f9cbb83
@ -58,6 +58,7 @@
|
||||
"@prisma/client": "^6.1.0",
|
||||
"@sentry/node": "^8.47.0",
|
||||
"amqplib": "^0.10.5",
|
||||
"audio-decode": "^2.2.3",
|
||||
"axios": "^1.7.9",
|
||||
"baileys": "github:EvolutionAPI/Baileys",
|
||||
"class-validator": "^0.14.1",
|
||||
|
@ -3024,6 +3024,8 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
inputAudioStream.end(audioBuffer);
|
||||
}
|
||||
|
||||
const isLpcm = isURL(audio) && /\.lpcm($|\?)/i.test(audio);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const outputAudioStream = new PassThrough();
|
||||
const chunks: Buffer[] = [];
|
||||
@ -3041,7 +3043,14 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
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')
|
||||
.noVideo()
|
||||
.audioCodec('libopus')
|
||||
|
Loading…
Reference in New Issue
Block a user