DiscordSpeechBot
DiscordSpeechBot copied to clipboard
Is there going to be a v13 version soon?
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 :)
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 ....", ...)
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
You are an amazing individual. Thank you, and make sure to have a fantastic day!
I'm glad I could help :)
I published the discord bot. Feel free to test it :) https://github.com/ShadowLp174/stt-example-bot
I'll test it out when I get free soon! Thank you so much!!