Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
# Load models (assuming these are the correct paths)
|
5 |
+
translatormodel = gr.Interface.load("models/Helsinki-NLP/opus-mt-es-en")
|
6 |
+
speechmodel = gr.Interface.load("models/facebook/mms-tts-eng")
|
7 |
+
|
8 |
+
def translate_and_speak(text):
|
9 |
+
translation = translatormodel(text)[0] # Assuming the first element is the translation
|
10 |
+
speech_output = speechmodel(translation, lang="en")[0] # Assuming the first element is the audio
|
11 |
+
return speech_output
|
12 |
+
|
13 |
+
st.title("Traductor")
|
14 |
+
text = st.text_area("Por favor, escriba lo que quiere decir para oírlo en Inglés")
|
15 |
+
|
16 |
+
if st.button("Escuchar"):
|
17 |
+
speech_output = translate_and_speak(text)
|
18 |
+
st.audio(speech_output, format="audio/wav")
|