File size: 1,261 Bytes
acacecc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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")
    )