Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ In this Learning Path, you'll learn how to convert the Stable Audio Open Small m

Your first task is to prepare a development environment with the required software:

- Android NDK: version r25b or newer.
- Android NDK: version r27b or newer.
- Python: version 3.10 or newer (tested with 3.10).
- CMake: version 3.16.0 or newer (tested with 3.28.1).

Expand All @@ -33,9 +33,7 @@ Download and install [Python version 3.10](https://www.python.org/downloads/rele

{{< tabpane code=true >}}
{{< tab header="Linux">}}
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.10 python3.10-venv python3.10-pip
sudo apt install -y python3.10 python3.10-venv
{{< /tab >}}
{{< tab header="MacOS">}}
brew install python@3.10
Expand All @@ -56,7 +54,7 @@ CMake is an open-source tool that automates the build process for software proje
{{< tabpane code=true >}}
{{< tab header="Linux">}}
sudo apt update
sudo apt install cmake
sudo apt install cmake g++ git
{{< /tab >}}
{{< tab header="MacOS">}}
brew install cmake
Expand Down Expand Up @@ -98,33 +96,57 @@ You can verify the installation and check the version with:
bazel --version
```

### Install Android NDK
### Install Android SDK and NDK

To build a native Android application you will need to install the Android SDK:

{{< tabpane code=true >}}
{{< tab header="Linux">}}
cd $WORKSPACE
sudo apt install openjdk-21-jdk openjdk-21-jre unzip
wget https://dl.google.com/android/repository/commandlinetools-linux-13114758_latest.zip
unzip -o commandlinetools-linux-13114758_latest.zip
mkdir -p $WORKSPACE/Android/Sdk
export ANDROID_HOME=$WORKSPACE/Android
export ANDROID_SDK_HOME=$ANDROID_HOME/Sdk
$WORKSPACE/cmdline-tools/bin/sdkmanager --sdk_root=$ANDROID_SDK_HOME --install "platform-tools" "platforms;android-35" "build-tools;35.0.0"
{{< /tab >}}
{{< tab header="MacOS">}}
cd $WORKSPACE
wget https://dl.google.com/android/repository/commandlinetools-mac-13114758_latest.zip
unzip -o commandlinetools-linux-13114758_latest.zip
mkdir -p $WORKSPACE/Android/Sdk
export ANDROID_HOME=$WORKSPACE/Android
export ANDROID_SDK_HOME=$ANDROID_HOME/Sdk
$WORKSPACE/cmdline-tools/bin/sdkmanager --sdk_root=$ANDROID_SDK_HOME --install "platform-tools" "platforms;android-35" "build-tools;35.0.0"
{{< /tab >}}
{{< /tabpane >}}

To run the model on Android, install Android Native Development Kit (Android NDK):

{{< tabpane code=true >}}
{{< tab header="Linux">}}
cd $WORKSPACE
wget https://dl.google.com/android/repository/android-ndk-r25b-linux.zip
unzip android-ndk-r25b-linux.zip
wget https://dl.google.com/android/repository/android-ndk-r27b-linux.zip
unzip android-ndk-r27b-linux.zip
{{< /tab >}}
{{< tab header="MacOS">}}
cd $WORKSPACE
wget https://dl.google.com/android/repository/android-ndk-r25b-darwin.zip
unzip android-ndk-r25b-darwin.zip
wget https://dl.google.com/android/repository/android-ndk-r27b-darwin.zip
unzip android-ndk-r27b-darwin.zip
{{< /tab >}}
{{< /tabpane >}}

For easier access and execution of Android NDK tools, add these to the `PATH` and set the `NDK_PATH` variable:

{{< tabpane code=true >}}
{{< tab header="Linux">}}
export NDK_PATH=$WORKSPACE/android-ndk-r25b/
export NDK_PATH=$WORKSPACE/android-ndk-r27b/
export ANDROID_NDK_HOME=$NDK_PATH
export PATH=$NDK_PATH/toolchains/llvm/prebuilt/linux-x86_64/bin/:$PATH
{{< /tab >}}
{{< tab header="MacOS">}}
export NDK_PATH=$WORKSPACE/android-ndk-r25b/
export NDK_PATH=$WORKSPACE/android-ndk-r27b/
export ANDROID_NDK_HOME=$NDK_PATH
export PATH=$NDK_PATH/toolchains/llvm/prebuilt/darwin-x86_64/bin/:$PATH
{{< /tab >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ You may need to fill out a form with your contact information to use the model:
Download and copy the configuration file `model_config.json` and the model itself, `model.ckpt`, to your workspace directory, and verify they exist by running the command:

```bash
ls $WORKSPACE/model_config.json $WORKSPACE/model.ckpt
ls -lha $WORKSPACE/model_config.json $WORKSPACE/model.ckpt
```

You can learn more about this model [here](https://huggingface.co/stabilityai/stable-audio-open-small).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ To avoid dependency issues, create a virtual environment. For example, you can u
cd $WORKSPACE
python3.10 -m venv .venv
source .venv/bin/activate
export PYTHON_BIN_PATH=$WORKSPACE/.venv/bin/python3
export PYTHON_LIB_PATH=$WORKSPACE/.venv/lib/python3.10/site-packages
```

## Clone the examples repository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,13 @@ From there, you can then run the audiogen application, which requires just three
* **Model Path:** The directory containing your LiteRT models and spiece.model files
* **Prompt:** A text description of the desired audio (e.g., warm arpeggios on house beats 120BPM with drums effect)
* **CPU Threads:** The number of CPU threads to use (e.g., 4)
* **Seed:** A random number to seed the generation (e.g. 1234)

Play around with the advice from [Download and test the model](../2-testing-model) section.

```bash
cd /data/local/tmp/app
LD_LIBRARY_PATH=. ./audiogen . "warm arpeggios on house beats 120BPM with drums effect" 4
LD_LIBRARY_PATH=. ./audiogen . "warm arpeggios on house beats 120BPM with drums effect" 4 1234
exit
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ learning_objectives:
- Run the application on an Android smartphone and generate an audio snippet.

prerequisites:
- A Linux-based x86 or macOS development machine with at least 8 GB of RAM (tested on Ubuntu 20.04.4 LTS with x86_64).
- A Linux-based x86 or macOS development machine with at least 8 GB of RAM and 50 GB of disk space (tested on Ubuntu 22.04 with x86_64).
- A [HuggingFace](https://huggingface.co/) account.
- An Android phone and a cable to connect it to your development machine.
- An Android phone in [developer mode](https://developer.android.com/studio/debug/dev-options) and a cable to connect it to your development machine.

author:
- Nina Drozd
Expand Down