jaelin215 commited on
Commit
1e1249d
1 Parent(s): 7066de6

Moved text to speech

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -314,10 +314,8 @@ if user_message:
314
 
315
  with st.chat_message("ai"):
316
  st.markdown(llm_reponse_with_quesiton)
317
- # Convert the response to speech
318
- speech_fp = text_to_speech(llm_reponse_with_quesiton)
319
- # Play the speech
320
- st.audio(speech_fp, format="audio/mp3")
321
  # st.write(f"{llm_response}")
322
  # if show_question:
323
  # st.write(f"{question}")
@@ -333,6 +331,12 @@ if user_message:
333
  st.session_state.mood_trend_symbol = mood_trend_symbol
334
  st.session_state.show_question = show_question
335
 
 
 
 
 
 
 
336
  # Show/hide "Behind the Scene" section
337
  # section_visible = st.sidebar.button('Show/Hide Behind the Scene')
338
 
@@ -342,6 +346,7 @@ if user_message:
342
  st.write(
343
  f"- Detected User Tone: {st.session_state.user_sentiment} ({st.session_state.mood_trend.capitalize()}{st.session_state.mood_trend_symbol})"
344
  )
 
345
  if st.session_state.show_question:
346
  st.write(
347
  f"- Possible Mental Condition: {st.session_state.predicted_mental_category.capitalize()}"
 
314
 
315
  with st.chat_message("ai"):
316
  st.markdown(llm_reponse_with_quesiton)
317
+
318
+
 
 
319
  # st.write(f"{llm_response}")
320
  # if show_question:
321
  # st.write(f"{question}")
 
331
  st.session_state.mood_trend_symbol = mood_trend_symbol
332
  st.session_state.show_question = show_question
333
 
334
+ if input_mode == "Speech":
335
+ # Convert the response to speech
336
+ speech_fp = text_to_speech(llm_reponse_with_quesiton)
337
+ # Play the speech
338
+ st.audio(speech_fp, format="audio/mp3")
339
+
340
  # Show/hide "Behind the Scene" section
341
  # section_visible = st.sidebar.button('Show/Hide Behind the Scene')
342
 
 
346
  st.write(
347
  f"- Detected User Tone: {st.session_state.user_sentiment} ({st.session_state.mood_trend.capitalize()}{st.session_state.mood_trend_symbol})"
348
  )
349
+
350
  if st.session_state.show_question:
351
  st.write(
352
  f"- Possible Mental Condition: {st.session_state.predicted_mental_category.capitalize()}"