RomajiASR is a Japanese phoneme ASR project focused on singing transcription.
The project is built on top of prj-beatrice/japanese-hubert-base-phoneme-ctc and extends that line of work with additional training on tens of hours of singing audio. The target output is romanized phoneme tokens (romaji-style phoneme sequences). In internal experiments, this repository achieved better singing transcription accuracy and robustness than the original baseline.
The public source tree is intentionally lightweight:
- training code is included
- PyTorch inference code is included
- ONNX export and ONNX Runtime inference are included
- forced-alignment-related modules are still present, but are experimental
- datasets, manifests, and large training artifacts are not included in the repository
- A HuBERT-based phoneme CTC training pipeline for Japanese singing ASR
- PyTorch inference for checkpoint directories
- ONNX export utilities for deployment or runtime experiments
- ONNX Runtime inference with CPU, CUDA, or DirectML provider selection
- Experimental FA-related modules for alignment-oriented research
- This repository does not ship datasets or training manifests.
- Existing configs may contain local placeholder paths that you should edit for your own environment.
- The released pretrained models are expected to be provided separately in
safetensorscheckpoint form and ONNX form. - The currently provided pretrained models do not include FA capability unless explicitly stated otherwise.
- FA-related code should be treated as experimental research code rather than a stable public interface.
.
|-- configs/ Training and experiment configs
|-- src/ Training, inference, export, evaluation, and FA code
|-- third_party/k2/ Vendored k2 code used by some experimental components
|-- requirements.txt Base Python dependencies
`-- .gitignore
Main entry points:
src/train.py: main HuBERT-based training pipelinesrc/infer.py: PyTorch checkpoint inferencesrc/export_onnx.py: export a checkpoint to ONNXsrc/infer_onnx.py: run ONNX Runtime inferencesrc/train_alignment.py: experimental alignment losses and FA-related training helpers
Base environment:
pip install -r requirements.txtFor ONNX export and ONNX inference, install additional packages as needed:
pip install onnx onnxruntimeIf you want GPU or DirectML execution, use the runtime package that matches your environment, for example:
pip install onnxruntime-gpuor
pip install onnxruntime-directmlThis repository expects manifest-style JSONL files prepared by the user.
A minimal phoneme-ASR manifest entry looks like:
{"audio": "path/to/audio.wav", "phones": ["a", "i", "u", "e", "o"]}Common optional fields used by the training code include:
duration_secphones_basealt_phonesn_phones- alignment-related fields for experimental FA / phone-alignment branches
The vocabulary file is expected to be a JSON mapping from token string to integer ID, for example:
{
"<blank>": 0,
"<unk>": 1,
"a": 2,
"i": 3
}The main training entry point is:
python src/train.py --config configs/exp8_base_retrain.yamlTo resume from the last saved training state:
python src/train.py --config configs/exp8_base_retrain.yaml --resume_from_checkpoint path/to/last_state.ptBefore running training, make sure you update the config file to point to:
- your pretrained backbone or checkpoint
- your train manifest
- your dev manifest
- your vocabulary JSON
- your output directory
The default configs in configs/ are examples from local experiments, not portable turnkey presets.
Run inference from a checkpoint directory:
python src/infer.py --ckpt path/to/checkpoint_dir --audio path/to/test.wavRun inference on a manifest:
python src/infer.py --ckpt path/to/checkpoint_dir --manifest path/to/test.jsonlOptional decoding controls:
--decode greedy|beam--beam_width--nbest--token_prune_size--insertion_penalty--length_bonus--phoneme_lm--lm_weight
If --vocab is omitted, the script tries to auto-detect phoneme_vocab.json from the checkpoint directory.
Export a checkpoint to ONNX:
python src/export_onnx.py --ckpt path/to/checkpoint_dir --out path/to/model.onnx --opset 17Example with dynamic time axis:
python src/export_onnx.py --ckpt path/to/checkpoint_dir --dynamic_time --opset 17Useful export options:
--export_mode full_logits|minimal_logits|minimal_pred_ids--dynamic_time--dynamic_batch--fp16--fp16_io--skip_verify
The exporter also writes metadata next to the ONNX file.
Run ONNX inference on a single file:
python src/infer_onnx.py --model path/to/model.onnx --audio path/to/test.wav --provider autoRun ONNX inference on a manifest:
python src/infer_onnx.py --model path/to/model.onnx --manifest path/to/test.jsonl --provider autoAvailable providers:
autocpucudadml
The ONNX inference path also supports beam search and optional phoneme LM rescoring when the exported model returns logits rather than pre-argmax IDs.
Pretrained models are intended to be distributed separately from the source repository, for example through GitHub Releases.
Recommended release contents:
safetensorscheckpoint packageconfig.jsonmodel.safetensorsphoneme_vocab.json- optional:
token_expansion_map.json - optional:
train_config.yaml
- ONNX package
model.onnxmodel.meta.jsonphoneme_vocab.json
Recommended local layout after download:
checkpoints/
`-- your_model_name/
`-- best/
|-- config.json
|-- model.safetensors
|-- phoneme_vocab.json
|-- token_expansion_map.json
`-- train_config.yaml
PyTorch inference example:
python src/infer.py --ckpt checkpoints/your_model_name/best --audio path/to/test.wavONNX inference example:
python src/infer_onnx.py --model path/to/model.onnx --audio path/to/test.wav --provider autoFor public distribution, model.safetensors is preferred over pytorch_model.bin because it is a tensor-only format and avoids pickle-based deserialization.
This repository still contains FA-related modules such as:
src/fa_modules.pysrc/train_alignment.pysrc/infer_fa_textgrid.pysrc/hfa_textgrid.py
These components are experimental.
Two important limitations:
- the public pretrained models for this repository should not be assumed to support FA
- FA behavior, labels, and alignment supervision formats are more fragile than the main phoneme-ASR path
If your goal is standard singing phoneme transcription, start with the main train.py, infer.py, export_onnx.py, and infer_onnx.py workflow.
This repository is primarily for:
- Japanese singing phoneme transcription
- romaji-style phoneme-token output
- HuBERT-based CTC training and inference
- ONNX export and runtime experiments
It is not intended to be a dataset release repository.
This project is based on and inspired by:
That upstream model line provided the starting point for the singing-focused training and experimentation in this repository.