test / app.py
abil-ml's picture
Create app.py
eaa70d7 verified
raw
history blame contribute delete
No virus
712 Bytes
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")