Detecting Voicechat inputs

I’m trying to make an obby game like “Voice Control :loud_sound: [WORLD 2 UPDATE]” where the game detects voice inputs from the voicechatservice and runs some functions if there’s audio/voice present.

after some research I figured that the only way to do this is to use the beta AudioAPI but I couldn’t figure out how to achieve this goal. I know that it’s possible because the game I mentioned does it.

Thanks for any help!

5 Likes

Check out the audio api announcement.
Once VoiceChatService.UseAudioApi is enabled you will notice the following:

Players receive the AudioDeviceInput instance
image

Characters receive the AudioEmitter instance.
image

Now if I am not mistaken you can use the AudioAnalyzer to check when they are speaking and so on.

2 Likes

I already enabled that option and I saw those instances, I just don’t know what to do next

1 Like

AudioAnalyzer

1 Like

so what exactly do I wire into the AudioAnalyzer

1 Like

fixed myself

local Input = game.Players.LocalPlayer.AudioDeviceInput
local AudioAnalyzer = Instance.new("AudioAnalyzer",game.Players.LocalPlayer.Character)
local Wire = Instance.new("Wire",game.Players.LocalPlayer.Character)
Wire.SourceInstance = Input
Wire.TargetInstance = AudioAnalyzer

while wait() do
	print(AudioAnalyzer.RmsLevel)
end
1 Like

Possible solutions I can recommend:

  • It’s not recommended to use wait() in today’s standards, use task.wait() instead.
  • Since it doesn’t require yielding you can use RunService.RenderStepped instead of a while loop.
  • If you want a bit unique way you can pick an average between PeakLevel and RmsLevel.
    i said that last sentence because i’m also working on another form of a voice-controlled movement game
1 Like