-
Notifications
You must be signed in to change notification settings - Fork 462
223 lines (184 loc) · 6.29 KB
/
flutter-macos.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
name: flutter-macos
on:
push:
branches:
- flutter
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
paths:
- '.github/workflows/flutter-macos.yaml'
- 'CMakeLists.txt'
- 'cmake/**'
- 'sherpa-onnx/csrc/*'
- 'sherpa-onnx/c-api/*'
- 'sherpa-onnx/flutter/**'
pull_request:
branches:
- master
paths:
- '.github/workflows/flutter-macos.yaml'
- 'CMakeLists.txt'
- 'cmake/**'
- 'sherpa-onnx/csrc/*'
- 'sherpa-onnx/c-api/*'
- 'sherpa-onnx/flutter/**'
workflow_dispatch:
concurrency:
group: flutter-macos-${{ github.ref }}
cancel-in-progress: true
jobs:
flutter_macos:
name: macos ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest]
arch: [x86_64, arm64]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Flutter SDK
uses: flutter-actions/setup-flutter@v3
with:
channel: stable
version: latest
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ matrix.os }}-flutter-${{ matrix.arch }}
- name: Display PWD
shell: bash
run: |
echo "pwd: $PWD"
ls -lh
- name: Display machine info
shell: bash
run: |
uname -a
- name: Install tree
shell: bash
run: |
brew install tree
- name: Display flutter info
shell: bash
run: |
which flutter
which dart
flutter --version
dart --version
flutter doctor
- name: Configure CMake
shell: bash
run: |
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
cmake --version
arch=${{ matrix.arch }}
mkdir build
cd build
cmake \
-D BUILD_SHARED_LIBS=ON \
-DCMAKE_OSX_ARCHITECTURES=$arch \
-DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
-DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \
-DBUILD_ESPEAK_NG_EXE=OFF \
-DSHERPA_ONNX_ENABLE_BINARY=OFF \
-DCMAKE_INSTALL_PREFIX=./install \
..
- name: Build sherpa-onnx for macos ${{ matrix.arch }}
shell: bash
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
cd build
make -j2
make install
rm -v ./install/lib/libonnxruntime.dylib
- name: Copy libs
shell: bash
run: |
cp -v build/install/lib/lib* ./sherpa-onnx/flutter/macos/
echo "--------------------"
ls -lh ./sherpa-onnx/flutter/macos/
- name: Download model files
shell: bash
run: |
cd sherpa-onnx/flutter
pushd example/assets
# curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/speaker-recongition-models/3dspeaker_speech_eres2net_base_sv_zh-cn_3dspeaker_16k.onnx
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/silero_vad.onnx
# git clone https://github.com/csukuangfj/sr-data
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2
tar xvf sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2
rm sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2
cd sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20
rm encoder-epoch-99-avg-1.onnx
rm decoder-epoch-99-avg-1.int8.onnx
rm joiner-epoch-99-avg-1.onnx
rm README.md
rm bpe.model
rm bpe.vocab
rm -rf test_wavs
ls -lh
cd ..
rm -rf sr-data/.git
popd
- name: Build flutter
shell: bash
run: |
SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
d=$PWD
pushd sherpa-onnx/flutter
dart pub get
cd example
export FLUTTER_XCODE_ARCHS=${{ matrix.arch }}
echo "FLUTTER_XCODE_ARCHS: $FLUTTER_XCODE_ARCHS"
flutter build macos
cd build/macos/Build/Products/Release/
tree ./sherpa_onnx.app
app=sherpa-onnx-osx-${{ matrix.arch }}-$SHERPA_ONNX_VERSION.app
mv sherpa_onnx.app $app
tar cjfv $app.tar.bz2 $app
ls -lh
mv $app.tar.bz2 $d
popd
ls -lh $app.tar.bz2
- uses: actions/upload-artifact@v4
with:
name: sherpa-onnx-osx-${{ matrix.arch }}
path: ./*.tar.bz2
- name: Publish to huggingface
if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/') && matrix.build_type == 'Release'
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
uses: nick-fields/retry@v3
with:
max_attempts: 20
timeout_seconds: 200
shell: bash
command: |
git config --global user.email "csukuangfj@gmail.com"
git config --global user.name "Fangjun Kuang"
rm -rf huggingface
export GIT_LFS_SKIP_SMUDGE=1
export GIT_CLONE_PROTECTION_ACTIVE=false
git clone https://huggingface.co/csukuangfj/sherpa-onnx-flutter huggingface
cd huggingface
git fetch
git pull
git merge -m "merge remote" --ff origin main
mkdir -p flutter
cp -v ../*.tar.bz2 ./flutter
git status
git lfs track "*.bz2"
git add .
git commit -m "add more files"
git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-flutter main
# - name: Release android libs
# if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
# uses: svenstaro/upload-release-action@v2
# with:
# file_glob: true
# overwrite: true
# file: sherpa*.tar.bz2