Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
|
|
2 |
from elevenlabs import set_api_key
|
3 |
from elevenlabs import clone, generate, play
|
4 |
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
|
@@ -11,18 +12,20 @@ import streamlit as st
|
|
11 |
|
12 |
|
13 |
#language translation function
|
14 |
-
def
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
model =
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
26 |
|
27 |
|
28 |
def save_uploaded_file_as_mp3(uploaded_file, output_file_path):
|
|
|
1 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
2 |
+
from transformers import MarianMTModel, MarianTokenizer
|
3 |
from elevenlabs import set_api_key
|
4 |
from elevenlabs import clone, generate, play
|
5 |
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
|
|
|
12 |
|
13 |
|
14 |
#language translation function
|
15 |
+
def translate_english_to_hindi(input_text):
|
16 |
+
# Load the pre-trained English to Hindi translation model and tokenizer
|
17 |
+
model_name = "Helsinki-NLP/opus-mt-en-hi"
|
18 |
+
tokenizer = MarianTokenizer.from_pretrained(model_name)
|
19 |
+
model = MarianMTModel.from_pretrained(model_name)
|
20 |
+
|
21 |
+
# Tokenize the input text and generate translation
|
22 |
+
inputs = tokenizer(input_text, return_tensors="pt", padding=True)
|
23 |
+
translated_ids = model.generate(inputs.input_ids)
|
24 |
+
|
25 |
+
# Decode the translated output
|
26 |
+
translated_text = tokenizer.decode(translated_ids[0], skip_special_tokens=True)
|
27 |
+
|
28 |
+
return translated_text
|
29 |
|
30 |
|
31 |
def save_uploaded_file_as_mp3(uploaded_file, output_file_path):
|