mirror of
https://github.com/mudler/LocalAI.git
synced 2026-06-14 11:49:33 -04:00
* feat(omnivoice-cpp): add C wrapper + CMake/Makefile build over OmniVoice ov_* ABI Assisted-by: claude:claude-opus-4-8 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(omnivoice-cpp): add option/language parsing + WAV framing helpers with tests Assisted-by: claude:claude-opus-4-8 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(omnivoice-cpp): wire purego binding with TTS + streaming TTSStream Assisted-by: claude:claude-opus-4-8 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * build(omnivoice-cpp): wire backend into root Makefile Assisted-by: claude:claude-opus-4-8 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * ci(omnivoice-cpp): add build matrix entries + dep-bump registration Assisted-by: claude:claude-opus-4-8 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(omnivoice-cpp): register backend meta + image entries Assisted-by: claude:claude-opus-4-8 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(omnivoice-cpp): expose as preference-only importable backend Assisted-by: claude:claude-opus-4-8 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(gallery): add omnivoice-cpp TTS models (Q8_0 default + BF16 HQ) Assisted-by: claude:claude-opus-4-8 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * docs(omnivoice-cpp): document the OmniVoice TTS backend Assisted-by: claude:claude-opus-4-8 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * test(omnivoice-cpp): add env-gated e2e for TTS + streaming Assisted-by: claude:claude-opus-4-8 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(omnivoice-cpp): honor tts.audio_path/tts.voice config as default cloning reference The model config tts.audio_path (ModelOptions.AudioPath) and tts.voice now provide a default voice-cloning reference used when a request omits Voice, so a cloned voice can be pinned in the model YAML instead of passed per request. A per-request voice still overrides. Paths resolve relative to the model dir. Assisted-by: claude:claude-opus-4-8 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix(omnivoice-cpp): add missing omnivoice-cpp-development backend meta Mirrors the whisper/vibevoice convention: a -development meta aggregating the master-tagged image variants (the production meta and per-variant prod+dev image entries already existed; only the development meta aggregator was missing). Assisted-by: claude:claude-opus-4-8 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io> --------- Signed-off-by: Ettore Di Giacinto <mudler@localai.io> Co-authored-by: Ettore Di Giacinto <mudler@localai.io>
91 lines
2.6 KiB
Go
91 lines
2.6 KiB
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/binary"
|
|
"testing"
|
|
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
)
|
|
|
|
func TestOmnivoiceCpp(t *testing.T) {
|
|
RegisterFailHandler(Fail)
|
|
RunSpecs(t, "omnivoice-cpp suite")
|
|
}
|
|
|
|
var _ = Describe("normalizeLanguage", func() {
|
|
DescribeTable("maps caller language to OmniVoice codes",
|
|
func(in, want string) {
|
|
Expect(normalizeLanguage(in)).To(Equal(want))
|
|
},
|
|
Entry("empty stays empty", "", ""),
|
|
Entry("english full name", "English", "en"),
|
|
Entry("chinese full name", "Chinese", "zh"),
|
|
Entry("locale suffix stripped", "en-US", "en"),
|
|
Entry("underscore locale", "zh_CN", "zh"),
|
|
Entry("already a code", "en", "en"),
|
|
Entry("unknown passes through normalized", "xx", "xx"),
|
|
)
|
|
})
|
|
|
|
var _ = Describe("parseOptions", func() {
|
|
It("extracts codec, use_fa, clamp_fp16, seed, denoise", func() {
|
|
o := parseOptions([]string{
|
|
"tokenizer:tok.gguf",
|
|
"use_fa:true",
|
|
"clamp_fp16:true",
|
|
"seed:7",
|
|
"denoise:false",
|
|
"unknown:ignored",
|
|
})
|
|
Expect(o.codecPath).To(Equal("tok.gguf"))
|
|
Expect(o.useFA).To(BeTrue())
|
|
Expect(o.clampFP16).To(BeTrue())
|
|
Expect(o.seed).To(Equal(int64(7)))
|
|
Expect(o.denoise).To(BeFalse())
|
|
})
|
|
|
|
It("accepts codec: as an alias for tokenizer:", func() {
|
|
o := parseOptions([]string{"codec:c.gguf"})
|
|
Expect(o.codecPath).To(Equal("c.gguf"))
|
|
})
|
|
|
|
It("defaults seed to -1 and denoise to true", func() {
|
|
o := parseOptions(nil)
|
|
Expect(o.seed).To(Equal(int64(-1)))
|
|
Expect(o.denoise).To(BeTrue())
|
|
})
|
|
})
|
|
|
|
var _ = Describe("wavHeader24k", func() {
|
|
It("emits a 44-byte streaming WAV header at 24 kHz mono 16-bit", func() {
|
|
h := wavHeader24k()
|
|
Expect(h).To(HaveLen(44))
|
|
Expect(string(h[0:4])).To(Equal("RIFF"))
|
|
Expect(string(h[8:12])).To(Equal("WAVE"))
|
|
Expect(string(h[12:16])).To(Equal("fmt "))
|
|
Expect(string(h[36:40])).To(Equal("data"))
|
|
var sampleRate uint32
|
|
Expect(binary.Read(bytes.NewReader(h[24:28]), binary.LittleEndian, &sampleRate)).To(Succeed())
|
|
Expect(sampleRate).To(Equal(uint32(24000)))
|
|
})
|
|
})
|
|
|
|
var _ = Describe("floatToPCM16LE", func() {
|
|
It("clamps and converts float PCM to little-endian int16 bytes", func() {
|
|
b := floatToPCM16LE([]float32{0, 1.0, -1.0, 2.0, -2.0})
|
|
Expect(b).To(HaveLen(10)) // 5 samples * 2 bytes
|
|
read := func(off int) int16 {
|
|
var v int16
|
|
_ = binary.Read(bytes.NewReader(b[off:off+2]), binary.LittleEndian, &v)
|
|
return v
|
|
}
|
|
Expect(read(0)).To(Equal(int16(0)))
|
|
Expect(read(2)).To(Equal(int16(32767)))
|
|
Expect(read(4)).To(Equal(int16(-32767)))
|
|
Expect(read(6)).To(Equal(int16(32767))) // clamped from 2.0
|
|
Expect(read(8)).To(Equal(int16(-32767))) // clamped from -2.0
|
|
})
|
|
})
|