ailia_speech  1.6.1.0
Running QNN on Yocto Linux

Validated environment

Component Environment
Board / SoC Advantech AOM-2721 / Qualcomm QCS6490
Yocto Based on 4.0.22 (Kirkstone)
OS QCOM Robotics Reference Distro with ROS 1.3-ver.1.1
OS ID qcom-robotics-ros2-humble
Linux kernel 6.6.52-yl01301-ga97804e47e26
CPU architecture aarch64
glibc 2.35
Python 3.10.15
QNN runtime QAIRT 2.47.0.260601 / Hexagon v68

The Linux ARM64 binaries require at most glibc 2.35 and GLIBCXX_3.4.29. They can use the system C++ runtime in the environment listed below.

Use the prebuilt Linux ARM64 sample in the distribution package. No compiler installation or sample build is required on the board. The BSP must provide CDSP firmware, FastRPC libcdsprpc.so, and access to the CDSP device.

1. Get the required files (host PC)

Extract the ailia Speech SDK distribution package and download:

Choose either Turbo or Medium. The following example uses Turbo. Extract QAIRT and set SPEECH_PACKAGE and QNN_SDK_PATH to the extracted directories.

export SPEECH_PACKAGE=/path/to/ailia_speech_package
export QNN_SDK_PATH=/path/to/qairt/2.47.0.260601
export DEPLOY="$PWD/qnn-yocto"
mkdir -p "$DEPLOY"

2. Copy the sample and dependencies (host PC)

The package's cpp/prebuilt/linux/arm64-v8a/ directory includes the following files. No separate ailia SDK, ailia Audio or ailia Tokenizer native-library download is needed.

File Purpose
ailia_speech_sample Prebuilt C++ sample
libailia_speech.so Speech recognition library
libailia_speech_qnn.so QNN plug-in
libailia.so ailia SDK
libailia_audio.so Audio preprocessing
libailia_tokenizer.so Tokenizer

Copy these files into the deployment directory.

cp -R "$SPEECH_PACKAGE/cpp/prebuilt/linux/arm64-v8a/." "$DEPLOY/"
cp "$SPEECH_PACKAGE/cpp/demo.wav" "$DEPLOY/"
curl -L --fail -o "$DEPLOY/whisper-large-v3-turbo-qcs6490-int16.qnn" \
https://storage.googleapis.com/ailia-models/whisper/qnn/v1.6.0/whisper-large-v3-turbo-qcs6490-int16.qnn

3. Copy the QNN libraries (host PC)

Copy QAIRT's aarch64-oe-linux-gcc11.2 libraries and the Hexagon v68 skel. Do not use Android or Windows binaries. Use the board's BSP FastRPC library and CDSP firmware.

cp "$QNN_SDK_PATH/lib/aarch64-oe-linux-gcc11.2/libQnnHtp.so" "$DEPLOY/"
cp "$QNN_SDK_PATH/lib/aarch64-oe-linux-gcc11.2/libQnnSystem.so" "$DEPLOY/"
cp "$QNN_SDK_PATH/lib/aarch64-oe-linux-gcc11.2/libQnnHtpV68Stub.so" "$DEPLOY/"
cp "$QNN_SDK_PATH/lib/hexagon-v68/unsigned/libQnnHtpV68Skel.so" "$DEPLOY/"

4. Transfer to the board (host PC)

Adjust the SSH address and user. If an evaluation license is required, place a valid license at ~/.shalo/ailia.lic on the board (setup).

scp -r "$DEPLOY" root@169.254.239.42:/home/root/

5. Run the C++ sample (board)

Run the following commands on the board. No LD_LIBRARY_PATH setting is needed: the sample loads the ailia libraries from its own directory, and the QNN plug-in loads the QNN libraries and v68 skel from the same directory. Pass the model path as the second argument. cpu selects the ailia environment for auxiliary processing. QNN speech recognition runs on HTP / NPU. VAD, diarization and postprocessing are disabled.

cd /home/root/qnn-yocto
chmod +x ./ailia_speech_sample
./ailia_speech_sample demo.wav whisper-large-v3-turbo-qcs6490-int16.qnn \
auto transcribe vad_disable diarization_disable none cpu

6. Run from Python (board)

Install the Python package

Use Python 3 and pip3. If the BSP does not include pip3, install it first:

curl -L --fail -o get-pip.py https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py

To install from the SDK package, also extract the SDK on the board. Run bootstrap.py to copy the bundled libraries into the Python package, then install:

cd /path/to/ailia_speech_package/python
python3 bootstrap.py
pip3 install .

Alternatively, install the public package:

pip3 install ailia_speech

Copy QNN libraries into the installed package

