vishwask commited on
Commit
7100c36
1 Parent(s): f639c46

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -23,6 +23,7 @@ import fitz
23
  from PIL import Image
24
  from langchain.vectorstores import FAISS
25
  import transformers
 
26
 
27
  user_session_id = uuid.uuid4()
28
 
@@ -178,6 +179,8 @@ if prompt := st.chat_input("How can I help you today?"):
178
  with open('/home/user/app/audio/audio.mp3','wb') as sound_file:
179
  tts = gTTS(result['result'], lang='en', tld='co.in')
180
  tts.write_to_fp(sound_file)
 
 
181
 
182
  for item in output:
183
  full_response += item
@@ -200,8 +203,8 @@ if prompt := st.chat_input("How can I help you today?"):
200
 
201
  if choice == 'TTS':
202
  generate_audio()
203
- st.session_state['audio'] = '/home/user/app/audio/audio.mp3'
204
- st.audio(st.session_state['audio'], format='audio/mp3')
205
 
206
  st.session_state.messages.append({"role": "assistant", "content": full_response})
207
 
 
23
  from PIL import Image
24
  from langchain.vectorstores import FAISS
25
  import transformers
26
+ from pydub import AudioSegment
27
 
28
  user_session_id = uuid.uuid4()
29
 
 
179
  with open('/home/user/app/audio/audio.mp3','wb') as sound_file:
180
  tts = gTTS(result['result'], lang='en', tld='co.in')
181
  tts.write_to_fp(sound_file)
182
+ sound = AudioSegment.from_mp3("/home/user/app/audio/audio.mp3")
183
+ sound.export("/home/user/app/audio/audio.wav", format="wav")
184
 
185
  for item in output:
186
  full_response += item
 
203
 
204
  if choice == 'TTS':
205
  generate_audio()
206
+ st.session_state['audio'] = '/home/user/app/audio/audio.wav'
207
+ st.audio(st.session_state['audio'])
208
 
209
  st.session_state.messages.append({"role": "assistant", "content": full_response})
210