Logeswaransr commited on
Commit
b2c635f
1 Parent(s): 201a42a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -19
app.py CHANGED
@@ -33,24 +33,6 @@ for message in st.session_state.messages:
33
  st.markdown(message['content'])
34
 
35
  ## messages element format: {'role':'user', 'content':'<user prompt>'}
36
-
37
- if st.session_state.messages==[]:
38
- for gr in greetings:
39
- with st.chat_message("assistant"):
40
- st.markdown(gr)
41
-
42
- tts=gTTS(gr)
43
- tts.save(audio_stream)
44
- with open(audio_stream, 'rb') as file:
45
- audio_data=file.read()
46
- audio_base64 = base64.b64encode(audio_data).decode('utf-8')
47
- audio_tag = f'<audio autoplay="true" src="data:audio/mp3;base64,{audio_base64}">'
48
- st.markdown(audio_tag, unsafe_allow_html=True)
49
- time.sleep(10)
50
-
51
- st.session_state.messages.append({
52
- 'role':'assistant',
53
- 'content': gr})
54
 
55
  tts=gTTS("Here is your answer")
56
  tts.save(audio_stream)
@@ -79,4 +61,22 @@ if prompt:=st.chat_input("Enter your query"):
79
 
80
  st.session_state.messages.append({
81
  'role':'assistant',
82
- 'content': response})
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  st.markdown(message['content'])
34
 
35
  ## messages element format: {'role':'user', 'content':'<user prompt>'}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  tts=gTTS("Here is your answer")
38
  tts.save(audio_stream)
 
61
 
62
  st.session_state.messages.append({
63
  'role':'assistant',
64
+ 'content': response})
65
+
66
+ if st.session_state.messages==[]:
67
+ for gr in greetings:
68
+ with st.chat_message("assistant"):
69
+ st.markdown(gr)
70
+
71
+ tts=gTTS(gr)
72
+ tts.save(audio_stream)
73
+ with open(audio_stream, 'rb') as file:
74
+ audio_data=file.read()
75
+ audio_base64 = base64.b64encode(audio_data).decode('utf-8')
76
+ audio_tag = f'<audio autoplay="true" src="data:audio/mp3;base64,{audio_base64}">'
77
+ st.markdown(audio_tag, unsafe_allow_html=True)
78
+ time.sleep(10)
79
+
80
+ st.session_state.messages.append({
81
+ 'role':'assistant',
82
+ 'content': gr})