Rei-x / discord-speech-recognition

Speech to text extension for discord.js
https://npmjs.com/package/discord-speech-recognition
MIT License
57 stars 23 forks source link

How to ignore all bots except one #40

Closed Zoom-Developer closed 2 years ago

Zoom-Developer commented 2 years ago

I need my bot to ignore all bots except for one of mine. I could not find this functionality not in discord.js, not in this library

Rei-x commented 2 years ago

I added option where you can customise who should be ignored from speech recognition in #41 You could do something like this to ignore all bots except yours:

addSpeechEvent(client, {
  shouldProcessSpeech: (user) => {
    if (user.bot && user.username !== "Your bot name") {
      return false;
    }
    return true;
  }
}

Is this what you want?

Zoom-Developer commented 2 years ago

Thanks, yes! I'm not sure if it's worth posting here, but I thought I'd say it straight in this question, I found a bug where sometimes the speech is called multiple times, with slightly changed content, which is not the best result. How can I fix this?

Rei-x commented 2 years ago

Can you give a way of reproduction?

Zoom-Developer commented 2 years ago

I don't know English very well, what do you mean by reproduction?

Rei-x commented 2 years ago

When does this problem occur? Is it random or maybe after multiple people/bots joins the voice channel?

Zoom-Developer commented 2 years ago

No, 1 person says and about once every 10-15 calls the call is repeated several times, I assume that this is somehow connected with Google's speech recognition

Rei-x commented 2 years ago

Okay, I think I found the reason for this problem

const opusStream = receiver.subscribe(userId, {
        end: {
          behavior: EndBehaviorType.AfterSilence,
          duration: 1000,
        },
      });

Bot is waiting 1 second after someone has stopped speaking and when someone stops talking for specific time (more than 300ms, less than 1 second) the speaking event is fired again, but recent one is still listening for audio, so there are 2 speech events for one speaking session. Don't worry if you don't understand it (it's really hard for me to explain it well), I will fix it as soon as possible.

Zoom-Developer commented 2 years ago

Look forward to)

Rei-x commented 2 years ago

Update discord-speech-recognition package, this issue should be fixed now and you can use this new option shouldProcess to listen only to your bot

Zoom-Developer commented 2 years ago

Thanks