Add Java and Koltin API for Kokoro TTS 1.0 (#1798)
This commit is contained in:
@@ -3,10 +3,34 @@ package com.k2fsa.sherpa.onnx
|
||||
fun main() {
|
||||
testVits()
|
||||
testMatcha()
|
||||
testKokoro()
|
||||
testKokoroEn()
|
||||
testKokoroZhEn()
|
||||
}
|
||||
|
||||
fun testKokoro() {
|
||||
fun testKokoroZhEn() {
|
||||
// see https://github.com/k2-fsa/sherpa-onnx/releases/tag/tts-models
|
||||
var config = OfflineTtsConfig(
|
||||
model=OfflineTtsModelConfig(
|
||||
kokoro=OfflineTtsKokoroModelConfig(
|
||||
model="./kokoro-multi-lang-v1_0/model.onnx",
|
||||
voices="./kokoro-multi-lang-v1_0/voices.bin",
|
||||
tokens="./kokoro-multi-lang-v1_0/tokens.txt",
|
||||
dataDir="./kokoro-multi-lang-v1_0/espeak-ng-data",
|
||||
dictDir="./kokoro-multi-lang-v1_0/dict",
|
||||
lexicon="./kokoro-multi-lang-v1_0/lexicon-us-en.txt,./kokoro-multi-lang-v1_0/lexicon-zh.txt",
|
||||
),
|
||||
numThreads=2,
|
||||
debug=true,
|
||||
),
|
||||
)
|
||||
val tts = OfflineTts(config=config)
|
||||
val audio = tts.generateWithCallback(text="中英文语音合成测试。This is generated by next generation Kaldi using Kokoro without Misaki. 你觉得中英文说的如何呢?", callback=::callback)
|
||||
audio.save(filename="test-kokoro-zh-en.wav")
|
||||
tts.release()
|
||||
println("Saved to test-kokoro-zh-en.wav")
|
||||
}
|
||||
|
||||
fun testKokoroEn() {
|
||||
// see https://github.com/k2-fsa/sherpa-onnx/releases/tag/tts-models
|
||||
var config = OfflineTtsConfig(
|
||||
model=OfflineTtsModelConfig(
|
||||
|
||||
Reference in New Issue
Block a user