File size: 2,042 Bytes
91428a3
 
21c0ae2
c257f88
ffd9653
c257f88
 
4005740
 
a194ba7
4005740
c257f88
ffd9653
c257f88
4005740
 
c257f88
 
ffd9653
 
 
 
 
 
 
 
4005740
a194ba7
 
cdd7596
a194ba7
c257f88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4005740
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
# have to run this locally as streamlit run app.py
import streamlit as st
from Autocorrect.autocorrectreal import edit
from TestTranslation.translation import decode_sequence
from TestTranslationChinese.translation_model import decode_sequence_chinese
from AudioToText.condensedmodel import AudioToTextUsingAPI
from AudioToText.condensedmodel import AudioToTextUsingModel


st.title("FIRE COML Summer 2022 Translation Model")

option = st.selectbox("Select input type:", ("Text input", "Audio input"))
option2 = st.selectbox("Select translation language:", ("Spanish", "Chinese"))
if option == "Text input":
    input_sentence = st.text_input("Enter input sentence:")
    if input_sentence is not None and len(input_sentence) > 0:
        edited = edit(input_sentence)
        st.write("Autocorrected sentence: " + edited)
        if option2 == "Spanish":
            translated = decode_sequence(edited)[8:-5]
            st.write(translated)
            input_sentence = None
        else:
            translated = decode_sequence_chinese(edited)[8:]
            st.write(translated)
            input_sentence = None
else:
    wav_sentence = st.file_uploader("Upload an audio file (.wav):", type=\
        ["wav"])
    option3 = st.selectbox("Select audio to text model to use:", ("Our pretrained model", "Google API"))
    if st.button("Submit audio file"):
        if option3 == "Our pretrained model":
            input_list = AudioToTextUsingModel(wav_sentence)
            input_sentence = "".join(input_list)
        else:
            input_sentence = AudioToTextUsingAPI(wav_sentence)
        st.write("Raw audio to text: " + input_sentence)
        edited = edit(input_sentence)
        st.write("Autocorrected sentence: " + edited)
        if option2 == "Spanish":
            translated = decode_sequence(edited)[8:-5]
            st.write(translated)
            input_sentence = None
        else:
            translated = decode_sequence_chinese(edited)[8:]
            st.write(translated)
            input_sentence = None