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

Change Language #31

Closed FaxBRz closed 2 years ago

FaxBRz commented 2 years ago

Would there be a way to explain to a layman, how do I make the module accept another spoken language?

Rei-x commented 2 years ago
const client = new Client({
  intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_VOICE_STATES],
});
addSpeechEvent(client, { lang: "pl-PL" });

you just need to pass second argument to addSpeechEvent function, in example above it uses polish language this is the list of language codes (most of them should work): http://www.lingoes.net/en/translator/langcode.htm

if you still have some trouble with setting this up, don't hesitate to ask

FaxBRz commented 2 years ago

It worked perfectly, thanks, however sometimes I get the error "cannot send empty message" and the bot crashes

Rei-x commented 2 years ago
client.on("speech", async (msg) => {
  if (!msg.content) return;
  msg.author.send(msg.content);
});

Just check if message content is truthy, sometimes it can be undefined or empty string (when module didn't recognize speech properly).

FaxBRz commented 2 years ago

It worked perfectly, thank you very much.