File tree 2 files changed +10
-4
lines changed
packages/plugin-node/src/services
2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -355,7 +355,8 @@ export class TranscriptionService
355
355
try {
356
356
await this . saveDebugAudio ( audioBuffer , "openai_input_original" ) ;
357
357
358
- const convertedBuffer = await this . convertAudio ( audioBuffer ) ;
358
+ const arrayBuffer = new Uint8Array ( audioBuffer ) . buffer ;
359
+ const convertedBuffer = Buffer . from ( await this . convertAudio ( arrayBuffer ) ) . buffer ;
359
360
360
361
await this . saveDebugAudio (
361
362
convertedBuffer ,
@@ -407,15 +408,19 @@ export class TranscriptionService
407
408
408
409
await this . saveDebugAudio ( audioBuffer , "local_input_original" ) ;
409
410
410
- const convertedBuffer = await this . convertAudio ( audioBuffer ) ;
411
+ const arrayBuffer = new Uint8Array ( audioBuffer ) . buffer ;
412
+ const convertedBuffer = Buffer . from ( await this . convertAudio ( arrayBuffer ) ) . buffer ;
411
413
412
414
await this . saveDebugAudio ( convertedBuffer , "local_input_converted" ) ;
413
415
414
416
const tempWavFile = path . join (
415
417
this . CONTENT_CACHE_DIR ,
416
418
`temp_${ Date . now ( ) } .wav`
417
419
) ;
418
- fs . writeFileSync ( tempWavFile , convertedBuffer ) ;
420
+
421
+ // Convert the ArrayBuffer to a Uint8Array which fs.writeFileSync can handle
422
+ const uint8Array = new Uint8Array ( convertedBuffer ) ;
423
+ fs . writeFileSync ( tempWavFile , uint8Array ) ;
419
424
420
425
elizaLogger . debug ( `Temporary WAV file created: ${ tempWavFile } ` ) ;
421
426
Original file line number Diff line number Diff line change @@ -347,7 +347,8 @@ export class VideoService extends Service implements IVideoService {
347
347
throw new Error ( "Transcription service not found" ) ;
348
348
}
349
349
350
- const transcript = await transcriptionService . transcribe ( audioBuffer ) ;
350
+ const uintBuffer = new Uint8Array ( audioBuffer ) . buffer ;
351
+ const transcript = await transcriptionService . transcribe ( uintBuffer ) ;
351
352
352
353
const endTime = Date . now ( ) ;
353
354
elizaLogger . log (
You can’t perform that action at this time.
0 commit comments