audio.play_wav

Play uncompressed PCM RIFF/WAVE bytes from memory.

Syntax

ue.audio.play_wav(wave_bytes: string) -> number?, error?

Parameters

ParameterTypeDescription
wave_bytesstringComplete, uncompressed PCM RIFF/WAVE file bytes.

Returns

Returns the audio duration in seconds after playback begins, or nil, error when the WAVE data is invalid or unsupported.

Example

ue.http.request(tts_options, function(response)
    if not response.ok then return end

    local seconds, err = ue.audio.play_wav(response.body)
    if not seconds then
        ue.log.error(err)
        return
    end

    character:ToggleTalking(true)
    ue.timer.after(seconds, function()
        if character:is_valid() then
            character:ToggleTalking(false)
        end
    end)
end)

Notes

  • Only uncompressed PCM WAVE is supported. MP3, Opus, and compressed WAVE codecs are not decoded.
  • Audio data is limited to 16 MiB.
  • Playback is asynchronous, non-spatial, and limited to one Lua sound at a time.
  • Starting another Lua sound replaces the current sound.

On this page