mirror of
https://github.com/mudler/LocalAI.git
synced 2025-05-28 14:35:00 +00:00
chore(vad): try to hook vad to received data from the API (WIP)
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
parent
a3fd8caaa6
commit
9614422713
3 changed files with 99 additions and 3 deletions
20
pkg/sound/float32.go
Normal file
20
pkg/sound/float32.go
Normal file
|
@ -0,0 +1,20 @@
|
|||
package sound
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"math"
|
||||
)
|
||||
|
||||
func BytesToFloat32Array(aBytes []byte) []float32 {
|
||||
aArr := make([]float32, 3)
|
||||
for i := 0; i < 3; i++ {
|
||||
aArr[i] = BytesFloat32(aBytes[i*4:])
|
||||
}
|
||||
return aArr
|
||||
}
|
||||
|
||||
func BytesFloat32(bytes []byte) float32 {
|
||||
bits := binary.LittleEndian.Uint32(bytes)
|
||||
float := math.Float32frombits(bits)
|
||||
return float
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue