voicecodec

package
v0.0.0-...-d9e29ba Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package voicecodec provides the portable audio codecs used by voice.v1.

Index

Constants

View Source
const (
	FrameDurationMilliseconds = 20
	MaxPacketBytes            = 1275
)

Variables

This section is empty.

Functions

func SupportsFormat

func SupportsFormat(sampleRate, channels int) bool

SupportsFormat reports whether raw Opus can represent the PCM format without resampling or remixing it.

Types

type OpusDecoder

type OpusDecoder struct {
	// contains filtered or unexported fields
}

OpusDecoder converts raw Opus packets into PCM16LE. It owns state and must not be used concurrently.

func NewOpusDecoder

func NewOpusDecoder(sampleRate, channels int) (*OpusDecoder, error)

NewOpusDecoder creates a decoder for one negotiated PCM output format.

func (*OpusDecoder) Decode

func (d *OpusDecoder) Decode(packet []byte) ([]byte, error)

Decode converts one Opus packet into caller-owned PCM16LE bytes.

type OpusEncoder

type OpusEncoder struct {
	// contains filtered or unexported fields
}

OpusEncoder converts exact 20 ms PCM16LE frames into raw Opus packets. It owns state and must not be used concurrently.

func NewOpusEncoder

func NewOpusEncoder(sampleRate, channels, bitrate int) (*OpusEncoder, error)

NewOpusEncoder creates a speech-tuned constrained-VBR encoder.

func (*OpusEncoder) Encode

func (e *OpusEncoder) Encode(pcm []byte) ([]byte, error)

Encode converts one exact 20 ms PCM16LE frame into a caller-owned packet.

func (*OpusEncoder) FrameBytes

func (e *OpusEncoder) FrameBytes() int

FrameBytes returns the exact PCM16LE byte count accepted by Encode.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL