Spaces:
Sleeping
Sleeping
vteam27
commited on
Commit
•
71ad94c
1
Parent(s):
556017a
env test
Browse files- app.py +16 -0
- requirements.txt +6 -0
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import SeamlessM4TForTextToText
|
3 |
+
from transformers import AutoProcessor, SeamlessM4TModel
|
4 |
+
model = SeamlessM4TForTextToText.from_pretrained("facebook/hf-seamless-m4t-medium")
|
5 |
+
processor = AutoProcessor.from_pretrained("facebook/hf-seamless-m4t-medium")
|
6 |
+
|
7 |
+
text_inputs = processor(text = "Hello, my dog is cute", src_lang="eng", return_tensors="pt")
|
8 |
+
output_tokens = model.generate(**text_inputs, tgt_lang="pan")
|
9 |
+
translated_text_from_text = processor.decode(output_tokens[0].tolist(), skip_special_tokens=True)
|
10 |
+
print(translated_text_from_text)
|
11 |
+
|
12 |
+
def greet(name):
|
13 |
+
return translated_text_from_text
|
14 |
+
|
15 |
+
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
16 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
transformers
|
3 |
+
fairseq2==0.1
|
4 |
+
pydub
|
5 |
+
yt-dlp
|
6 |
+
sentencepiece
|