alexshah's picture mariam-av's picture
OhanASR-Streaming-v0.1
d3136c4
|
Raw History Blame Contribute Delete
6.21 kB
---
license: cc-by-nc-4.0
language:
- hy
pipeline_tag: automatic-speech-recognition
tags:
- pytorch
- armenian
- speech-recognition
- streaming
---
# OhanASR-Streaming-v0.1
![OhanASR Streaming Poster](https://cdn-uploads.huggingface.co/production/uploads/65cf49796c48188b990b7b00/vrXswvo45Zw4nZ3_uheuF.png)
OhanASR-Streaming-v0.1 is an Armenian streaming automatic speech recognition model. It transcribes Armenian
speech into punctuated, cased Armenian text while the audio arrives: the audio is processed in 1-second chunks,
and the text of each chunk is available 0.3 seconds after the chunk ends.
## Scores
Evaluated on 10,113 clips across five Armenian speech datasets, decoded in streaming mode with the settings of
the example below (beam 2, sliding decoder context of 15 s / 5 s). Scores are percentages; lower is better.
Both columns apply number normalization; the second also applies text normalization.
| Dataset | WER with number normalization (%) | WER with text and number normalization (%) |
|---|---:|---:|
| Combined | 19.0654 | 8.5682 |
| Common Voice 26 | 11.9138 | 7.3646 |
| FLEURS | 13.3043 | 4.8317 |
| Poems | 30.1002 | 7.9612 |
| Movies | 44.9982 | 24.5011 |
| Infocom May 26 | 18.0185 | 6.1361 |
## Installation
Use Linux with Python 3.10 or 3.11 (tested with 3.11; `omnilingual-asr` 0.2.0 does not install on
Python 3.12.1 or newer). Install the audio library required by fairseq2 and the pinned dependencies from this
repository's `requirements.txt`:
```bash
sudo apt install libsndfile1 # Debian/Ubuntu; with conda: conda install -c conda-forge libsndfile==1.0.31
pip install -r https://huggingface.co/Metric-AI/OhanASR-Streaming-v0.1/resolve/main/requirements.txt
```
The checkpoint uses the fairseq2 format rather than the Transformers AutoModel format, and is loaded
with the `omnilingual-asr` library installed above.
## Usage
```python
import sys
from pathlib import Path
import soundfile as sf
import torch
import torchaudio.functional as AF
from huggingface_hub import snapshot_download
folder = Path(snapshot_download("Metric-AI/OhanASR-Streaming-v0.1"))
sys.path.insert(0, str(folder))
from ohanasr_streaming import SAMPLE_RATE, StreamingTranscriber, load_model
# ---- load the model (GPU in bfloat16 if available, otherwise CPU in float32) -----------
model, tokenizer = load_model(folder)
# ---- streaming decoder settings --------------------------------------------------------
transcriber = StreamingTranscriber(
model, tokenizer,
beam=2, # beam search width for each 1 s chunk
max_context_sec=15.0, # sliding decoder context: cut when it would exceed 15 s of audio...
keep_sec=5.0, # ...and keep chunk 1 + the last 4 chunks (with their text)
lang="hye_Armn",
)
def load_audio(path: str) -> torch.Tensor:
"""Read any soundfile-supported file as 16 kHz mono float32."""
x, sr = sf.read(path, dtype="float32", always_2d=True)
x = torch.from_numpy(x.mean(axis=1))
return AF.resample(x, sr, SAMPLE_RATE) if sr != SAMPLE_RATE else x
audio = load_audio("audio.wav")
text = transcriber.transcribe(
audio,
on_chunk=lambda i, end_sec, chunk_text: print(f"{end_sec:6.1f} s {chunk_text}"),
)
print(text)
```
`on_chunk` is called after every 1-second chunk with the text of that chunk, as a live application would
display it; `transcribe` returns the whole transcript.
### How streaming works
- **Encoder.** The audio is split into 1 s chunks. Each chunk is encoded from that chunk, at most 3 s of audio
before it and 0.3 s after it, and nothing else, so its result never changes once computed and the text of a
chunk is ready 0.3 s after the chunk ends.
- **Decoder.** Each chunk is transcribed with beam search (`beam=2`), conditioned on the earlier chunks and the
text already produced for them:
`[chunk 1] <lid> <lang> <bos> [text 1] [chunk 2] [text 2] ... [chunk i] -> text i`.
- **Sliding decoder context.** To keep the cost per chunk bounded on long audio, chunk 1, the prompt tokens
and the text of chunk 1 are always kept, and when the context would exceed `max_context_sec` only the last
`keep_sec - 1` chunks with their text are kept; the context then grows again. With 15 s / 5 s, chunk 16 is
transcribed from `[chunk 1] <lid> <lang> <bos> [text 1] [chunk 12] [text 12] ... [chunk 15] [text 15] [chunk 16]`,
and the context is cut again at chunks 26, 36, ...
`transcribe` computes the encoder output of all chunks of the given audio in one pass (each chunk still sees
only its own window, so the result equals chunk-by-chunk processing). Its memory therefore grows with the
input length: the scores above were measured on clips of up to 33 s, and very long recordings are best given
to it in pieces.
## Files
- `model.pt`: OhanASR-Streaming model weights (float32).
- `ohanasr_tokenizer.model`: matching tokenizer (10,291 tokens).
- `streaming_encoder.py`: the chunk-wise streaming encoder (1 s chunks, 3 s left context, 0.3 s lookahead).
- `ohanasr_streaming.py`: model loading and chunk-by-chunk decoding with beam search and the sliding context.
- `model.json`: model configuration, streaming and decoding settings, file hashes, and detailed scores.
- `requirements.txt`: pinned Python dependencies.
- `LICENSE`: CC BY-NC 4.0 license text.
## License
This model is released under the [Creative Commons Attribution-NonCommercial 4.0 International](https://creativecommons.org/licenses/by-nc/4.0/)
license (CC BY-NC 4.0); see `LICENSE`. You may use, share and adapt it for non-commercial purposes with
attribution.
## Citation
If you use OhanASR-Streaming-v0.1 in your research, please cite it as follows:
```bibtex
@misc{ohan-asr-streaming-v0.1,
title={OhanASR-Streaming-v0.1: Streaming Armenian Speech-to-Text Model},
author={Metric-AI-Lab},
year={2026},
howpublished={\url{https://huggingface.co/Metric-AI/OhanASR-Streaming-v0.1}},
note={Streaming Speech-to-Text Model for Armenian}
}
```
## Acknowledgements
We acknowledge the EuroHPC Joint Undertaking for awarding this project access to the EuroHPC supercomputer LUMI, hosted by CSC (Finland) and the LUMI consortium. The training of OhanASR-Streaming-v0.1 was run on LUMI.