Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Flutter GUI example for VAD with a microphone. #905

Merged
merged 16 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
206 changes: 206 additions & 0 deletions .github/workflows/flutter-linux.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
name: flutter-linux

on:
push:
branches:
- flutter
tags:
- '*'
paths:
- '.github/workflows/flutter-linux.yaml'
- 'CMakeLists.txt'
- 'cmake/**'
- 'sherpa-onnx/csrc/*'
- 'sherpa-onnx/c-api/*'
- 'sherpa-onnx/flutter/**'
pull_request:
branches:
- master
paths:
- '.github/workflows/flutter-linux.yaml'
- 'CMakeLists.txt'
- 'cmake/**'
- 'sherpa-onnx/csrc/*'
- 'sherpa-onnx/c-api/*'
- 'sherpa-onnx/flutter/**'

workflow_dispatch:

concurrency:
group: flutter-linux-${{ github.ref }}
cancel-in-progress: true

jobs:
flutter_linux:
name: linux
runs-on: ${{ matrix.os }}
container: ubuntu:18.04
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Install deps
shell: bash
run: |
apt-get update -y
apt-get install -y build-essential jq git cmake
apt-get install -y curl

- name: Setup Flutter SDK
uses: flutter-actions/setup-flutter@v3
with:
channel: stable
version: latest

- name: Install ninja
shell: bash
run: |
apt-get install -y ninja-build

- name: Display ninja version
shell: bash
run: |
ninja --version
ninja --help || true
which ninja

- name: Display PWD
shell: bash
run: |
echo "pwd: $PWD"
ls -lh

- name: Display machine info
shell: bash
run: |
uname -a

- name: Display flutter info
shell: bash
run: |
which flutter
which dart

flutter --version

mkdir -p /__t/flutter-Linux-3.22.1-X64/flutter

git config --global --add safe.directory /__t/flutter-Linux-3.22.1-X64/flutter

flutter --version

dart --version
flutter doctor


flutter doctor

- name: Install libgtk-3-dev
shell: bash
run: |
apt install -y libgtk-3-dev tree clang pkg-config

- name: Display flutter info (2)
shell: bash
run: |
which flutter
which dart

flutter --version
dart --version
flutter doctor