The Location shown by pip3 show is the site-packages directory. The plug-in is installed in ailia_speech/linux/arm64-v8a/ beneath it. Copy the QNN libraries and v68 skel beside libailia_speech_qnn.so:

pip3 show ailia_speech
SITE_PACKAGES=$(pip3 show ailia_speech | sed -n 's/^Location: //p')
SPEECH_NATIVE="$SITE_PACKAGES/ailia_speech/linux/arm64-v8a"
test -f "$SPEECH_NATIVE/libailia_speech_qnn.so"
cd /home/root/qnn-yocto
cp libQnnHtp.so libQnnSystem.so libQnnHtpV68Stub.so libQnnHtpV68Skel.so "$SPEECH_NATIVE/"

Start Python after copying the libraries. The system C++ runtime must support GLIBCXX_3.4.29 or later; no additional LD_LIBRARY_PATH setting is needed.

Open local models from an application

open() opens the specified local files instead of initialize_model(), which downloads models automatically. Save the following code as /home/root/qnn-yocto/transcribe_qnn.py on the board. It reads audio as float32 with soundfile, loads the model and prints the recognition results. Install soundfile for this example:

pip3 install soundfile

Transpose the audio to the (channels, samples) shape accepted by ailia Speech. Call get_qnn_model_name() on the instance to obtain the device model name. Enable set_qnn_graph_switching(True) before open() to reduce HTP memory usage; inference may take longer. Pass one file for QNN. The Python Turbo constant is used by default.

import argparse
import soundfile as sf
import ailia_speech
parser = argparse.ArgumentParser()
parser.add_argument("--model", required=True)
parser.add_argument("--input", required=True)
parser.add_argument("--model-type", type=int,
default=ailia_speech.AILIA_SPEECH_MODEL_TYPE_WHISPER_MULTILINGUAL_LARGE_V3_TURBO)
parser.add_argument("--language", default=None)
args = parser.parse_args()
waveform, sampling_rate = sf.read(args.input, dtype="float32", always_2d=True)
waveform = waveform.T
speech = ailia_speech.Whisper()
print("QNN model:", speech.get_qnn_model_name())
speech.set_qnn_graph_switching(True)
speech.open(
args.model,
model_type=args.model_type,
vad_path=None,
segmentation_path=None,
embedding_path=None,
)
for segment in speech.transcribe(waveform, sampling_rate, lang=args.language):
print(segment["text"], flush=True)

Run after copying the QNN libraries in step 6. Language is detected automatically; add –language ja to select Japanese explicitly.

cd /home/root/qnn-yocto
python3 transcribe_qnn.py \
--model ./whisper-large-v3-turbo-qcs6490-int16.qnn --input ./demo.wav

For ONNX, pass two files with open(encoder_path, decoder_path, model_type=...).

For VAD, pass a local ONNX file such as vad_path="silero_vad_v6_2.onnx". For diarization, supply both segmentation_path="segmentation.onnx" and embedding_path="speaker-embedding.onnx". These ONNX models can be used with QNN recognition. Each optional path defaults to None, which skips loading that model. The default vad_type is Silero and diarization_type is Pyannote. Supplying VAD applies the same silent thresholds as initialize_model(). Select FP16 and VAD version through the supplied files. Place external ONNX weights at the locations referenced by the ONNX file. None does not unload a previously loaded model.

Using the Medium model

Download and transfer the Medium model instead of Turbo in step 2.

curl -L --fail -o "$DEPLOY/whisper-medium-qcs6490-int16.qnn" \
https://storage.googleapis.com/ailia-models/whisper/qnn/v1.6.0/whisper-medium-qcs6490-int16.qnn
scp "$DEPLOY/whisper-medium-qcs6490-int16.qnn" root@169.254.239.42:/home/root/qnn-yocto/

Run on the board in /home/root/qnn-yocto. For Python, copy the libraries as in step 6:

./ailia_speech_sample demo.wav whisper-medium-qcs6490-int16.qnn \
auto transcribe vad_disable diarization_disable none cpu
python3 transcribe_qnn.py \
--model ./whisper-medium-qcs6490-int16.qnn --input ./demo.wav --model-type 3

Troubleshooting

Error Action
GLIBCXX_x.x.xx not found GLIBCXX_3.4.29 or later (a Yocto 4.0 or later BSP) is required. Check the BSP version.
GLIBC_2.xx not found Check binary requirements against the BSP's glibc. Use a compatible BSP; do not overwrite individual libc.so.6 or loader files.
QnnSystem interface version mismatch Check that the QAIRT 2.47 Yocto libraries are selected.
Missing libcdsprpc.so / DSP initialization failure Check BSP FastRPC, CDSP firmware, device permissions and the v68 skel.