Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -87,42 +87,42 @@ def ui():
|
|
87 |
|
88 |
set_api_key(user_api_key)
|
89 |
|
90 |
-
#container for the chat history
|
91 |
-
response_container = st.container()
|
92 |
-
#container for the user's text input
|
93 |
-
container = st.container()
|
94 |
|
95 |
-
with container:
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
|
121 |
-
if 'generated' in st.session_state and st.session_state['generated']:
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
|
127 |
if __name__ == '__main__':
|
128 |
ui()
|
|
|
87 |
|
88 |
set_api_key(user_api_key)
|
89 |
|
90 |
+
# #container for the chat history
|
91 |
+
# response_container = st.container()
|
92 |
+
# #container for the user's text input
|
93 |
+
# container = st.container()
|
94 |
|
95 |
+
# with container:
|
96 |
+
with st.form(key='my_form', clear_on_submit=True):
|
97 |
+
audio_file = st.file_uploader("Upload an audio file ", type=[ "wav,Mp4","Mp3"])
|
98 |
+
submit_button = st.form_submit_button(label='Send')
|
99 |
+
if audio_file is not None and submit_button :
|
100 |
+
output_file_path = "./output_audio.mp3"
|
101 |
+
save_uploaded_file_as_mp3(audio_file,output_file_path )
|
102 |
+
hindi_input_audio,sample_rate= librosa.load(output_file_path, sr=None, mono=True)
|
103 |
+
#applying the audio recognition
|
104 |
+
hindi_transcription=parse_transcription('./output_audio.mp3')
|
105 |
+
st.success(f"Audio file saved as {output_file_path}")
|
106 |
+
#convert hindi to english
|
107 |
+
english_input=hindi_to_english(hindi_transcription)
|
108 |
+
#feeding the input to the LLM
|
109 |
+
english_output = conversational_chat(llm_chain,english_input)
|
110 |
+
#converting english to hindi
|
111 |
+
hin_output=translate_english_to_hindi(english_output)
|
112 |
+
#getting the hindi_tts
|
113 |
+
hindi_output_audio=hindi_tts(hin_output)
|
114 |
+
# hindi_output_file="./Hindi_output_Audio.Mp3"
|
115 |
+
# save_uploaded_file_as_mp3(hindi_out"put_audio,hindi_output_file)
|
116 |
+
st.audio(hindi_output_audio)
|
117 |
+
|
118 |
+
# st.session_state['past'].append(hindi_input_audio)
|
119 |
+
# st.session_state['generated'].append(hindi_output_audio)
|
120 |
|
121 |
+
# if 'generated' in st.session_state and st.session_state['generated']:
|
122 |
+
# with response_container:
|
123 |
+
# for i in range(len(st.session_state['generated'])):
|
124 |
+
# st.audio(st.session_state["past"][i],format='audio/wav')
|
125 |
+
# st.audio(st.session_state["generated"][i],format='audio/wav')
|
126 |
|
127 |
if __name__ == '__main__':
|
128 |
ui()
|