DiscordSpeechBot icon indicating copy to clipboard operation
DiscordSpeechBot copied to clipboard

Is there going to be a v13 version soon?

Open EBMOfficial opened this issue 3 years ago • 7 comments

EBMOfficial avatar Feb 20 '22 04:02 EBMOfficial

I'm not sure if this repository is still active, but if need the transcriber for v13, then have a look at this. I'll be publishing a music bot with voice commands soon :)

ShadowLp174 avatar Mar 18 '22 13:03 ShadowLp174

You can then use something like this to parse the commands:

function parse(string, possible) {
    let output = string.repeat(1);
    string = string.replace("/\./g", "");
    string = string.toLowerCase().replace("music", "").trim();
    if (string.includes(" ")) string = string.split(" ")[0];
    string = string.trim();
    if (!possible.includes(string)) return false;
    output = output.replace(/\./g, "").toLowerCase().replace("music", "").trim();
    return output;
  }

// Usage:
let command = parse(transcribedText, ["play", "pause", "resume", "skip", "shuffle", "list"]);

It will give you a well-formated command or false (if not valid) for further processing. ("play ...", "pause ...", "resume ....", ...)

ShadowLp174 avatar Mar 18 '22 14:03 ShadowLp174

All-in-all you can do something like this:

connection.receiver.speaking.on("start", (userId) => {
    const user = client.users.cache.get(userId);
    console.log("Listening to " + user.username);
    transcriber.listen(connection.receiver, userId, user).then((data) => {
      if (!data.transcript.text) return;
      let parsed = parse(data.transcript.text, ["play", "pause", "resume", "skip", "shuffle", "list"]);
      if (!parsed) {return;}
      
      // do whatever you want with the parsed command
      executeVoiceCommand(parsed);
    });
 });

Where you have to put this snippet, is declared in the Transcriber repository

Happy coding :D

ShadowLp174 avatar Mar 18 '22 14:03 ShadowLp174

You are an amazing individual. Thank you, and make sure to have a fantastic day!

EBMOfficial avatar Mar 18 '22 23:03 EBMOfficial

I'm glad I could help :)

ShadowLp174 avatar Mar 19 '22 14:03 ShadowLp174

I published the discord bot. Feel free to test it :) https://github.com/ShadowLp174/stt-example-bot

ShadowLp174 avatar Mar 19 '22 18:03 ShadowLp174

I'll test it out when I get free soon! Thank you so much!!

EBMOfficial avatar Mar 20 '22 03:03 EBMOfficial