ziyadsuper2017 commited on
Commit
9b198d7
·
1 Parent(s): f75b36f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -24
app.py CHANGED
@@ -2,7 +2,6 @@ import streamlit as st
2
  import google.generativeai as genai
3
  import sqlite3
4
  from streamlit import file_uploader
5
- from gtts import gTTS # Import the gTTS library
6
 
7
  # Database setup
8
  conn = sqlite3.connect('chat_history.db')
@@ -105,26 +104,3 @@ if uploaded_file and image_question:
105
 
106
  response = model.generate_content(prompt_parts)
107
  st.markdown(f"**Model's answer:** {response.text}")
108
-
109
- # Add a button to play the audio of the model's answer
110
- if st.button("Play Model's Audio"):
111
- # Call the text_to_speech function with the response text
112
- audio_file = text_to_speech(response.text)
113
- # Display the audio file using st.audio
114
- st.audio(audio_file, format="audio/mp3")
115
-
116
- # Add a button to play the audio of the user's question
117
- if st.button("Play User's Audio"):
118
- # Call the text_to_speech function with the image question
119
- audio_file = text_to_speech(image_question)
120
- # Display the audio file using st.audio
121
- st.audio(audio_file, format="audio/mp3")
122
-
123
- # Define a function that takes a text input and returns an audio file using gTTS
124
- def text_to_speech(text):
125
- # Create a gTTS object with the text and the language
126
- tts = gTTS(text=text, lang="en")
127
- # Save the audio file to a temporary file
128
- tts.save("temp.mp3")
129
- # Return the audio file as bytes
130
- return open("temp.mp3", "rb").read()
 
2
  import google.generativeai as genai
3
  import sqlite3
4
  from streamlit import file_uploader
 
5
 
6
  # Database setup
7
  conn = sqlite3.connect('chat_history.db')
 
104
 
105
  response = model.generate_content(prompt_parts)
106
  st.markdown(f"**Model's answer:** {response.text}")