Skip to main content

Streaming Automatic Speech Recognition (ASR) tools for Fujie Lab, built on ESPnet

Project description

fujielab-asr

Automatic Speech Recognition (ASR) modules for Fujie Laboratory, built on top of ESPnet.

fujielab-asr packages streaming-ASR extensions (the fujielab.asr.espnet_ext layer) on top of stock ESPnet, together with ready-to-use pretrained models on the Hugging Face Hub. It is designed for online / chunk-by-chunk recognition.

Features

  • Streaming ASR with a Contextual Block Streaming (CBS) encoder.
  • Recognizer families:
    • RNN-Transducer (Speech2Text) — streaming beam search.
    • CTC-only multitask (Speech2TextMultitaskCTC) — streaming greedy CTC that, in addition to the transcript, predicts a per-token auxiliary-information label via a separate head: N (normal), F (filler / フィラー), D (repair / 言い直し).
    • CTC-only (Speech2TextCTC) — streaming greedy CTC for models whose auxiliary markers are part of the recognized tokens (composite あ+F / チ+D, or span <F> あ の </F>).
  • Pretrained Japanese models distributed via the Hugging Face Hub (loaded with from_pretrained).

Installation

Requirements

  • Python 3.10 – 3.12 (tested on 3.11).
  • ESPnet >= 202412 — pulled in automatically as a dependency. (Older fujielab-asr (<= 0.1.3) targeted ESPnet 202301–202503; from 0.1.4 the package follows the newer ESPnet line, which uses typeguard 4.x.)
  • torch / torchaudio (install a build matching your CUDA / platform).

ESPnet has a few dependencies that build from source (e.g. pyworld); a working C/C++ toolchain is recommended when installing.

Install from PyPI

pip install fujielab-asr

We recommend a fresh virtual environment, e.g.:

python3.11 -m venv .venv && . .venv/bin/activate
pip install -U pip
pip install fujielab-asr

Install from source

git clone https://github.com/fujielab/fujielab-asr
cd fujielab-asr
pip install -e .

Pretrained models

Loaded by tag via from_pretrained. (The auxiliary-information models additionally emit F/D markers for fillers and repairs.)

Tag Type Tokens Corpus
fujie/espnet_asr_csj_pron_aux_cbs_ctc_120300_hop132 CTC multitask (N/F/D head) kana CSJ
fujie/espnet_asr_csj_pron_comp_cbs_ctc_120300_hop132 CTC composite (あ+F/チ+D) kana CSJ
fujie/espnet_asr_csj_pron_span_cbs_ctc_120300_hop132 CTC span (<F> あ </F>) kana CSJ
fujie/espnet_asr_cejc_pron_aux_cbs_transducer_081616_hop132 Transducer kana CEJC
fujie/espnet_asr_csj_writ_aux_cbs_transducer_081616_hop132 Transducer kanji CSJ
fujie/espnet_asr_cbs_transducer_120303_hop132_cc0105 Transducer kana CEJC+CSJ

The three CSJ pron CTC models (multitask / composite / span) share the same encoder and were trained on the same utterances — three encodings of the same filler/repair information. On CSJ eval, content CER is ~equal (≈6.7–6.8%); filler detection F1 ≈93 for all; repair detection F1 is composite ≈ multitask > span.

Example Usage

Runnable scripts are in the examples/ directory:

  • examples/run_streaming_asr.py — streaming Transducer ASR.
  • examples/run_streaming_asr_ctc.py — streaming CTC ASR (composite / span markers in tokens).
  • examples/run_streaming_asr_multitask.py — streaming CTC multitask ASR (transcript + filler/repair labels).
  • examples/run_streaming_asr_live.py — live (microphone) streaming ASR.
  • examples/demo.py — Gradio demo.

Streaming CTC multitask (recognition + auxiliary information)

import numpy as np, soundfile as sf
from fujielab.asr.espnet_ext.espnet2.bin.asr_multitask_ctc_inference_cbs import (
    Speech2TextMultitaskCTC,
)

s2t = Speech2TextMultitaskCTC.from_pretrained(
    "fujie/espnet_asr_csj_pron_aux_cbs_ctc_120300_hop132", streaming=True
)

audio, fs = sf.read("utterance.wav")  # 16 kHz mono
chunk = int(16000 * 0.1)              # 100 ms
for i in range(0, len(audio), chunk):
    c = audio[i:i + chunk]
    is_final = len(c) < chunk
    if is_final:
        c = np.pad(c, (0, chunk - len(c)))
    r = s2t.streaming_decode(c, is_final=is_final)[0]
    # r.tokens and r.aux_labels are aligned 1:1 (aux in {N, F, D})
    print(" ".join(f"{t}[{a}]" if a != "N" else t
                   for t, a in zip(r.tokens, r.aux_labels)))

License

Apache License 2.0. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fujielab_asr-0.1.6.tar.gz (40.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fujielab_asr-0.1.6-py3-none-any.whl (39.0 kB view details)

Uploaded Python 3

File details

Details for the file fujielab_asr-0.1.6.tar.gz.

File metadata

  • Download URL: fujielab_asr-0.1.6.tar.gz
  • Upload date:
  • Size: 40.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for fujielab_asr-0.1.6.tar.gz
Algorithm Hash digest
SHA256 7c55b75369cb8a67344e5033dd103a24002f0cd16875a13358adb515caecccc7
MD5 d7b46848418937aa8c3f2f9c06364ef7
BLAKE2b-256 123f503665167f2b9cfd1d33bf81fff7fa270d8dd4fe056a960eee7a5af69f96

See more details on using hashes here.

File details

Details for the file fujielab_asr-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: fujielab_asr-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 39.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for fujielab_asr-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 d404da6d61c1fbf629cf4ea2ec1e26a3b4926e0de93e356acdae2458b8e6982e
MD5 90ee21a47139af930752315db76c0dd8
BLAKE2b-256 5a3a55a89a1c760f59af3d6eefb7996d587bb518cc4a72557e7982ac0e3ed88e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page