Add Flutter text to speech demo (#1087)
This commit is contained in:
125
scripts/flutter/build-linux-tts.sh.in
Executable file
125
scripts/flutter/build-linux-tts.sh.in
Executable file
@@ -0,0 +1,125 @@
|
||||
#!/usr/bin/env bash
|
||||
set -ex
|
||||
|
||||
log() {
|
||||
# This function is from espnet
|
||||
local fname=${BASH_SOURCE[1]##*/}
|
||||
echo -e "$(date '+%Y-%m-%d %H:%M:%S') (${fname}:${BASH_LINENO[0]}:${FUNCNAME[1]}) $*"
|
||||
}
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
SHERPA_ONNX_DIR=$(cd $SCRIPT_DIR/../.. && pwd)
|
||||
log "SCRIPT_DIR: $SCRIPT_DIR"
|
||||
log "SHERPA_ONNX_DIR: $SHERPA_ONNX_DIR"
|
||||
|
||||
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" $SHERPA_ONNX_DIR/CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
||||
log "SHERPA_ONNX_VERSION: $SHERPA_ONNX_VERSION"
|
||||
|
||||
if [ -z $arch ]; then
|
||||
arch=x86_64
|
||||
fi
|
||||
|
||||
log "arch: $arch"
|
||||
|
||||
{% for tts_model in tts_model_list %}
|
||||
pushd $SHERPA_ONNX_DIR/flutter-examples/tts/
|
||||
|
||||
git checkout .
|
||||
|
||||
rm -rf assets
|
||||
mkdir assets
|
||||
|
||||
pushd assets
|
||||
|
||||
model_dir={{ tts_model.model_dir }}
|
||||
model_name={{ tts_model.model_name }}
|
||||
lang={{ tts_model.lang }}
|
||||
|
||||
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/$model_dir.tar.bz2
|
||||
tar xf $model_dir.tar.bz2
|
||||
rm $model_dir.tar.bz2
|
||||
|
||||
ls -lh
|
||||
ls -lh *
|
||||
|
||||
popd # assets
|
||||
# Now we are at the project root directory
|
||||
|
||||
./generate-asset-list.py
|
||||
|
||||
pushd lib
|
||||
|
||||
sed -i.bak "s|modelDir = ''|modelDir = \"$model_dir\"|" ./model.dart
|
||||
sed -i.bak s/"modelName = ''"/"modelName = \"$model_name\""/ ./model.dart
|
||||
|
||||
{% if tts_model.rule_fsts %}
|
||||
rule_fsts={{ tts_model.rule_fsts }}
|
||||
sed -i.bak "s|ruleFsts = ''|ruleFsts = \"$rule_fsts\"|" ./model.dart
|
||||
{% endif %}
|
||||
|
||||
{% if tts_model.rule_fars %}
|
||||
rule_fars={{ tts_model.rule_fars }}
|
||||
sed -i.bak "s|ruleFars = ''|ruleFars = \"$rule_fars\"|" ./model.dart
|
||||
{% endif %}
|
||||
|
||||
{% if tts_model.dict_dir %}
|
||||
dict_dir={{ tts_model.dict_dir }}
|
||||
sed -i.bak "s|dictDir = ''|dictDir = \"$dict_dir\"|" ./model.dart
|
||||
{% endif %}
|
||||
|
||||
{% if tts_model.data_dir %}
|
||||
data_dir={{ tts_model.data_dir }}
|
||||
sed -i.bak "s|dataDir = ''|dataDir = \"$data_dir\"|" ./model.dart
|
||||
{% elif not tts_model.is_char %}
|
||||
sed -i.bak "s|lexicon = ''|lexicon = \"lexicon.txt\"|" ./model.dart
|
||||
{% endif %}
|
||||
|
||||
git status
|
||||
|
||||
git diff .
|
||||
|
||||
popd #lib
|
||||
|
||||
flutter pub get
|
||||
|
||||
flutter build linux
|
||||
|
||||
pushd build/linux/x64/release/
|
||||
|
||||
ls -lh
|
||||
echo "----"
|
||||
ls -lh bundle
|
||||
|
||||
echo "----"
|
||||
ls -lh bundle/lib
|
||||
|
||||
echo "----"
|
||||
ls -lh bundle/data
|
||||
echo "======"
|
||||
ls -lh bundle/data/flutter_assets
|
||||
|
||||
|
||||
echo "----"
|
||||
file bundle/tts
|
||||
|
||||
echo "----"
|
||||
readelf -d bundle/tts
|
||||
|
||||
echo "----"
|
||||
ldd bundle/tts
|
||||
|
||||
app=sherpa-onnx-$SHERPA_ONNX_VERSION-linux-$arch-$lang-tts-$model_dir
|
||||
|
||||
mv bundle $app
|
||||
tar cjf $app.tar.bz2 $app
|
||||
rm -rf $app
|
||||
mv $app.tar.bz2 $SHERPA_ONNX_DIR
|
||||
|
||||
pushd $SHERPA_ONNX_DIR
|
||||
ls -lh *.tar.bz2
|
||||
popd
|
||||
|
||||
popd
|
||||
|
||||
popd
|
||||
{% endfor %}
|
||||
Reference in New Issue
Block a user