Add Koltin and Java API for Kokoro TTS models (#1728)
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user