-
Notifications
You must be signed in to change notification settings - Fork 474
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
112c0e0
commit da6ff8d
Showing
8 changed files
with
241 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,23 @@ jobs: | |
echo "ANDROID_NDK_LATEST_HOME: ${ANDROID_NDK_LATEST_HOME}" | ||
ls -lh ${ANDROID_NDK_LATEST_HOME} | ||
- name: Setup build tool version variable | ||
shell: bash | ||
run: | | ||
echo "---" | ||
ls -lh /usr/local/lib/android/ | ||
echo "---" | ||
ls -lh /usr/local/lib/android/sdk | ||
echo "---" | ||
ls -lh /usr/local/lib/android/sdk/build-tools | ||
echo "---" | ||
BUILD_TOOL_VERSION=$(ls /usr/local/lib/android/sdk/build-tools/ | tail -n 1) | ||
echo "BUILD_TOOL_VERSION=$BUILD_TOOL_VERSION" >> $GITHUB_ENV | ||
echo "Last build tool version is: $BUILD_TOOL_VERSION" | ||
- name: build APK | ||
shell: bash | ||
run: | | ||
|
@@ -59,13 +76,77 @@ jobs: | |
run: | | ||
ls -lh ./apks/ | ||
- uses: actions/upload-artifact@v4 | ||
# https://github.com/marketplace/actions/sign-android-release | ||
- uses: r0adkll/sign-android-release@v1 | ||
name: Sign app APK | ||
with: | ||
path: ./apks/*.apk | ||
releaseDirectory: ./apks | ||
signingKeyBase64: ${{ secrets.ANDROID_SIGNING_KEY }} | ||
alias: ${{ secrets.ANDROID_SIGNING_KEY_ALIAS }} | ||
keyStorePassword: ${{ secrets.ANDROID_SIGNING_KEY_STORE_PASSWORD }} | ||
env: | ||
BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOL_VERSION }} | ||
|
||
- name: Release APK | ||
uses: svenstaro/upload-release-action@v2 | ||
- name: Display APK after signing | ||
shell: bash | ||
run: | | ||
ls -lh ./apks/ | ||
du -h -d1 . | ||
- name: Rename APK after signing | ||
shell: bash | ||
run: | | ||
cd apks | ||
rm -fv signingKey.jks | ||
rm -fv *.apk.idsig | ||
rm -fv *-aligned.apk | ||
all_apks=$(ls -1 *-signed.apk) | ||
echo "----" | ||
echo $all_apks | ||
echo "----" | ||
for apk in ${all_apks[@]}; do | ||
n=$(echo $apk | sed -e s/-signed//) | ||
mv -v $apk $n | ||
done | ||
cd .. | ||
ls -lh ./apks/ | ||
du -h -d1 . | ||
- name: Display APK after rename | ||
shell: bash | ||
run: | | ||
ls -lh ./apks/ | ||
du -h -d1 . | ||
- name: Publish to huggingface | ||
env: | ||
HF_TOKEN: ${{ secrets.HF_TOKEN }} | ||
uses: nick-fields/retry@v3 | ||
with: | ||
file_glob: true | ||
file: apks/*.apk | ||
overwrite: true | ||
max_attempts: 20 | ||
timeout_seconds: 200 | ||
shell: bash | ||
command: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Fangjun Kuang" | ||
rm -rf huggingface | ||
export GIT_LFS_SKIP_SMUDGE=1 | ||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-apk huggingface | ||
cd huggingface | ||
git fetch | ||
git pull | ||
git merge -m "merge remote" --ff origin main | ||
mkdir -p kws | ||
cp -v ../apks/*.apk ./kws/ | ||
git status | ||
git lfs track "*.apk" | ||
git add . | ||
git commit -m "add more apks" | ||
git push https://csukuangfj:[email protected]/csukuangfj/sherpa-onnx-apk main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
lib | ||
hs_err* | ||
!run-streaming*.sh | ||
!run-non-streaming*.sh | ||
!run-*.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
java-api-examples/SpokenLanguageIdentificationWhisper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright 2024 Xiaomi Corporation | ||
|
||
// This file shows how to use a multilingual whisper model for | ||
// spoken language identification. | ||
// | ||
// Note that it needs a multilingual whisper model. For instance, | ||
// tiny works, but tiny.en doesn't. | ||
import com.k2fsa.sherpa.onnx.*; | ||
|
||
public class SpokenLanguageIdentificationWhisper { | ||
public static void main(String[] args) { | ||
// please download model and test files from | ||
// https://github.com/k2-fsa/sherpa-onnx/releases/tag/asr-models | ||
String encoder = "./sherpa-onnx-whisper-tiny/tiny-encoder.int8.onnx"; | ||
String decoder = "./sherpa-onnx-whisper-tiny/tiny-decoder.int8.onnx"; | ||
|
||
String[] testFiles = | ||
new String[] { | ||
"./spoken-language-identification-test-wavs/en-english.wav", | ||
"./spoken-language-identification-test-wavs/de-german.wav", | ||
"./spoken-language-identification-test-wavs/zh-chinese.wav", | ||
"./spoken-language-identification-test-wavs/es-spanish.wav", | ||
"./spoken-language-identification-test-wavs/fa-persian.wav", | ||
"./spoken-language-identification-test-wavs/ko-korean.wav", | ||
"./spoken-language-identification-test-wavs/ja-japanese.wav", | ||
"./spoken-language-identification-test-wavs/ru-russian.wav", | ||
"./spoken-language-identification-test-wavs/uk-ukrainian.wav", | ||
}; | ||
|
||
SpokenLanguageIdentificationWhisperConfig whisper = | ||
SpokenLanguageIdentificationWhisperConfig.builder() | ||
.setEncoder(encoder) | ||
.setDecoder(decoder) | ||
.build(); | ||
|
||
SpokenLanguageIdentificationConfig config = | ||
SpokenLanguageIdentificationConfig.builder() | ||
.setWhisper(whisper) | ||
.setNumThreads(1) | ||
.setDebug(true) | ||
.build(); | ||
|
||
SpokenLanguageIdentification slid = new SpokenLanguageIdentification(config); | ||
for (String filename : testFiles) { | ||
WaveReader reader = new WaveReader(filename); | ||
|
||
OfflineStream stream = slid.createStream(); | ||
stream.acceptWaveform(reader.getSamples(), reader.getSampleRate()); | ||
|
||
String lang = slid.compute(stream); | ||
System.out.println("---"); | ||
System.out.printf("filename: %s\n", filename); | ||
System.out.printf("lang: %s\n", lang); | ||
|
||
stream.release(); | ||
} | ||
System.out.println("---"); | ||
|
||
slid.release(); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
java-api-examples/run-spoken-language-identification-whisper.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -ex | ||
|
||
if [[ ! -f ../build/lib/libsherpa-onnx-jni.dylib && ! -f ../build/lib/libsherpa-onnx-jni.so ]]; then | ||
mkdir -p ../build | ||
pushd ../build | ||
cmake \ | ||
-DSHERPA_ONNX_ENABLE_PYTHON=OFF \ | ||
-DSHERPA_ONNX_ENABLE_TESTS=OFF \ | ||
-DSHERPA_ONNX_ENABLE_CHECK=OFF \ | ||
-DBUILD_SHARED_LIBS=ON \ | ||
-DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \ | ||
-DSHERPA_ONNX_ENABLE_JNI=ON \ | ||
.. | ||
|
||
make -j4 | ||
ls -lh lib | ||
popd | ||
fi | ||
|
||
if [ ! -f ../sherpa-onnx/java-api/build/sherpa-onnx.jar ]; then | ||
pushd ../sherpa-onnx/java-api | ||
make | ||
popd | ||
fi | ||
|
||
if [[ ! -f ../build/lib/libsherpa-onnx-jni.dylib && ! -f ../build/lib/libsherpa-onnx-jni.so ]]; then | ||
cmake \ | ||
-DSHERPA_ONNX_ENABLE_PYTHON=OFF \ | ||
-DSHERPA_ONNX_ENABLE_TESTS=OFF \ | ||
-DSHERPA_ONNX_ENABLE_CHECK=OFF \ | ||
-DBUILD_SHARED_LIBS=ON \ | ||
-DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \ | ||
-DSHERPA_ONNX_ENABLE_JNI=ON \ | ||
.. | ||
|
||
make -j4 | ||
ls -lh lib | ||
fi | ||
|
||
# Note that it needs a multilingual whisper model. so, for example, tiny works while tiny.en does not work | ||
# https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-whisper-tiny.tar.bz2 | ||
if [ ! -f ./sherpa-onnx-whisper-tiny/tiny-encoder.int8.onnx ]; then | ||
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-whisper-tiny.tar.bz2 | ||
tar xvf sherpa-onnx-whisper-tiny.tar.bz2 | ||
rm sherpa-onnx-whisper-tiny.tar.bz2 | ||
fi | ||
|
||
if [ ! -f ./spoken-language-identification-test-wavs/en-english.wav ]; then | ||
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/spoken-language-identification-test-wavs.tar.bz2 | ||
tar xvf spoken-language-identification-test-wavs.tar.bz2 | ||
rm spoken-language-identification-test-wavs.tar.bz2 | ||
fi | ||
|
||
java \ | ||
-Djava.library.path=$PWD/../build/lib \ | ||
-cp ../sherpa-onnx/java-api/build/sherpa-onnx.jar \ | ||
./SpokenLanguageIdentificationWhisper.java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters