• Gmod Voice Discord Bot Advice
    9 replies, posted
I recently saw a plugin on the [URL="https://www.gmodstore.com/scripts/view/3277/discord-garrys-mod-chat-relay-script"]Gmod Store [/URL] that relays chat message into a discord chat channel using webhooks. This has gotten me thinking, could I do the same thing with voice, i.e. a bot in a Discord server that would play all the voice chat that is current going on in your Gmod server. This would be extremely useful for server owners or admins, who could now join voice chat without joining the game. This means that not only could they covertly see what is going on in the server, this would also give them a way to listen to voice chat from their phones when away from computer. Now I've been looking into how I might accomplish this task, I have a decent understanding of gmod lua as a couple years ago I was running a few servers and enjoyed creating custom plugins for the servers. However my main coding knowledge is in web technologies (most notably Javascript). So I could quite easily create a Discord bot in nodejs, and I even found a [URL="https://github.com/jpemartins/speex.js/"]SPEEX Audio Codec[/URL] (gmods current voice codec) that is based in nodejs. My problem lies in that from what I can find there is no lua hooks that I can use to get the voice stream and pipe it somewhere. My assumption is that I would have to create a modified "vaudio_speex.dll" file that would allow me to split the stream, on one side still piping that audio to all the clients, and on the other into my nodejs program running on the same machine. Now I have basically no knowledge in modifying dll files (not to mention I'm currently working on a mac and therefore have .dylib files instead ). So I'm mostly looking for someone to either tell me if I'm heading in the right or wrong direction, or even better if someone that has some experience in something like this and would like to lend a hand. I also found the following two sourcemods, however I also don't have any experience with that so I wasn't sure if these would actually help me. (and they are quite old) [URL="https://forums.alliedmods.net/showthread.php?p=1627542?p=1627542"]Triskle - Broadcast In-Game Voice Comm[/URL] [URL="https://forums.alliedmods.net/showthread.php?t=145457"]VoiceHook - Developer preview of something.[/URL]
Just not worthy [sp]You would need to be a genius to do something like this, if someone didn't invent this, i doubt someone would come with a solution[/sp]
The only way I see this possible is that the message will play on the server after it was done. Basically: 1) Someone says something and the bot records it to an external location 2) The bot sends the server a message with the location of the sound file 3) The server plays the sound external file sound 4) The server sends a message back to the bot that it finished playing the sound file 5) The bot removes the external sound file. (If you want someone to say on discord and it will be sent to the game ^^) (Otherwise you'll need to do an opposite process)
[QUOTE=SleepyMode;52294812]The only way I see this possible is that the message will play on the server after it was done. Basically: 1) Someone says something and the bot records it to an external location 2) The bot sends the server a message with the location of the sound file 3) The server plays the sound external file sound 4) The server sends a message back to the bot that it finished playing the sound file 5) The bot removes the external sound file. (If you want someone to say on discord and it will be sent to the game ^^) (Otherwise you'll need to do an opposite process)[/QUOTE] I think you misunderstood what I'm looking to do and why it would be challenging. You are talking about going from discord into the game. That would actually be quite easy, as the discord library has methods to record discord voice chat to a file, then a simple playsound command on the gmod server and you would be done. The part that is an issue here, is that even if I wanted to do the reverse of what you're saying, ie recording gmod voice chat to a file and then playing it on the server, as it stands there is no way for me to record voice chat in gmod. This is what I'm hoping to figure out. Either recording to a file, or even better, streaming directly. Thank you for your input though, I appreciate anyone who takes the time to think of a solution! :smile:
[QUOTE=silverline;52295825]I think you misunderstood what I'm looking to do and why it would be challenging. You are talking about going from discord into the game. That would actually be quite easy, as the discord library has methods to record discord voice chat to a file, then a simple playsound command on the gmod server and you would be done. The part that is an issue here, is that even if I wanted to do the reverse of what you're saying, ie recording gmod voice chat to a file and then playing it on the server, as it stands there is no way for me to record voice chat in gmod. This is what I'm hoping to figure out. Either recording to a file, or even better, streaming directly. Thank you for your input though, I appreciate anyone who takes the time to think of a solution! :smile:[/QUOTE] I'm pretty sure there are plenty of ways to record voice in game, but that can only be done in the C++ level as long as I'm aware. You should read up a little on valve's developer wiki and maybe you'll find your solution.
I believe Gmod uses Steam's VOIP system by default and not the codec modules. Not sure if that would be easier or harder to detour. Perhaps Willox or Robot can clarify. I can do some more investigation this weekend, at the moment I'm trying to limit my Gmod exposure.
You could just setup a bot client to join the game and output speaker volume to a virtual microphone. Have that bot join the Discord chat and vuala. In-game voice in Discord :dance: But in all seriosness, there are a lot of bots on the bots.discord.pw site maybe you're looking for something like this? [url]https://bots.discord.pw/bots/293164737867284481[/url] or atleast one that would have the same functionality. My original idea may work. Add a client to the server that has a virtual mic that streams to a URL. which then is picked up by a web hook to be played over a discord bots mic in the voice channels? Not sure of all the specifics but i'm not sure there would be a way to do this with just modules and coding?
Gmod has been using steam voip forever now, you can hack together a bot that records people with playercanhearplayersvoice and make it send shit but that would be too much work for something like this
Alright, so I noticed two people have said that gmod used the steam voip, so I started looking into that. From what I can find (and there really isn't a lot) Gmod could be using the Steamworks Voice Chat api. I believe that it's still using the SPEEX audio codec that I originally had thought, however it looks like steamworks voice is actually P2P. This is a big problem as that means this voice data never goes through the server, and it only gets sent between the clients. If this is true I will most likely have to go with what Richtofen had said: [QUOTE=Richtofen;52302125]You could just setup a bot client to join the game and output speaker volume to a virtual microphone. Have that bot join the Discord chat and vuala. In-game voice in Discord :dance:[/QUOTE] Which I believe I have seen a headless gmod client written in nodejs before that I'm going to try to hunt down to see it it might be helpful. The downside here is I believe bots logged in under user accounts in steam is a generally against their TOS. [QUOTE=Kevlon;52302273]Gmod has been using steam voip forever now, you can hack together a bot that records people with playercanhearplayersvoice and make it send shit but that would be too much work for something like this[/QUOTE] Side note, Kevlon, thank you for pointing me in the direction of Steam Voip, however I would just like to note that the hook you had mentioned "playercanhearplayersvoice" only tells that a player is talking, but does not give me any voice data. The Main topic of discussion is how we can actually retrieve voice data from the clients, preferable server side. But again, thanks everyone for your input thus far!:dance:
[QUOTE=silverline;52302468] Side note, Kevlon, thank you for pointing me in the direction of Steam Voip, however I would just like to note that the hook you had mentioned "playercanhearplayersvoice" only tells that a player is talking, but does not give me any voice data. The Main topic of discussion is how we can actually retrieve voice data from the clients, preferable server side. But again, thanks everyone for your input thus far!:dance:[/QUOTE] You would use it for a bot that is connected in the game world that would be able to hear everybody and transmit it. But it would require way too much work for something so simple, like at least a binary module for decent voice recording and timing
Sorry, you need to Log In to post a reply to this thread.