@@ -1291,17 +1291,18 @@ export class WAStartupService {
12911291 let outputAudio : string ;
12921292
12931293 if ( isURL ( audio ) ) {
1294- outputAudio = `${ join ( process . cwd ( ) , 'temp' , 'audio.mp4' ) } ` ;
1295- tempAudioPath = `${ join ( process . cwd ( ) , 'temp' , 'audioTemp.mp3' ) } ` ;
1296-
12971294 const timestamp = new Date ( ) . getTime ( ) ;
1295+ outputAudio = `${ join ( process . cwd ( ) , 'temp' , `${ timestamp } .mp4` ) } ` ;
1296+ tempAudioPath = `${ join ( process . cwd ( ) , 'temp' , `temp-${ timestamp } .mp3` ) } ` ;
1297+
12981298 const url = `${ audio } ?timestamp=${ timestamp } ` ;
12991299
13001300 const response = await axios . get ( url , { responseType : 'arraybuffer' } ) ;
13011301 fs . writeFileSync ( tempAudioPath , response . data ) ;
13021302 } else {
1303- outputAudio = `${ join ( process . cwd ( ) , 'temp' , 'audio.mp4' ) } ` ;
1304- tempAudioPath = `${ join ( process . cwd ( ) , 'temp' , 'audioTemp.mp3' ) } ` ;
1303+ const timestamp = new Date ( ) . getTime ( ) ;
1304+ outputAudio = `${ join ( process . cwd ( ) , 'temp' , `${ timestamp } .mp4` ) } ` ;
1305+ tempAudioPath = `${ join ( process . cwd ( ) , 'temp' , `temp-${ timestamp } .mp3` ) } ` ;
13051306
13061307 const audioBuffer = Buffer . from ( audio , 'base64' ) ;
13071308 fs . writeFileSync ( tempAudioPath , audioBuffer ) ;
@@ -1323,7 +1324,7 @@ export class WAStartupService {
13231324 const convert = await this . processAudio ( data . audioMessage . audio ) ;
13241325 if ( typeof convert === 'string' ) {
13251326 const audio = fs . readFileSync ( convert ) . toString ( 'base64' ) ;
1326- return this . sendMessageWithTyping < AnyMessageContent > (
1327+ const result = this . sendMessageWithTyping < AnyMessageContent > (
13271328 data . number ,
13281329 {
13291330 audio : Buffer . from ( audio , 'base64' ) ,
@@ -1332,6 +1333,10 @@ export class WAStartupService {
13321333 } ,
13331334 { presence : 'recording' , delay : data ?. options ?. delay } ,
13341335 ) ;
1336+
1337+ fs . unlinkSync ( convert ) ;
1338+
1339+ return result ;
13351340 } else {
13361341 throw new InternalServerErrorException ( convert ) ;
13371342 }
0 commit comments