mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-25 22:57:44 -06:00
conversion of audios for sending recorded audio, now it is possible to send mp3 audios and not just ogg
This commit is contained in:
@@ -1146,8 +1146,8 @@ export class WAStartupService {
|
||||
let outputAudio: string;
|
||||
|
||||
if (isURL(audio)) {
|
||||
outputAudio = `${join(process.cwd(), 'temp', 'audio.opus')}`;
|
||||
tempAudioPath = `${join(process.cwd(), 'temp', 'audio.mp3')}`;
|
||||
outputAudio = `${join(process.cwd(), 'temp', 'audio.mp4')}`;
|
||||
tempAudioPath = `${join(process.cwd(), 'temp', 'audioTemp.mp3')}`;
|
||||
|
||||
const response = await axios.get(audio, { responseType: 'arraybuffer' });
|
||||
fs.writeFileSync(tempAudioPath, response.data);
|
||||
@@ -1161,7 +1161,8 @@ export class WAStartupService {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
exec(
|
||||
`${ffmpegPath.path} -i ${tempAudioPath} -c:a libopus ${outputAudio} -y`,
|
||||
// `${ffmpegPath.path} -i ${tempAudioPath} -c:a libopus ${outputAudio} -y`,
|
||||
`${ffmpegPath.path} -i ${tempAudioPath} -vn -ab 128k -ar 44100 -f ipod ${outputAudio} -y`,
|
||||
(error, _stdout, _stderr) => {
|
||||
fs.unlinkSync(tempAudioPath);
|
||||
if (error) reject(error);
|
||||
@@ -1179,11 +1180,9 @@ export class WAStartupService {
|
||||
data.number,
|
||||
{
|
||||
audio: Buffer.from(audio, 'base64'),
|
||||
// audio: isURL(data.audioMessage.audio)
|
||||
// ? { url: data.audioMessage.audio }
|
||||
// : Buffer.from(data.audioMessage.audio, 'base64'),
|
||||
ptt: true,
|
||||
mimetype: 'audio/ogg; codecs=opus',
|
||||
// mimetype: 'audio/ogg; codecs=opus',
|
||||
mimetype: 'audio/mp4',
|
||||
},
|
||||
{ presence: 'recording', delay: data?.options?.delay },
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user