# 🦉 Hoot 🦉
transcribing all the data...

# Usage
Use suno_util's interface.
```python
import os
from suno_utils.tasks.hoot import preload_models, encode_filepaths
# v0 model, en 
# model_dir = "s3://suno-data/datasets/bundles/v1/models/hoot_v0"
# _ = preload_models(
#     checkpoint_filepath=os.path.join(model_dir, "2023-05-26_16-55-38_last_ckpt.pt"),
#     tokenizer_filepath=os.path.join(model_dir, "tokenizer.model"),
# )
# v1 model, mulit-lingo
# model_dir = "s3://suno-data/checkpoints/hoot_v1"
# v3 model, mulit-lingo
# model_dir = "s3://suno-data/checkpoints/hoot_v3"
# v4 model, mulit-lingo
model_dir = "s3://suno-data/checkpoints/hoot_v4"
_ = preload_models(
    checkpoint_filepath=os.path.join(model_dir, "hoot_ckpt.pt"),
    tokenizer_filepath=os.path.join(model_dir, "tokenizer.model"),
)
transcription = encode_filepaths(["/home/tony/Work/tony/audios/test_adele.mp3"])
```
You should get the output as a list of string, corresponding to transcription of each file.


# Background

This module is a thin inference wrapper around NeMo's Fast Conformer CTC model. A pretrained checkpoint can be downloaded from here:
- https://catalog.ngc.nvidia.com/orgs/nvidia/teams/nemo/models/stt_en_fastconformer_ctc_large
- https://catalog.ngc.nvidia.com/orgs/nvidia/teams/nemo/models/stt_multilingual_fastconformer_hybrid_large_pc
- https://catalog.ngc.nvidia.com/orgs/nvidia/teams/nemo/models/stt_en_fastconformer_ctc_xlarge
- https://catalog.ngc.nvidia.com/orgs/nvidia/teams/nemo/models/stt_en_fastconformer_ctc_xxlarge

It can then be used like this
```python
import sys
sys.path.insert(0, "/Users/georg/code/hoot/")

from hoot import Hoot
model = Hoot.from_nemo(
    "/my/dir/stt_en_fastconformer_ctc_large/model_weights.ckpt",
    "/my/dir/stt_en_fastconformer_ctc_large/129be3e4b71e449e86261ee42b6849fa_vocab.txt",
)

model.predict_wav("/my/dir/my_audio.wav")
```

# Training

## Pretrained model

First, you will need to download the pre-trained model.
Training the model from scratch will take ~20khrs of audio + several hundred epochs (probably 1k).
On a single A100 this will likely take more than a month.

``` python
import nemo.collections.asr as nemo_asr
import torch
asr_model = nemo_asr.models.EncDecCTCModelBPE.from_pretrained(model_name="stt_en_fastconformer_ctc_large")
torch.save(asr_model.state_dict(), "/home/tony/Data/Hoot/stt_en_fastconformer_ctc_large.pt")
```

Current training receipe:
- train a multi-version with vocab 20480, from pre-trained NVDIA model, on a more language balanced dataset filtered with low word error rate from prev version of hoot.

## Data preparation
This is crucial for the success of the model. Follow the [notebook](https://github.com/suno-ai/tony/blob/e96d6cf5fee701a2cc06fa08d5968a0a1c44e67a/hoot/Hoot_training_data_selection_and_preparation.ipynb).
The notebook contains data preparation and tokenizer preparation.

## Train script
Training script is [train_audios.py](scripts/train_audios.py). Follow the instructions on top the file to train it.

This works on slurm now.

# Versions

- v1 (or v0 in prod naming) -- trained only in english. [wandb run](https://wandb.ai/suno/hoot-v1/runs/o5h7ei03)
- v2 (or v1 in prod naming) -- multi-lingo. [wandb run](https://wandb.ai/suno/hoot-v2/runs/1baufbsk/)
- v3 -- multi-lingo. [wandb run](https://wandb.ai/suno/hoot-v2/runs/4dte74de/)
- v4 -- multi-lingo. [wandb run](https://wandb.ai/suno/hoot-v2/runs/a2wixub3/)
- v5 -- multi-lingo. [wandb run](https://wandb.ai/suno/hoot-v2/runs/tkw4w2dp/)