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

Method Encode

backend/go/opus/codec.go:160–169  ·  view source on GitHub ↗

Encode encodes a frame of PCM int16 samples. It returns the number of bytes written to out, or a negative error code.

(pcm []int16, frameSize int, out []byte)

Source from the content-addressed store, hash-verified

158// Encode encodes a frame of PCM int16 samples. It returns the number of bytes
159// written to out, or a negative error code.
160func (e *Encoder) Encode(pcm []int16, frameSize int, out []byte) (int, error) {
161 if len(pcm) == 0 || len(out) == 0 {
162 return 0, errors.New("opus encode: empty input or output buffer")
163 }
164 n := cEncode(e.st, &pcm[0], int32(frameSize), &out[0], int32(len(out)))
165 if n < 0 {
166 return 0, fmt.Errorf("opus_encode failed: error %d", n)
167 }
168 return int(n), nil
169}
170
171func (e *Encoder) SetBitrate(bitrate int) error {
172 if ret := cSetBitrate(e.st, int32(bitrate)); ret != 0 {

Callers 15

AudioEncodeMethod · 0.95
InpaintingEndpointFunction · 0.95
opus_test.goFile · 0.80
writeDepthPNGFunction · 0.80
buildSQLiteDSNFunction · 0.80
RenderMethod · 0.80
saveMethod · 0.80
writePIIBlockedFunction · 0.80
handleFullUploadFunction · 0.80
handleRangeUploadFunction · 0.80
handleAllocTempFunction · 0.80
handleListDirFunction · 0.80

Calls

no outgoing calls

Tested by 6

RenderMethod · 0.64
fakeBackendFunction · 0.64
fakeLocalAIFunction · 0.64
startAgentMockLLMServerFunction · 0.64
jwtResolverMaterialFunction · 0.64
startMockLLMServerFunction · 0.64