This section uses the whisper-medium model as an example to introduce the on-device execution flow.
This process applies to scenarios where a quantized model is deployed and executed directly on the device.
Please first read the On-device Preparation section to complete the necessary setup and understand the correspondence between models and sample files.
whisper-mediumonly supports 16 kHz, single-channel audio.
The maximum audio duration allowed for a single inference is 30 seconds.
Within theoellm_runtime directory, the files and folders used by whisper-mediumare as follows:
The on-device configuration file whisper_config.json includes the following parameters:
| Parameter Name | Description | Required / Optional |
|---|---|---|
model_dir | Description: Directory path where the model files are stored on the device Type: string | Required |
encode_model_file | Description: Filename of the encoder model Type: string | Required |
decode_model_file | Description: Filename of the decoder model Type: string | Required |
encode_bpu_core | Description: BPU cores used by the encoder; specify cores in the format[0,1,2,3]when using multipleType: [int] | Required |
decode_bpu_core | Description: BPU cores used by the decoder; specify cores in the format[0,1,2,3]when using multipleType: [int] | Required |
vocabulary_path | Description: Path to the tokenizer configuration Type: string | Required |
language | Description: Target language for transcription Type: stringOptions: zh: Chineseen: EnglishDefault: zh | Optional |
Example configuration:
A one-click execution script run_whisper.sh is provided.
Contents of the script:
Executable parameter info:
Execution result for the test sample0.wav
whisper_demo can directly read local audio files and supports common formats such as mp3,wav and flac.
The program uses Essentia's MonoLoader to resample audio to 16 kHz, convert it into a float32 (-1.0 ~ 1.0) 1-D vector, and pass it to the ASR model through the xlm_feed_audio_online interface.xlm_feed_audio_online supports a maximum of 30 seconds of audio input. Any excess duration is discarded before inference, along with a warning.int16_t format, convert it to float32 first—typically by dividing by 32768 and casting the data type.