Spaces:
Runtime error
Runtime error
ziyadsuper2017
commited on
Commit
•
e742fb1
1
Parent(s):
dfb90bd
Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,7 @@ from gtts import gTTS
|
|
7 |
import google.generativeai as genai
|
8 |
|
9 |
# Set your API key
|
10 |
-
api_key = "
|
11 |
genai.configure(api_key=api_key)
|
12 |
|
13 |
# Configure the generative AI model
|
@@ -102,7 +102,7 @@ def send_message(tts=False):
|
|
102 |
response_text = response.text if hasattr(response, "text") else "No response text found."
|
103 |
if response_text:
|
104 |
st.session_state['chat_history'].append({"role": "model", "parts": [{"text": response_text}]})
|
105 |
-
|
106 |
# If TTS is enabled, convert the response text to speech
|
107 |
if tts:
|
108 |
tts = gTTS(text=response_text, lang='en')
|
@@ -160,17 +160,19 @@ download_button = st.download_button(
|
|
160 |
st.session_state.uploaded_files = uploaded_files
|
161 |
|
162 |
# JavaScript to capture the Ctrl+Enter event and trigger a button click
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
|
|
170 |
e.preventDefault();
|
171 |
}
|
172 |
});
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
|
|
|
7 |
import google.generativeai as genai
|
8 |
|
9 |
# Set your API key
|
10 |
+
api_key = "AIzaSyC70u1sN87IkoxOoIj4XCAPw97ae2LZwNM" # Replace with your actual API key
|
11 |
genai.configure(api_key=api_key)
|
12 |
|
13 |
# Configure the generative AI model
|
|
|
102 |
response_text = response.text if hasattr(response, "text") else "No response text found."
|
103 |
if response_text:
|
104 |
st.session_state['chat_history'].append({"role": "model", "parts": [{"text": response_text}]})
|
105 |
+
|
106 |
# If TTS is enabled, convert the response text to speech
|
107 |
if tts:
|
108 |
tts = gTTS(text=response_text, lang='en')
|
|
|
160 |
st.session_state.uploaded_files = uploaded_files
|
161 |
|
162 |
# JavaScript to capture the Ctrl+Enter event and trigger a button click
|
163 |
+
st.markdown(
|
164 |
+
"""
|
165 |
+
<script>
|
166 |
+
// Use jQuery to capture the Ctrl+Enter event and click the 'Send' button
|
167 |
+
document.addEventListener('DOMContentLoaded', (event) => {
|
168 |
+
document.querySelector('.stTextArea textarea').addEventListener('keydown', function(e) {
|
169 |
+
if (e.key === 'Enter' && e.ctrlKey) {
|
170 |
+
document.querySelector('.stButton > button').click();
|
171 |
e.preventDefault();
|
172 |
}
|
173 |
});
|
174 |
+
});
|
175 |
+
</script>
|
176 |
+
""",
|
177 |
+
unsafe_allow_html=True
|
178 |
+
)
|