diff --git a/services/discord-bot/src/bots/discord/commands/summon.ts b/services/discord-bot/src/bots/discord/commands/summon.ts index e62599e..6f5a637 100644 --- a/services/discord-bot/src/bots/discord/commands/summon.ts +++ b/services/discord-bot/src/bots/discord/commands/summon.ts @@ -294,7 +294,12 @@ export class VoiceManager extends EventEmitter { opusDecoder.on('close', closeHandler) receiveStream?.on('close', streamCloseHandler) - pipeline(receiveStream, opusDecoder, err => this.logger.withError(err).error('Opus decoding pipeline error')) + pipeline(receiveStream, opusDecoder, (err) => { + this.logger.withError(err).error('Opus decoding pipeline error') + if (err.message.includes('memory access out of bounds')) { + throw err + } + }) this.logger.log(`Monitoring user: ${member.displayName}`) await this.handleUserStream(userId, member, member.guild.id, channelId, opusDecoder) @@ -439,24 +444,24 @@ export class VoiceManager extends EventEmitter { const result = await openaiTranscribe(wavBuffer) const transcriptionText = result - const discordContext = { - channelId, - guildId, - guildMember: member, - } satisfies Discord + if (transcriptionText && isValidTranscription(transcriptionText)) { + state.transcriptionText += transcriptionText - this.airiClient.send({ - type: 'input:text:voice', - data: { transcription: transcriptionText, discord: discordContext }, - }) + const discordContext = { + channelId, + guildId, + guildMember: member, + } satisfies Discord - this.airiClient.send({ - type: 'input:text', - data: { text: transcriptionText, discord: discordContext }, - }) + this.airiClient.send({ + type: 'input:text:voice', + data: { transcription: transcriptionText, discord: discordContext }, + }) - if (transcriptionText && isValidTranscription(transcriptionText)) { - state.transcriptionText += transcriptionText + this.airiClient.send({ + type: 'input:text', + data: { text: transcriptionText, discord: discordContext }, + }) } if (state.transcriptionText.length) { this.cleanupAudioPlayer(this.activeAudioPlayer)