microphone.stop
Stop recording and receive a PCM WAVE buffer on the game thread.
Syntax
ue.microphone.stop(capture_id: integer, callback: function) -> booleanThe call requests capture to stop immediately. Encoding and callback delivery are asynchronous.
ue.microphone.stop(capture_id, function(result)
if not result.ok then
ue.log.error(result.error)
return
end
-- result.wav is a binary-safe PCM RIFF/WAVE string.
print(result.duration, result.sample_rate, result.channels, #result.wav)
ue.http.request({
url = "https://api.example.test/transcribe",
method = "POST",
headers = {
Authorization = "Bearer " .. assert(ue.secrets.get("EXAMPLE_API_KEY"))
},
multipart = {
{
name = "file",
filename = "voice.wav",
content_type = "audio/wav",
data = result.wav
}
}
}, function(response)
if not response.ok then
ue.log.error(response.error, response.status)
return
end
local decoded = assert(ue.json.decode(response.body))
print(decoded.text)
end)
end)The callback result contains ok, duration, sample_rate, channels, and either wav or error. It runs on the Unreal game thread, so the decoded text can be passed directly to a reflected Blueprint function.