- name: Build sherpa-onnx
uses: addnab/docker-run-action@v3
with:
image: quay.io/pypa/manylinux2014_x86_64
options: |
--volume ${{ github.workspace }}/:/home/runner/work/sherpa-onnx/sherpa-onnx
shell: bash
run: |
uname -a
gcc --version
cmake --version
cat /etc/*release
id
pwd

cd /home/runner/work/sherpa-onnx/sherpa-onnx

mkdir build
cd build

cmake \
-D BUILD_SHARED_LIBS=ON \
-DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
-DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \
-DBUILD_ESPEAK_NG_EXE=OFF \
-DSHERPA_ONNX_ENABLE_BINARY=OFF \
-DCMAKE_INSTALL_PREFIX=./install \
..

make -j2
make install

- name: Copy libs
shell: bash
run: |
cp -v build/install/lib/lib* ./sherpa-onnx/flutter/linux/

echo "--------------------"

ls -lh ./sherpa-onnx/flutter/linux/

- name: Download model files
shell: bash
run: |
cd sherpa-onnx/flutter
cd example/assets

curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/silero_vad.onnx

- name: Build flutter
shell: bash
run: |

d=$PWD

pushd sherpa-onnx/flutter
dart pub get

cd example
flutter build linux

ls -lh build/linux/x64/release/bundle/sherpa_onnx
file build/linux/x64/release/bundle/sherpa_onnx

tree build/linux/x64/release/bundle/
cd build/linux/x64/release/

dst=flutter_sherpa_onnx_linux_x64
mv bundle $dst

pushd $dst/lib

ls -lh
mv -v libonnxruntime.so libonnxruntime.so.1.17.1
mv -v libpiper_phonemize.so libpiper_phonemize.so.1
popd

tar cjfv $dst.tar.bz2 $dst
ls -lh
mv $dst.tar.bz2 $d
popd

ls -lh $dst.tar.bz2

- uses: actions/upload-artifact@v2
with:
name: flutter-sherpa-onnx-linux-x64
path: ./*.tar.bz2
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
name: flutter
name: flutter-macos

on:
push:
branches:
- flutter
- flutter-sid-2
tags:
- '*'
paths:
- '.github/workflows/flutter.yaml'
- '.github/workflows/flutter-macos.yaml'
- 'CMakeLists.txt'
- 'cmake/**'
- 'sherpa-onnx/csrc/*'
Expand All @@ -18,7 +17,7 @@ on:
branches:
- master
paths:
- '.github/workflows/flutter.yaml'
- '.github/workflows/flutter-macos.yaml'
- 'CMakeLists.txt'
- 'cmake/**'
- 'sherpa-onnx/csrc/*'
Expand All @@ -28,17 +27,18 @@ on:
workflow_dispatch:

concurrency:
group: flutter-${{ github.ref }}
group: flutter-macos-${{ github.ref }}
cancel-in-progress: true

jobs:
flutter:
name: flutter
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
Expand All @@ -54,7 +54,7 @@ jobs:
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ matrix.os }}-flutter
key: ${{ matrix.os }}-flutter-${{ matrix.arch }}

- name: Display PWD
shell: bash
Expand All @@ -67,6 +67,11 @@ jobs:
run: |
uname -a

- name: Install tree
shell: bash
run: |
brew install tree

- name: Display flutter info
shell: bash
run: |
Expand All @@ -83,20 +88,22 @@ jobs:
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='arm64;x86_64' \
-DCMAKE_OSX_ARCHITECTURES=$arch \
-DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
-DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \
-DSHERPA_ONNX_ENABLE_BINARY=ON \
-DBUILD_ESPEAK_NG_EXE=OFF \
-DSHERPA_ONNX_ENABLE_BINARY=OFF \
-DCMAKE_INSTALL_PREFIX=./install \
..

- name: Build sherpa-onnx for macos
- name: Build sherpa-onnx for macos ${{ matrix.arch }}
shell: bash
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
Expand All @@ -105,7 +112,7 @@ jobs:
make -j2
make install

rm -v ./install/lib/libcargs*
rm -v ./install/lib/libonnxruntime.dylib

- name: Copy libs
shell: bash
Expand All @@ -122,14 +129,13 @@ jobs:
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/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
# git clone https://github.com/csukuangfj/sr-data

rm -rf sr-data/.git
popd


- name: Build flutter
shell: bash
run: |
Expand All @@ -139,20 +145,25 @@ jobs:
dart pub get

cd example
export FLUTTER_XCODE_ARCHS=${{ matrix.arch }}
echo "FLUTTER_XCODE_ARCHS: $FLUTTER_XCODE_ARCHS"
flutter build macos

pushd build/macos/Build/Products/Release/
tar cjfv sherpa_onnx.app.tar.bz2 ./sherpa_onnx.app
cd build/macos/Build/Products/Release/

tree ./sherpa_onnx.app

app=flutter_sherpa_onnx_macos_${{ matrix.arch }}.app
mv sherpa_onnx.app $app
tar cjfv $app.tar.bz2 $app
ls -lh
mv sherpa_onnx.app.tar.bz2 $d
popd
mv $app.tar.bz2 $d

popd

ls -lh sherpa_onnx.app.tar.bz2
ls -lh $app.tar.bz2

- uses: actions/upload-artifact@v4
if: matrix.os == 'macos-latest'
with:
name: flutter-sherpa-onnx-app-macos
path: ./sherpa_onnx.app.tar.bz2
name: flutter-sherpa-onnx-app-macos-${{ matrix.arch }}
path: ./*.tar.bz2
Loading
Loading