File size: 1,564 Bytes
438833d
f6b625e
0e31adc
e001d2e
aa58e2f
eefcf53
57b9447
64a6ef4
6672a13
7a74048
aa58e2f
ed350f1
f098da2
302f1b5
cc6cbbe
0e31adc
da16091
caab77b
da16091
438833d
64a6ef4
754b842
302f1b5
f6b625e
e001d2e
f6b625e
794777e
 
 
 
359f6f7
0b3304a
 
 
 
be36f5d
eefcf53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0b3304a
 
 
511dc85
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from image import *
from language import *
from textToSpeach import *
from translation import *
import streamlit as st
import base64


# url = "https://i.imgur.com/qs0CxjE_d.webp?maxwidth=760&fidelity=grand"
# text = "How many cars are here?"

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')