mbzuai-nlp / ArTST

24 stars 2 forks source link

Colab Demo #4

Closed AhmadM-DL closed 5 months ago

AhmadM-DL commented 5 months ago

Hello guys, Nice work you did. I wonder how to run inference in a colab books.

I installed fairseq:

!git clone https://github.com/pytorch/fairseq
%cd fairseq 
!pip install --editable ./
!python setup.py build_ext --inplace

Installed AraTST:

!git clone https://github.com/mbzuai-nlp/artst
%cd artst
!pip install -r requirements.txt
!git lfs install
!git clone https://huggingface.co/MBZUAI/ArTST

But when I run task = ArTSTTask.setup_task(checkpoint['cfg']['task'])

I am getting the following fairseq error: FileNotFoundError: [Errno 2] No such file or directory: '/l/users/speech_lab/_SpeechT5PretrainDataset/v1/manifest/dict.txt'

Can you please provide a working colab?

djanibekov commented 5 months ago

@AhmadM-DL thank you for your interest in our project. Please clone HF repository with checkpoints and use this path to set location for data parameter

import torch

from artst.tasks.artst import ArTSTTask
from artst.models.artst import ArTSTTransformerModel

checkpoint = torch.load('...path-to-checkpoint')
checkpoint['cfg']['task'].t5_task = 's2t' # or "s2t" for asr
checkpoint['cfg']['task'].data = '...path-to-HF-repository'  <--- new line
task = ArTSTTask.setup_task(checkpoint['cfg']['task'])

model = ArTSTTransformerModel.build_model(checkpoint['cfg']['model'], task)
model.load_state_dict(checkpoint['model'])
djanibekov commented 5 months ago

Check out these demo notebooks

  1. demo-artst-asr.ipynb
  2. demo-artst-tts.ipynb