support reading rule FST for Android TTS (#410)
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
# Inside the $ANDROID_NDK directory, you can find a binary ndk-build
|
||||
# and some other files like the file "build/cmake/android.toolchain.cmake"
|
||||
|
||||
set -e
|
||||
set -ex
|
||||
|
||||
log() {
|
||||
# This function is from espnet
|
||||
@@ -43,6 +43,7 @@ wget -qq https://huggingface.co/csukuangfj/$model_dir/resolve/main/$model_name
|
||||
wget -qq https://huggingface.co/csukuangfj/$model_dir/resolve/main/lexicon.txt
|
||||
wget -qq https://huggingface.co/csukuangfj/$model_dir/resolve/main/tokens.txt
|
||||
wget -qq https://huggingface.co/csukuangfj/$model_dir/resolve/main/MODEL_CARD 2>/dev/null || true
|
||||
wget -qq https://huggingface.co/csukuangfj/$model_dir/resolve/main/rule.fst 2>/dev/null || true
|
||||
|
||||
popd
|
||||
# Now we are at the project root directory
|
||||
@@ -51,6 +52,11 @@ git checkout .
|
||||
pushd android/SherpaOnnxTts/app/src/main/java/com/k2fsa/sherpa/onnx
|
||||
sed -i.bak s/"modelDir = null"/"modelDir = \"$model_dir\""/ ./MainActivity.kt
|
||||
sed -i.bak s/"modelName = null"/"modelName = \"$model_name\""/ ./MainActivity.kt
|
||||
{% if tts_model.rule_fsts %}
|
||||
rule_fsts={{ tts_model.rule_fsts }}
|
||||
sed -i.bak s%"ruleFsts = null"%"ruleFsts = \"$rule_fsts\""% ./MainActivity.kt
|
||||
{% endif %}
|
||||
|
||||
git diff
|
||||
popd
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
from dataclasses import dataclass
|
||||
from typing import List, Optional
|
||||
|
||||
import jinja2
|
||||
from typing import List
|
||||
import argparse
|
||||
|
||||
|
||||
def get_args():
|
||||
@@ -29,12 +29,65 @@ class TtsModel:
|
||||
model_dir: str
|
||||
model_name: str
|
||||
lang: str # en, zh, fr, de, etc.
|
||||
rule_fsts: Optional[List[str]] = (None,)
|
||||
|
||||
|
||||
def get_all_models() -> List[TtsModel]:
|
||||
return [
|
||||
# Chinese
|
||||
TtsModel(
|
||||
model_dir="vits-zh-aishell3", model_name="vits-aishell3.onnx", lang="zh"
|
||||
model_dir="vits-zh-aishell3",
|
||||
model_name="vits-aishell3.onnx",
|
||||
lang="zh",
|
||||
rule_fsts="vits-zh-aishell3/rule.fst",
|
||||
),
|
||||
TtsModel(
|
||||
model_dir="vits-zh-hf-doom",
|
||||
model_name="doom.onnx",
|
||||
lang="zh",
|
||||
rule_fsts="vits-zh-hf-doom/rule.fst",
|
||||
),
|
||||
TtsModel(
|
||||
model_dir="vits-zh-hf-echo",
|
||||
model_name="echo.onnx",
|
||||
lang="zh",
|
||||
rule_fsts="vits-zh-hf-echo/rule.fst",
|
||||
),
|
||||
TtsModel(
|
||||
model_dir="vits-zh-hf-zenyatta",
|
||||
model_name="zenyatta.onnx",
|
||||
lang="zh",
|
||||
rule_fsts="vits-zh-hf-zenyatta/rule.fst",
|
||||
),
|
||||
TtsModel(
|
||||
model_dir="vits-zh-hf-abyssinvoker",
|
||||
model_name="abyssinvoker.onnx",
|
||||
lang="zh",
|
||||
rule_fsts="vits-zh-hf-abyssinvoker/rule.fst",
|
||||
),
|
||||
TtsModel(
|
||||
model_dir="vits-zh-hf-keqing",
|
||||
model_name="keqing.onnx",
|
||||
lang="zh",
|
||||
rule_fsts="vits-zh-hf-keqing/rule.fst",
|
||||
),
|
||||
TtsModel(
|
||||
model_dir="vits-zh-hf-eula",
|
||||
model_name="eula.onnx",
|
||||
lang="zh",
|
||||
rule_fsts="vits-zh-hf-eula/rule.fst",
|
||||
),
|
||||
TtsModel(
|
||||
model_dir="vits-zh-hf-bronya",
|
||||
model_name="bronya.onnx",
|
||||
lang="zh",
|
||||
rule_fsts="vits-zh-hf-bronya/rule.fst",
|
||||
),
|
||||
TtsModel(
|
||||
model_dir="vits-zh-hf-theresa",
|
||||
model_name="theresa.onnx",
|
||||
lang="zh",
|
||||
rule_fsts="vits-zh-hf-theresa/rule.fst",
|
||||
),
|
||||
# English (US)
|
||||
# fmt: off
|
||||
|
||||
Reference in New Issue
Block a user