File size: 584 Bytes
e511180
51c33c0
e511180
51c33c0
1917902
51c33c0
1917902
 
51c33c0
1917902
51c33c0
 
 
1917902
51c33c0
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import streamlit as st
from transformers import AutoProcessor, SeamlessM4Tv2ForTextToText

processor = AutoProcessor.from_pretrained("facebook/seamless-m4t-v2-large")

model = SeamlessM4Tv2ForTextToText.from_pretrained("facebook/seamless-m4t-v2-large")


text_inputs = processor(text = "Hello, my dog is cute", src_lang="eng", return_tensors="pt")

# from text
output_tokens = model.generate(**text_inputs, tgt_lang="fra", generate_speech=False)
translated_text_from_text = processor.decode(output_tokens[0].tolist()[0], skip_special_tokens=True)


st.write(translated_text_from_text)