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

Method Decode

backend/go/opus/codec.go:213–235  ·  view source on GitHub ↗

Decode decodes an Opus packet into pcm. frameSize is the max number of samples per channel that pcm can hold. Returns the number of decoded samples per channel.

(data []byte, pcm []int16, frameSize int, fec bool)

Source from the content-addressed store, hash-verified

211// samples per channel that pcm can hold. Returns the number of decoded samples
212// per channel.
213func (d *Decoder) Decode(data []byte, pcm []int16, frameSize int, fec bool) (int, error) {
214 if len(pcm) == 0 {
215 return 0, errors.New("opus decode: empty output buffer")
216 }
217
218 var dataPtr *byte
219 var dataLen int32
220 if len(data) > 0 {
221 dataPtr = &data[0]
222 dataLen = int32(len(data))
223 }
224
225 decodeFec := int32(0)
226 if fec {
227 decodeFec = 1
228 }
229
230 n := cDecode(d.st, dataPtr, dataLen, &pcm[0], int32(frameSize), decodeFec)
231 if n < 0 {
232 return 0, fmt.Errorf("opus_decode failed: error %d", n)
233 }
234 return int(n), nil
235}
236
237func (d *Decoder) Close() {
238 if d.st != 0 {

Callers 15

AudioDecodeMethod · 0.95
TryConsumeJSONMethod · 0.95
parseJSONLegacyFunction · 0.95
predictOpenAIRichMethod · 0.80
predictAnthropicRichMethod · 0.80
ImportAgentEndpointFunction · 0.80
ExecuteActionEndpointFunction · 0.80
proxyP2PConnectionFunction · 0.80
chat_test.goFile · 0.80
chatTestServerFunction · 0.80

Calls

no outgoing calls

Tested by 1

chatTestServerFunction · 0.64