Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit 86aff27

Browse files
authored
update of streaming ASR for PT 1.11 (#240)
* initial commit * Revert "initial commit" This reverts commit 5a65775. * main readme and helloworld/demo app readme updates * update of streaming ASR for PT 1.11
1 parent 486fc7a commit 86aff27

4 files changed

Lines changed: 14 additions & 10 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ The [PyTorch demo app](https://github.com/pytorch/android-demo-app/tree/master/P
4242

4343
[Speech Recognition](https://github.com/pytorch/android-demo-app/tree/master/SpeechRecognition) demonstrates how to convert Facebook AI's wav2vec 2.0, one of the leading models in speech recognition, to TorchScript and how to use the scripted model in an Android app to perform speech recognition.
4444

45+
### Streaming Speech recognition
46+
47+
[Streaming Speech Recognition](https://github.com/pytorch/android-demo-app/tree/master/StreamingASR) demonstrates how to how to use a new torchaudio pipeline to perform streaming speech recognition, powered by Java Native Call to a C++ audio processing library for the mel spectrogram transform.
48+
4549
### Video Classification
4650

4751
[TorchVideo](https://github.com/pytorch/android-demo-app/tree/master/TorchVideo) demonstrates how to use a pre-trained video classification model, available at the newly released [PyTorchVideo](https://github.com/facebookresearch/pytorchvideo), on Android to see video classification results, updated per second while the video plays, on tested videos, videos from the Photos library, or even real-time videos.

StreamingASR/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ In the Speech Recognition Android [demo app](https://github.com/pytorch/android-
66

77
## Prerequisites
88

9-
* PyTorch 1.10.1 and torchaudio 0.10.1 or above (Optional)
9+
* PyTorch 1.11 and torchaudio 0.11 or above (Optional)
1010
* Python 3.8 (Optional)
11-
* Android Pytorch library org.pytorch:pytorch_android_lite:1.10.0
11+
* Android Pytorch library org.pytorch:pytorch_android_lite:1.11.0
1212
* Android Studio 4.0.1 or later
1313

1414
## Quick Start
@@ -22,7 +22,7 @@ git clone https://github.com/pytorch/android-demo-app
2222
cd android-demo-app/StreamingASR
2323
```
2424

25-
If you don't have PyTorch 1.10.1 and torchaudio 0.10.1 installed or want to have a quick try of the demo app, you can download the optimized scripted model file [streaming_asr.ptl](https://drive.google.com/file/d/1awT_1S6H5IXSOOqpFLmpeg0B-kQVWG2y/view?usp=sharing), then drag and drop it to the `StreamingASR/app/src/main/assets` folder inside `android-demo-app/StreamingASR`, and continue to Step 3.
25+
If you don't have PyTorch 1.11 and torchaudio 0.11 installed or want to have a quick try of the demo app, you can download the optimized scripted model file [streaming_asr.ptl](https://drive.google.com/file/d/1awT_1S6H5IXSOOqpFLmpeg0B-kQVWG2y/view?usp=sharing), then drag and drop it to the `StreamingASR/app/src/main/assets` folder inside `android-demo-app/StreamingASR`, and continue to Step 3.
2626

2727
Also you need to download [Eigen](https://eigen.tuxfamily.org/), a C++ template library for linear algebra, for Android NDK build required to run the app (see last section of this README for more info):
2828
```
@@ -32,16 +32,16 @@ git clone https://github.com/jeffxtang/eigen
3232

3333
### 2. Test and Prepare the Model
3434

35-
To install PyTorch 1.10.1, torchaudio 0.10.1, and other required Python packages (numpy and pyaudio), do something like this:
35+
To install PyTorch 1.11, torchaudio 0.11, and other required Python packages (numpy and pyaudio), do something like this:
3636

3737
```
38-
conda create -n pt1.10.1 python=3.8.5
39-
conda activate pt1.10.1
38+
conda create -n pt1.11 python=3.8.5
39+
conda activate pt1.11
4040
pip install torch torchaudio numpy pyaudio
4141
```
4242

4343
Now download the streaming ASR model file
44-
[scripted_wrapper_tuple_no_transform.pt](https://drive.google.com/file/d/1_49DwHS_a3p3THGdHZj3TXmjNJj60AhP/view?usp=sharing) (the script used to create the model will be published soon) to the `android-demo-app/StreamingASR` directory.
44+
[scripted_wrapper_tuple_no_transform.pt](https://drive.google.com/file/d/1_49DwHS_a3p3THGdHZj3TXmjNJj60AhP/view?usp=sharing) to the `android-demo-app/StreamingASR` directory.
4545

4646
To test the model, run `python run_sasr.py`. After you see:
4747
```
@@ -59,7 +59,7 @@ mv streaming_asr.ptl StreamingASR/app/src/main/assets
5959

6060
### 3. Build and run with Android Studio
6161

62-
Start Android Studio, open the project located in `android-demo-app/StreamingASR/StreamingASR`, build and run the app on an Android device. After the app runs, tap the Start button and start saying something. Some example recognition results are:
62+
Start Android Studio, open the project located in `android-demo-app/StreamingASR/StreamingASR`, build and run the app on an Android device (not an emulator). After the app runs, tap the Start button and start saying something. Some example recognition results are:
6363

6464
![](screenshot1.png)
6565
![](screenshot2.png)

StreamingASR/StreamingASR/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ dependencies {
5050
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
5151
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
5252

53-
implementation 'org.pytorch:pytorch_android_lite:1.10.0'
53+
implementation 'org.pytorch:pytorch_android_lite:1.11'
5454
}

StreamingASR/save_model_for_mobile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ def get_demo_wrapper():
99
wrapper = get_demo_wrapper()
1010
scripted_model = torch.jit.script(wrapper)
1111
optimized_model = optimize_for_mobile(scripted_model)
12-
optimized_model._save_for_lite_interpreter("sasr.ptl")
12+
optimized_model._save_for_lite_interpreter("streaming_asr.ptl")
1313
print("Done _save_for_lite_interpreter")

0 commit comments

Comments
 (0)