Skip to content

Commit

Permalink
fix: memory access out of bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
nekomeowww committed Jan 16, 2025
1 parent 73ec604 commit 59daece
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions services/discord-bot/src/bots/discord/commands/summon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 59daece

Please sign in to comment.