Spaces:
Runtime error
Runtime error
Steven Zhang
commited on
Commit
•
c257f88
1
Parent(s):
9e4caf3
audio update
Browse files- .gitignore +3 -1
- AudioToText/condensedmodel.py +3 -2
- app.py +26 -10
.gitignore
CHANGED
@@ -133,4 +133,6 @@ EngToSpanishckpts/
|
|
133 |
cmn.txt
|
134 |
re-model.h5
|
135 |
TestTranslationChinese/cmn.txt
|
136 |
-
TestTranslationChinese/re-model.h5
|
|
|
|
133 |
cmn.txt
|
134 |
re-model.h5
|
135 |
TestTranslationChinese/cmn.txt
|
136 |
+
TestTranslationChinese/re-model.h5
|
137 |
+
AudioToText/AudioToTextCKPT.hdf5
|
138 |
+
AudioToTextCKPT.hdf5
|
AudioToText/condensedmodel.py
CHANGED
@@ -184,10 +184,11 @@ def getSpectro(wav_file):
|
|
184 |
|
185 |
return spectrogram
|
186 |
|
|
|
|
|
187 |
# CONVERT AUDIO TO TEXT
|
188 |
def AudioToTextUsingModel(wav_file):
|
189 |
-
|
190 |
-
loadWeights()
|
191 |
|
192 |
# Get Spectrogram
|
193 |
spectro = getSpectro(wav_file)
|
184 |
|
185 |
return spectrogram
|
186 |
|
187 |
+
# Load Weights
|
188 |
+
loadWeights()
|
189 |
# CONVERT AUDIO TO TEXT
|
190 |
def AudioToTextUsingModel(wav_file):
|
191 |
+
|
|
|
192 |
|
193 |
# Get Spectrogram
|
194 |
spectro = getSpectro(wav_file)
|
app.py
CHANGED
@@ -1,31 +1,47 @@
|
|
1 |
# have to run this locally as streamlit run app.py
|
2 |
import streamlit as st
|
3 |
from Autocorrect.autocorrectreal import edit
|
4 |
-
from TestTranslation.translation import
|
5 |
from TestTranslationChinese.translation_model import decode_sequence_chinese
|
|
|
|
|
6 |
|
7 |
|
8 |
st.title("Translation model test")
|
9 |
|
10 |
-
option = st.selectbox("Select input type:", ("
|
11 |
option2 = st.selectbox("Select translation language:", ("Spanish", "Chinese"))
|
12 |
-
if option == "
|
13 |
input_sentence = st.text_input("Enter input sentence:")
|
14 |
if input_sentence is not None and len(input_sentence) > 0:
|
|
|
|
|
15 |
if option2 == "Spanish":
|
16 |
-
edited = edit(input_sentence)
|
17 |
-
st.write("Autocorrected sentence: " + edited)
|
18 |
translated = decode_sequence(edited)[8:-5]
|
19 |
st.write(translated)
|
20 |
input_sentence = None
|
21 |
else:
|
22 |
-
edited = edit(input_sentence)
|
23 |
-
st.write("Autocorrected sentence: " + edited)
|
24 |
translated = decode_sequence_chinese(edited)[8:]
|
25 |
st.write(translated)
|
26 |
input_sentence = None
|
27 |
else:
|
28 |
-
wav_sentence = st.file_uploader("Upload a wav file:")
|
29 |
-
st.
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
1 |
# have to run this locally as streamlit run app.py
|
2 |
import streamlit as st
|
3 |
from Autocorrect.autocorrectreal import edit
|
4 |
+
from TestTranslation.translation import decode_sequence
|
5 |
from TestTranslationChinese.translation_model import decode_sequence_chinese
|
6 |
+
from AudioToText.condensedmodel import AudioToTextUsingAPI
|
7 |
+
from AudioToText.condensedmodel import AudioToTextUsingModel
|
8 |
|
9 |
|
10 |
st.title("Translation model test")
|
11 |
|
12 |
+
option = st.selectbox("Select input type:", ("Text input", "Audio input"))
|
13 |
option2 = st.selectbox("Select translation language:", ("Spanish", "Chinese"))
|
14 |
+
if option == "Text input":
|
15 |
input_sentence = st.text_input("Enter input sentence:")
|
16 |
if input_sentence is not None and len(input_sentence) > 0:
|
17 |
+
edited = edit(input_sentence)
|
18 |
+
st.write("Autocorrected sentence: " + edited)
|
19 |
if option2 == "Spanish":
|
|
|
|
|
20 |
translated = decode_sequence(edited)[8:-5]
|
21 |
st.write(translated)
|
22 |
input_sentence = None
|
23 |
else:
|
|
|
|
|
24 |
translated = decode_sequence_chinese(edited)[8:]
|
25 |
st.write(translated)
|
26 |
input_sentence = None
|
27 |
else:
|
28 |
+
wav_sentence = st.file_uploader("Upload a .wav file:")
|
29 |
+
option3 = st.selectbox("Select audio to text model to use:", ("Our pretrained model", "Google API"))
|
30 |
+
if st.button("Submit .wav file"):
|
31 |
+
if option3 == "Our pretrained model":
|
32 |
+
input_list = AudioToTextUsingModel(wav_sentence)
|
33 |
+
input_sentence = "".join(input_list)
|
34 |
+
else:
|
35 |
+
input_sentence = AudioToTextUsingAPI(wav_sentence)
|
36 |
+
st.write("Raw audio to text: " + input_sentence)
|
37 |
+
edited = edit(input_sentence)
|
38 |
+
st.write("Autocorrected sentence: " + edited)
|
39 |
+
if option2 == "Spanish":
|
40 |
+
translated = decode_sequence(edited)[8:-5]
|
41 |
+
st.write(translated)
|
42 |
+
input_sentence = None
|
43 |
+
else:
|
44 |
+
translated = decode_sequence_chinese(edited)[8:]
|
45 |
+
st.write(translated)
|
46 |
+
input_sentence = None
|
47 |
|