worried-rocket-36543
09/11/2025, 11:56 AMtall-airline-16756
09/11/2025, 11:56 AMtall-airline-16756
09/11/2025, 11:58 AMDecodeULaw
function from the media-sdk
package to decode the μ-law audio into PCM16 format. Here's a simple example to guide you:
// Create a PCM16Writer (e.g., your agent's audio processor or sink)
pcmWriter := yourPcm16Writer
// Wrap it with DecodeULaw to create a ULawWriter
ulawWriter := DecodeULaw(pcmWriter)
// Write μ-law samples directly to ulawWriter
err := ulawWriter.WriteSample(ULawSample{0x83, 0x87, 0x96, ...})
if err != nil {
log.Fatal(err)
}
1. If you encounter any sample rate mismatches, no worries! You can handle them using the built-in resampling feature of DecodeULaw
.
2. Also, please double-check that your upstream components or plugins provide μ-law 8000 audio. Plugins like Uplift AI TTS and Speechmatics are great examples that support μ-law encoding.
This approach is a reliable and efficient way to convert μ-law audio to PCM16 format, making it perfect for real-time audio processing. If you have any questions or need further assistance, feel free to ask—I'm here to help!
Sources: g711/g711.go | livekit-plugins/livekit-plugins-lmnt/livekit/plugins/lmnt/models.pyworried-rocket-36543
09/11/2025, 11:59 AMtall-airline-16756
09/11/2025, 11:59 AM