|
from image import * |
|
from language import * |
|
from textToSpeach import * |
|
from translation import * |
|
import streamlit as st |
|
import base64 |
|
|
|
|
|
|
|
|
|
|
|
st.write('Part 1') |
|
|
|
question = st.text_input('Posez votre question') |
|
url = st.text_input('mettez le liens de votre image') |
|
tts = st.checkbox('lire la réponse') |
|
if url : |
|
st.image(url, width=250) |
|
|
|
|
|
if st.button('générer'): |
|
question = frenchtoenglish(question) |
|
responseBase = image(url, question) |
|
st.write('response is :', responseBase) |
|
|
|
st.write('Part 2') |
|
enResponse = longText(responseBase, question) |
|
frResponse = englishtofrench(enResponse) |
|
st.write('en : ',enResponse) |
|
st.write('fr : ',frResponse) |
|
|
|
st.write('Part 3 : TTS') |
|
|
|
if tts: |
|
st.write('le TTS est en cours de chargement') |
|
st.audio(speaking(frResponse)) |
|
def autoplay_audio(file_path: str): |
|
with open(file_path, "rb") as f: |
|
data = f.read() |
|
b64 = base64.b64encode(data).decode() |
|
md = f""" |
|
<audio controls autoplay="true"> |
|
<source src="data:audio/mp3;base64,{b64}" type="audio/mp3"> |
|
</audio> |
|
""" |
|
st.markdown( |
|
md, |
|
unsafe_allow_html=True, |
|
) |
|
|
|
|
|
st.write("# Auto-playing Audio!") |
|
|
|
autoplay_audio("DoTTS_generation.wav") |
|
else: |
|
st.write('Pas de tts demander') |
|
|
|
|
|
|