Skip to content

Commit a334564

Browse files
authored
Merge pull request elizaOS#1996 from odilitime/hfi
fix: resolve translation type issue
2 parents 902b31e + 4e2dff2 commit a334564

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

packages/plugin-node/src/services/transcription.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,8 @@ export class TranscriptionService
355355
try {
356356
await this.saveDebugAudio(audioBuffer, "openai_input_original");
357357

358-
const convertedBuffer = await this.convertAudio(audioBuffer);
358+
const arrayBuffer = new Uint8Array(audioBuffer).buffer;
359+
const convertedBuffer = Buffer.from(await this.convertAudio(arrayBuffer)).buffer;
359360

360361
await this.saveDebugAudio(
361362
convertedBuffer,
@@ -407,15 +408,19 @@ export class TranscriptionService
407408

408409
await this.saveDebugAudio(audioBuffer, "local_input_original");
409410

410-
const convertedBuffer = await this.convertAudio(audioBuffer);
411+
const arrayBuffer = new Uint8Array(audioBuffer).buffer;
412+
const convertedBuffer = Buffer.from(await this.convertAudio(arrayBuffer)).buffer;
411413

412414
await this.saveDebugAudio(convertedBuffer, "local_input_converted");
413415

414416
const tempWavFile = path.join(
415417
this.CONTENT_CACHE_DIR,
416418
`temp_${Date.now()}.wav`
417419
);
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);
419424

420425
elizaLogger.debug(`Temporary WAV file created: ${tempWavFile}`);
421426

packages/plugin-node/src/services/video.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,8 @@ export class VideoService extends Service implements IVideoService {
347347
throw new Error("Transcription service not found");
348348
}
349349

350-
const transcript = await transcriptionService.transcribe(audioBuffer);
350+
const uintBuffer = new Uint8Array(audioBuffer).buffer;
351+
const transcript = await transcriptionService.transcribe(uintBuffer);
351352

352353
const endTime = Date.now();
353354
elizaLogger.log(

0 commit comments

Comments
 (0)