How can I create a voice chat radio using the Audio API?

I saw the new audio API, and saw others making a voice chat radio with it? The new API is kinda difficult to understand and I need help adding voice chat to my radio. Please help!
This is my current system:
it has a chat system with a mute button (activation)
video

Please help again. I need someone to guide me through the voice api and the voice chat stuff. I just need the voice chat to not only talk from the character, but with the player as well!

1 Like

very sorry i gotta bump this but it’s been a WHOPPING THREE HOURS!!! please help

VoiceChatService.UseAudioApi might be a good starting point idk.

(I haven’t messed around with the voice chat routing stuff that much but figure it out from there i guess?)

i did that already. i think i wasted my time :pensive:

afaik it then creates an AudioDeviceInput in each player which has some automatic under the hood wiring.

idk how to snap this wiring (might be internally defined and cant be destroyed), because i haven’t touched it much

i was hoping this post reached the right people. i guess not.

BUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUMP!!! please

From looking at the roblox api reference for a little bit, it looks like you should only need an AudioDeviceInput, and an AudioEmitter. Connect them together with a Wire.

I’ve already tried this before, and looked at many tutorials! I’m not sure as to why it doesn’t work, though I’ve looked at example places and such and tried the most simplest thing: An AudioDeviceInput connected to an AudioEmitter with a Wire. I made a testing place for this and this is the script:

function connectDevices(src, target)
	local wire = Instance.new("Wire")
	wire.Parent = target
	wire.SourceInstance = src
	wire.TargetInstance = target
end

game.Players.PlayerAdded:Connect(function(player)

	-- Create a new AudioDeviceInput
	local micIn = Instance.new("AudioDeviceInput")
	micIn.Parent = player
	micIn.Player = player
	micIn.Muted = false
	
	-- Assign a CharacterAdded event incase the player dies and respawns
	player.CharacterAdded:Connect(function(character)

		-- Make a new AudioEmitter with its Parent being the Character
		local emitter = Instance.new("AudioEmitter")
		emitter.Parent = character:WaitForChild("Head")
		-- Connect the devices together
		connectDevices(micIn, emitter)
		connectDevices(micIn, workspace.Part.AudioEmitter) -- I added this for testing; I made a part in workspace and added an AudioEmitter
	end)
end)

If I’m not mistaken, this should work in theory. Although I tested this in a live Roblox server and I don’t hear my voice coming out of that part.

image
This might be because of the newly added DistanceAttenuation property but i setted it to something like
image
this much and it still doesnt work. and I even made matching groups. I do not know what is going on and this is so confusing!

i need someone with experience on the audio api to help me out here :pray:

This script is a bit of a mess, but can you run this and see if it works? It works for me, and depending on if it works for you too, we’re close to pinpointing the issue for you (whether it’s in the script or an out the script configuration)

local players = game:GetService("Players")

local audioInput : AudioDeviceInput
local audioSpeaker : AudioEmitter

local audioListener : AudioListener
local audioOutput : AudioDeviceOutput

players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Wait()
	
	audioInput = Instance.new("AudioDeviceInput", player)
	audioInput.Player = player
	
	audioSpeaker = Instance.new("AudioEmitter")
	audioSpeaker.Parent = workspace.Part
	audioSpeaker.AudioInteractionGroup = "Default"
	audioSpeaker:SetDistanceAttenuation({[100] = 1})

	audioListener = Instance.new("AudioListener", player.Character.Head)
	audioListener.AudioInteractionGroup = "Default"
	audioListener:SetDistanceAttenuation({[100] = 1})
	
	audioOutput = Instance.new("AudioDeviceOutput", player)
	audioOutput.Player = player
	
	local wire1 = Instance.new("Wire", workspace.Part)

	wire1.SourceInstance = audioInput
	wire1.SourceName = "Output"

	wire1.TargetInstance = audioSpeaker
	wire1.TargetName = "Input"

	local wire2 = Instance.new("Wire", workspace.Part)

	wire2.SourceInstance = audioListener
	wire2.SourceName = "Output"

	wire2.TargetInstance = audioOutput
	wire2.TargetName = "Input"
end)

i recently got myself a system that can replay my voice and recreates the voice chat system. ill look into adding that script in a bit before i try something my own because im finally getting somewhere with this.