Add Kotlin API for Matcha-TTS models. (#1668)
This commit is contained in:
@@ -1,10 +1,35 @@
|
||||
package com.k2fsa.sherpa.onnx
|
||||
|
||||
fun main() {
|
||||
testTts()
|
||||
testVits()
|
||||
testMatcha()
|
||||
}
|
||||
|
||||
fun testTts() {
|
||||
fun testMatcha() {
|
||||
// see https://github.com/k2-fsa/sherpa-onnx/releases/tag/tts-models
|
||||
// https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/matcha-icefall-zh-baker.tar.bz2
|
||||
var config = OfflineTtsConfig(
|
||||
model=OfflineTtsModelConfig(
|
||||
matcha=OfflineTtsMatchaModelConfig(
|
||||
acousticModel="./matcha-icefall-zh-baker/model-steps-3.onnx",
|
||||
vocoder="./hifigan_v2.onnx",
|
||||
tokens="./matcha-icefall-zh-baker/tokens.txt",
|
||||
lexicon="./matcha-icefall-zh-baker/lexicon.txt",
|
||||
dictDir="./matcha-icefall-zh-baker/dict",
|
||||
),
|
||||
numThreads=1,
|
||||
debug=true,
|
||||
),
|
||||
ruleFsts="./matcha-icefall-zh-baker/phone.fst,./matcha-icefall-zh-baker/date.fst,./matcha-icefall-zh-baker/number.fst",
|
||||
)
|
||||
val tts = OfflineTts(config=config)
|
||||
val audio = tts.generateWithCallback(text="某某银行的副行长和一些行政领导表示,他们去过长江和长白山; 经济不断增长。2024年12月31号,拨打110或者18920240511。123456块钱。", callback=::callback)
|
||||
audio.save(filename="test-zh.wav")
|
||||
tts.release()
|
||||
println("Saved to test-zh.wav")
|
||||
}
|
||||
|
||||
fun testVits() {
|
||||
// see https://github.com/k2-fsa/sherpa-onnx/releases/tag/tts-models
|
||||
// https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/vits-piper-en_US-amy-low.tar.bz2
|
||||
var config = OfflineTtsConfig(
|
||||
|
||||
Reference in New Issue
Block a user