Rei-x / discord-speech-recognition

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

activate speech with a special word #29

Closed J3SUCR1ST0 closed 2 years ago

J3SUCR1ST0 commented 2 years ago

hi mate, first of all ty for creating this, it´s really usefull. i have question for u, i want the bot to start the speech recognition when it hears a special word like "andrea" for example, because it stats the speech recogniton every time someone stops talking. my english id bad, if you dont understand something let me know

Rei-x commented 2 years ago

Hi! If I understand you right, the easiest way to do this is to check if voice message content starts with special world, like "andrea". I made music bot, that accepts voice commands only if they start with "alexa". You can check the repository here: https://github.com/Rei-x/discord-music-voice-control

Basically, check if message content starts with this special word and then do whatever you want. Here is code example:

client.on("speech", async (message) => {
  if (!message.content) return;
  if (!message.content.toLowerCase().startsWith("andrea")) return;

  doSomething()
}

That's what you meant?

J3SUCR1ST0 commented 2 years ago

gonna try that ty so much