Skip to content
Open
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
71 changes: 71 additions & 0 deletions src/qai_hub_models/models/phowhisper_small/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# [PhoWhisper-Small: Vietnamese-specialized automatic speech recognition (ASR) model, fine-tuned from Whisper-Small for accurate on-device transcription of Vietnamese speech](https://aihub.qualcomm.com/models/phowhisper_small)

PhoWhisper-Small is a Vietnamese fine-tune of OpenAI's Whisper-Small ASR (Automatic Speech Recognition) model. It shares the same transformer encoder-decoder architecture as Whisper-Small but is trained on a large, diverse Vietnamese speech corpus covering multiple dialects, substantially improving Vietnamese transcription accuracy over the generic multilingual checkpoint. It fills the gap of having no Vietnamese-specialized ASR model in the catalog. Like Whisper-Small, it has been optimized for edge inference by replacing Multi-Head Attention (MHA) with Single-Head Attention (SHA) and linear layers with convolutional (conv) layers, and it transcribes audio clips up to 30 seconds long. Time to the first token is the encoder's latency, while time to each additional token is decoder's latency, where we assume a max decoded length specified below.

On the Vietnamese FLEURS test set, PhoWhisper-Small attains a word error rate (WER) of 11.0%, compared with 21.4% for the generic Whisper-Small checkpoint.

This is based on the implementation of PhoWhisper found [here](https://github.com/VinAIResearch/PhoWhisper).
This repository contains scripts for optimized on-device export suitable to run on Qualcomm® devices. More details on model performance across various devices, can be found [here](https://aihub.qualcomm.com/models/phowhisper_small).

Qualcomm AI Hub Models uses [Qualcomm AI Hub Workbench](https://workbench.aihub.qualcomm.com) to compile, profile, and evaluate this model. [Sign up](https://myaccount.qualcomm.com/signup) to run these models on a hosted Qualcomm® device.

## Setup
### 1. Install System-Level Dependencies
#### Linux
```bash
sudo apt install ffmpeg libportaudio2
```

#### Windows
```
winget install ffmpeg
```

### 2. Install the package
Install the package via pip:
```bash
# NOTE: 3.10 <= PYTHON_VERSION < 3.14 is supported.
pip install "qai-hub-models[phowhisper-small]"
```

### 3. Configure Qualcomm® AI Hub Workbench
Sign-in to [Qualcomm® AI Hub Workbench](https://workbench.aihub.qualcomm.com/) with your
Qualcomm® ID. Once signed in navigate to `Account -> Settings -> API Token`.

With this API token, you can configure your client to run models on the cloud
hosted devices.
```bash
qai-hub configure --api_token API_TOKEN
```
Navigate to [docs](https://workbench.aihub.qualcomm.com/docs/) for more information.

## Run CLI Demo
Run the following simple CLI demo to verify the model is working end to end:

```bash
python -m qai_hub_models.models.phowhisper_small.demo
```
More details on the CLI tool can be found with the `--help` option. See
[demo.py](demo.py) for sample usage of the model including pre/post processing
scripts. Please refer to our [general instructions on using
models](../../../#getting-started) for more usage instructions.

## Export for on-device deployment
To run the model on Qualcomm® devices, you must export the model for use with an edge runtime such as
TensorFlow Lite, ONNX Runtime, or Qualcomm AI Engine Direct. Use the following command to export the model:
```bash
python -m qai_hub_models.models.phowhisper_small.export --device "Samsung Galaxy S25 (Family)"
```
Additional options are documented with the `--help` option.

## License
* The license for the original implementation of PhoWhisper can be found
[here](https://github.com/VinAIResearch/PhoWhisper/blob/main/LICENSE).

## References
* [PhoWhisper: Automatic Speech Recognition for Vietnamese](https://arxiv.org/abs/2406.02555)
* [Source Model Implementation](https://github.com/VinAIResearch/PhoWhisper)

## Community
* Join [our AI Hub Slack community](https://aihub.qualcomm.com/community/slack) to collaborate, post questions and learn more about on-device AI.
* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com).
13 changes: 13 additions & 0 deletions src/qai_hub_models/models/phowhisper_small/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# ---------------------------------------------------------------------
# Copyright (c) 2025 Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause
# ---------------------------------------------------------------------

from qai_hub_models.models._shared.hf_whisper.app import (
HfWhisperApp as App,
)

from .model import MODEL_ID
from .model import PhoWhisperSmall as Model

__all__ = ["MODEL_ID", "App", "Model"]
12 changes: 12 additions & 0 deletions src/qai_hub_models/models/phowhisper_small/code-gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
is_collection_model: true
requires_aot_prepare: true
readme_install_system_deps: |
#### Linux
```bash
sudo apt install ffmpeg libportaudio2
```

#### Windows
```
winget install ffmpeg
```
38 changes: 38 additions & 0 deletions src/qai_hub_models/models/phowhisper_small/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# ---------------------------------------------------------------------
# Copyright (c) 2025 Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause
# ---------------------------------------------------------------------
# THIS FILE WAS AUTO-GENERATED. DO NOT EDIT MANUALLY.

import gc
import warnings

import pytest
import torch.jit._trace

from qai_hub_models.models.phowhisper_small import Model
from qai_hub_models.scorecard.utils.testing import make_cached_from_pretrained_fixture


def pytest_configure(config: pytest.Config) -> None:
# pytest is unable to figure out how to silence several PyTorch warning types from pyproject.toml settings,
# so we apply a manual warning filter here instead.
warnings.filterwarnings(action="ignore", category=torch.jit._trace.TracerWarning)
warnings.filterwarnings(action="ignore", category=UserWarning, module="torch.*")
warnings.filterwarnings(action="ignore", category=FutureWarning, module="torch.*")
warnings.filterwarnings(
action="ignore", category=DeprecationWarning, module="torch.*"
)


# Instantiate the model only once for all tests.
# Mock from_pretrained to always return the initialized model.
# This speeds up tests and limits memory leaks.
cached_from_pretrained = make_cached_from_pretrained_fixture(
Model, skip_clone_repo=False
)


@pytest.fixture(scope="module", autouse=True)
def ensure_gc() -> None:
gc.collect()
15 changes: 15 additions & 0 deletions src/qai_hub_models/models/phowhisper_small/demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# ---------------------------------------------------------------------
# Copyright (c) 2025 Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause
# ---------------------------------------------------------------------

from qai_hub_models.models._shared.hf_whisper.demo import hf_whisper_demo
from qai_hub_models.models.phowhisper_small.model import MODEL_ID, PhoWhisperSmall


def main(is_test: bool = False) -> None:
hf_whisper_demo(PhoWhisperSmall, MODEL_ID, is_test)


if __name__ == "__main__":
main()
Loading