Detecting Player Voice

I’m trying to use the new AudioAPI to detect when a player is talking via voicechat, I already enabled “UseAudioApi” option on the VoiceChatService and I tried this piece of code

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local AudioAnalyzer = Instance.new("AudioAnalyzer")
		AudioAnalyzer.Parent = Character
		
		local AudioListener = Instance.new("AudioListener")
		local Attachment = Instance.new("Attachment",Character.HumanoidRootPart)
		AudioListener.Parent = Attachment
		Character:WaitForChild("AudioEmitter").AudioInteractionGroup = "2B"
		AudioListener.AudioInteractionGroup = "2B"
		
		
		local Wire = Instance.new("Wire")
		Wire.Parent = Character
		Wire.SourceInstance = AudioListener
		Wire.TargetInstance = AudioAnalyzer
		while wait() do
		if AudioAnalyzer.RmsLevel > 0 then
			print("VOICE DETECTED")
			end
			end
	end)
end)

however I can’t seem to get any prints in the console (the script is located in ServerScriptService)

4 Likes

I’m not very good at coding, but I think the double end might be a problem.

1 Like

Nah that isn’t it chief, you need that second end for the while loop.

1 Like

oh, sorry, I didn’t realize there was a while loop.

1 Like

I don’t think roblox has made it possible yet to detect player voice, but I’m not updated that much with the announcements and what not so I might be wrong:

Sorry isn’t enough arctic fox, its time to go back to antartica.

How did you guys even adapt to the climate of antartica, and then adapt to using devices like keyboards to use the devforum?! Your species is astonishing…

awh :frowning: That is very unfortunate

Ok but seriously how did your species learn to use the devforum

1 Like

That’s a very long story, uhh… SHHHH… Also, it seems you found your solution yourself.

Fine i wont tell anyone.

30char

I’m not an expert at using this but after doing a quick skim on the documentation would you need to use this?

1 Like

Documentation can be useful, but it won’t tell you every way to make everything.

1 Like

I don’t think the audio listener goes under an attachment, there’s a specific place it’s gotta be, have you checked the radio example .rbxl file?

1 Like

It’s a reference artic fox, clearly you haven’t evolved enough.

I’m already using that as you can see in the script

1 Like

It’s possible since the AudioApi update, there’s even games on roblox which uses it.

I checked the roblox documentations, it either has to go under an attachment, camera or PVInstance

I hope you realize you used 2 operators to check for the same thing

if not success -- if success == false then

if success == false -- same thing as the one shown above, except more defined
1 Like

huh

30char

1 Like

When you say

if not success -- if success == false

it’s checking if success == false, but then you add and if even though you’ve already checked if it were false, you’re checking for the same thing twice, which just makes your code look unprofessional.

nevermind, that was not you :skull:

1 Like