MCPcopy
hub / github.com/mudler/LocalAI / NewDecoder

Function NewDecoder

backend/go/opus/codec.go:197–208  ·  view source on GitHub ↗
(sampleRate, channels int)

Source from the content-addressed store, hash-verified

195}
196
197func NewDecoder(sampleRate, channels int) (*Decoder, error) {
198 if err := ensureInit(); err != nil {
199 return nil, err
200 }
201
202 var opusErr int32
203 st := cDecoderCreate(int32(sampleRate), int32(channels), &opusErr)
204 if opusErr != 0 || st == 0 {
205 return nil, fmt.Errorf("opus_decoder_create failed: error %d", opusErr)
206 }
207 return &Decoder{st: st}, nil
208}
209
210// Decode decodes an Opus packet into pcm. frameSize is the max number of
211// samples per channel that pcm can hold. Returns the number of decoded samples

Callers 2

getOrCreateDecoderMethod · 0.85
AudioDecodeMethod · 0.85

Calls 1

ensureInitFunction · 0.85

Tested by

no test coverage detected