benjolo's picture
Create run.py
acacecc verified
raw
history blame
No virus
1.26 kB
import torch
from transformers import pipeline
translator = pipeline("automatic-speech-recognition",
"facebook/seamless-m4t-v2-large",
torch_dtype=torch.float32,
device="cpu")
converter = pipeline("translation",
"facebook/seamless-m4t-v2-large",
torch_dtype=torch.float32,
device="cpu")
asr_text = translator("https://huggingface.co/datasets/reach-vb/random-audios/resolve/main/ted_60.wav",
chunk_length_s=30,
generate_kwargs={"tgt_lang": "eng"})
print(asr_text)
# print(translator("https://huggingface.co/datasets/reach-vb/random-audios/resolve/main/ted_60.wav",
# chunk_length_s=30,
# generate_kwargs={"tgt_lang": "fra"}))
# print(translator("https://huggingface.co/datasets/reach-vb/random-audios/resolve/main/ted_60.wav",
# chunk_length_s=30,
# generate_kwargs={"tgt_lang": "ita"}))
# print(translator("https://huggingface.co/datasets/reach-vb/random-audios/resolve/main/ted_60.wav",
# chunk_length_s=30,
# generate_kwargs={"tgt_lang": "spa"}))
print(converter(asr_text['text'],
src_lang="eng", tgt_lang="spa")
)