Add Koltin and Java API for Kokoro TTS models (#1728)

This commit is contained in:
Fangjun Kuang
2025-01-17 17:36:13 +08:00
committed by GitHub
parent 3a1de0bfc1
commit 99cef4198b
18 changed files with 548 additions and 39 deletions

View File

@@ -3,6 +3,28 @@ package com.k2fsa.sherpa.onnx
fun main() {
testVits()
testMatcha()
testKokoro()
}
fun testKokoro() {
// see https://github.com/k2-fsa/sherpa-onnx/releases/tag/tts-models
var config = OfflineTtsConfig(
model=OfflineTtsModelConfig(
kokoro=OfflineTtsKokoroModelConfig(
model="./kokoro-en-v0_19/model.onnx",
voices="./kokoro-en-v0_19/voices.bin",
tokens="./kokoro-en-v0_19/tokens.txt",
dataDir="./kokoro-en-v0_19/espeak-ng-data",
),
numThreads=2,
debug=true,
),
)
val tts = OfflineTts(config=config)
val audio = tts.generateWithCallback(text="How are you doing today?", callback=::callback)
audio.save(filename="test-kokoro-en.wav")
tts.release()
println("Saved to test-kokoro-en.wav")
}
fun testMatcha() {
@@ -24,9 +46,9 @@ fun testMatcha() {
)
val tts = OfflineTts(config=config)
val audio = tts.generateWithCallback(text="某某银行的副行长和一些行政领导表示,他们去过长江和长白山; 经济不断增长。2024年12月31号拨打110或者18920240511。123456块钱。", callback=::callback)
audio.save(filename="test-zh.wav")
audio.save(filename="test-matcha-zh.wav")
tts.release()
println("Saved to test-zh.wav")
println("Saved to test-matcha-zh.wav")
}
fun testVits() {