Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -31,9 +31,12 @@ from helper import parse_transcription,hindi_to_english,translate_english_to_hin
|
|
| 31 |
def extract_text_from_html(html):
|
| 32 |
cleanr = re.compile('<.*?>')
|
| 33 |
cleantext = re.sub(cleanr, '', html)
|
| 34 |
-
def conversational_chat(
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
def save_uploaded_file_as_mp3(uploaded_file, output_file_path):
|
| 39 |
audio = AudioSegment.from_file(uploaded_file)
|
|
@@ -70,12 +73,15 @@ def ui():
|
|
| 70 |
hi_audio,sample_rate2=librosa.load('./good-morning-sir.mp3')
|
| 71 |
if 'history' not in st.session_state:
|
| 72 |
st.session_state['history'] = []
|
|
|
|
| 73 |
|
| 74 |
if 'generated' not in st.session_state:
|
| 75 |
st.session_state['generated'] = [hi_audio]
|
|
|
|
| 76 |
|
| 77 |
if 'past' not in st.session_state:
|
| 78 |
st.session_state['past'] = [good_morining_audio]
|
|
|
|
| 79 |
|
| 80 |
if user_api_key is not None and user_api_key.strip() != "":
|
| 81 |
eleven_labs_api_key = st.sidebar.text_input(
|
|
@@ -112,8 +118,11 @@ def ui():
|
|
| 112 |
# hindi_output_file="./Hindi_output_Audio.Mp3"
|
| 113 |
# save_uploaded_file_as_mp3(hindi_out"put_audio,hindi_output_file)
|
| 114 |
st.audio(hindi_output_audio)
|
|
|
|
| 115 |
|
| 116 |
st.session_state['past'].append(hindi_input_audio)
|
|
|
|
|
|
|
| 117 |
st.session_state['generated'].append(hindi_output_audio)
|
| 118 |
|
| 119 |
if 'generated' in st.session_state and st.session_state['generated']:
|
|
@@ -128,11 +137,3 @@ def ui():
|
|
| 128 |
|
| 129 |
if __name__ == '__main__':
|
| 130 |
ui()
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
|
|
|
| 31 |
def extract_text_from_html(html):
|
| 32 |
cleanr = re.compile('<.*?>')
|
| 33 |
cleantext = re.sub(cleanr, '', html)
|
| 34 |
+
def conversational_chat(chain,query):
|
| 35 |
+
result = chain({"question": query,
|
| 36 |
+
"chat_history": st.session_state['history_text']})
|
| 37 |
+
st.session_state['history_text'].append((query, result["answer"]))
|
| 38 |
+
|
| 39 |
+
return result["answer"]
|
| 40 |
|
| 41 |
def save_uploaded_file_as_mp3(uploaded_file, output_file_path):
|
| 42 |
audio = AudioSegment.from_file(uploaded_file)
|
|
|
|
| 73 |
hi_audio,sample_rate2=librosa.load('./good-morning-sir.mp3')
|
| 74 |
if 'history' not in st.session_state:
|
| 75 |
st.session_state['history'] = []
|
| 76 |
+
st.session_state['history_text']=[]
|
| 77 |
|
| 78 |
if 'generated' not in st.session_state:
|
| 79 |
st.session_state['generated'] = [hi_audio]
|
| 80 |
+
st.session_states['generated_text']=[]
|
| 81 |
|
| 82 |
if 'past' not in st.session_state:
|
| 83 |
st.session_state['past'] = [good_morining_audio]
|
| 84 |
+
st.session_states['past_text']=[]
|
| 85 |
|
| 86 |
if user_api_key is not None and user_api_key.strip() != "":
|
| 87 |
eleven_labs_api_key = st.sidebar.text_input(
|
|
|
|
| 118 |
# hindi_output_file="./Hindi_output_Audio.Mp3"
|
| 119 |
# save_uploaded_file_as_mp3(hindi_out"put_audio,hindi_output_file)
|
| 120 |
st.audio(hindi_output_audio)
|
| 121 |
+
|
| 122 |
|
| 123 |
st.session_state['past'].append(hindi_input_audio)
|
| 124 |
+
st.session_state['past_text'].append(english_input)
|
| 125 |
+
st.session_state['past_generated'].append(english_output)
|
| 126 |
st.session_state['generated'].append(hindi_output_audio)
|
| 127 |
|
| 128 |
if 'generated' in st.session_state and st.session_state['generated']:
|
|
|
|
| 137 |
|
| 138 |
if __name__ == '__main__':
|
| 139 |
ui()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|