Add MeloTTS example for ios (#1223)
This commit is contained in:
@@ -39,7 +39,6 @@ echo "SHERPA_ONNXRUNTIME_INCLUDE_DIR $SHERPA_ONNXRUNTIME_INCLUDE_DIR"
|
||||
# The symbol _NSLog is not defined
|
||||
#
|
||||
|
||||
if [[ ! -f ./build/simulator_x86_64/lib/libsherpa-onnx-c-api.a ]]; then
|
||||
cmake \
|
||||
-DBUILD_PIPER_PHONMIZE_EXE=OFF \
|
||||
-DBUILD_PIPER_PHONMIZE_TESTS=OFF \
|
||||
@@ -64,11 +63,9 @@ if [[ ! -f ./build/simulator_x86_64/lib/libsherpa-onnx-c-api.a ]]; then
|
||||
-B build/simulator_x86_64
|
||||
|
||||
cmake --build build/simulator_x86_64 -j 4 --verbose
|
||||
fi
|
||||
|
||||
echo "Building for simulator (arm64)"
|
||||
|
||||
if [[ ! -f ./build/simulator_arm64/lib/libsherpa-onnx-c-api.a ]]; then
|
||||
cmake \
|
||||
-DBUILD_PIPER_PHONMIZE_EXE=OFF \
|
||||
-DBUILD_PIPER_PHONMIZE_TESTS=OFF \
|
||||
@@ -94,13 +91,11 @@ if [[ ! -f ./build/simulator_arm64/lib/libsherpa-onnx-c-api.a ]]; then
|
||||
-B build/simulator_arm64
|
||||
|
||||
cmake --build build/simulator_arm64 -j 4 --verbose
|
||||
fi
|
||||
|
||||
echo "Building for arm64"
|
||||
|
||||
export SHERPA_ONNXRUNTIME_LIB_DIR=$PWD/ios-onnxruntime/onnxruntime.xcframework/ios-arm64
|
||||
|
||||
if [[ ! -f ./build/os64/lib/libsherpa-onnx-c-api.a ]]; then
|
||||
cmake \
|
||||
-DBUILD_PIPER_PHONMIZE_EXE=OFF \
|
||||
-DBUILD_PIPER_PHONMIZE_TESTS=OFF \
|
||||
@@ -128,7 +123,6 @@ if [[ ! -f ./build/os64/lib/libsherpa-onnx-c-api.a ]]; then
|
||||
cmake --build build/os64 -j 4
|
||||
# Generate headers for sherpa-onnx.xcframework
|
||||
cmake --build build/os64 --target install
|
||||
fi
|
||||
|
||||
echo "Generate xcframework"
|
||||
|
||||
|
||||
@@ -93,12 +93,50 @@ func getTtsFor_en_US_amy_low() -> SherpaOnnxOfflineTtsWrapper {
|
||||
return SherpaOnnxOfflineTtsWrapper(config: &config)
|
||||
}
|
||||
|
||||
// https://k2-fsa.github.io/sherpa/onnx/tts/pretrained_models/vits.html#vits-melo-tts-zh-en-chinese-english-1-speaker
|
||||
func getTtsFor_zh_en_melo_tts() -> SherpaOnnxOfflineTtsWrapper {
|
||||
// please see https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/vits-melo-tts-zh_en.tar.bz2
|
||||
|
||||
let model = getResource("model", "onnx")
|
||||
|
||||
let tokens = getResource("tokens", "txt")
|
||||
let lexicon = getResource("lexicon", "txt")
|
||||
|
||||
let dictDir = resourceURL(to: "dict")
|
||||
|
||||
let numFst = getResource("number", "fst")
|
||||
let dateFst = getResource("date", "fst")
|
||||
let phoneFst = getResource("phone", "fst")
|
||||
let ruleFsts = "\(dateFst),\(phoneFst),\(numFst)"
|
||||
|
||||
let vits = sherpaOnnxOfflineTtsVitsModelConfig(
|
||||
model: model, lexicon: lexicon, tokens: tokens,
|
||||
dataDir: "",
|
||||
noiseScale: 0.667,
|
||||
noiseScaleW: 0.8,
|
||||
lengthScale: 1.0,
|
||||
dictDir: dictDir
|
||||
)
|
||||
|
||||
let modelConfig = sherpaOnnxOfflineTtsModelConfig(vits: vits)
|
||||
var config = sherpaOnnxOfflineTtsConfig(
|
||||
model: modelConfig,
|
||||
ruleFsts: ruleFsts
|
||||
)
|
||||
|
||||
return SherpaOnnxOfflineTtsWrapper(config: &config)
|
||||
}
|
||||
|
||||
func createOfflineTts() -> SherpaOnnxOfflineTtsWrapper {
|
||||
// Please enable only one of them
|
||||
|
||||
return getTtsFor_en_US_amy_low()
|
||||
|
||||
// return getTtsForVCTK()
|
||||
|
||||
// return getTtsForAishell3()
|
||||
|
||||
// return getTtsFor_zh_en_melo_tts()
|
||||
|
||||
// please add more models on need by following the above two examples
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user