File size: 712 Bytes
eaa70d7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import streamlit as st
import gradio as gr

# Load models (assuming these are the correct paths)
translatormodel = gr.Interface.load("models/Helsinki-NLP/opus-mt-es-en")
speechmodel = gr.Interface.load("models/facebook/mms-tts-eng")

def translate_and_speak(text):
    translation = translatormodel(text)[0]  # Assuming the first element is the translation
    speech_output = speechmodel(translation, lang="en")[0]  # Assuming the first element is the audio
    return speech_output

st.title("Traductor")
text = st.text_area("Por favor, escriba lo que quiere decir para oírlo en Inglés")

if st.button("Escuchar"):
    speech_output = translate_and_speak(text)
    st.audio(speech_output, format="audio/wav")