Update app.py
Browse files
app.py
CHANGED
@@ -242,7 +242,7 @@ def load_mp3_viewer():
|
|
242 |
st.session_state['mp3_files'][filename] = mp3
|
243 |
|
244 |
async def save_chat_entry(username, message, voice, is_markdown=False):
|
245 |
-
if not message.strip():
|
246 |
return None, None
|
247 |
central = pytz.timezone('US/Central')
|
248 |
timestamp = datetime.now(central).strftime("%Y-%m-%d %H:%M:%S")
|
@@ -258,6 +258,7 @@ async def save_chat_entry(username, message, voice, is_markdown=False):
|
|
258 |
await broadcast_message(f"{username}|{message}", "chat")
|
259 |
st.session_state.last_chat_update = time.time()
|
260 |
st.session_state.chat_history.append(entry)
|
|
|
261 |
return md_file, audio_file
|
262 |
|
263 |
async def load_chat():
|
@@ -274,7 +275,7 @@ async def load_chat():
|
|
274 |
|
275 |
# Claude Search Function
|
276 |
async def perform_claude_search(query, username):
|
277 |
-
if not query.strip():
|
278 |
return None, None
|
279 |
client = anthropic.Anthropic(api_key=anthropic_key)
|
280 |
response = client.messages.create(
|
@@ -292,7 +293,7 @@ async def perform_claude_search(query, username):
|
|
292 |
|
293 |
# ArXiv Search Function
|
294 |
async def perform_arxiv_search(query, username):
|
295 |
-
if not query.strip():
|
296 |
return None, None
|
297 |
# Step 1: Claude Search
|
298 |
client = anthropic.Anthropic(api_key=anthropic_key)
|
@@ -572,10 +573,9 @@ def main():
|
|
572 |
# Speech Component at Top Level
|
573 |
mycomponent = components.declare_component("mycomponent", path="mycomponent")
|
574 |
val = mycomponent(my_input_value="")
|
575 |
-
if val and val != st.session_state.
|
576 |
val_stripped = val.strip().replace('\n', ' ')
|
577 |
if val_stripped:
|
578 |
-
st.session_state.old_val = val
|
579 |
voice = FUN_USERNAMES.get(st.session_state.username, "en-US-AriaNeural")
|
580 |
md_file, audio_file = asyncio.run(save_chat_entry(st.session_state.username, val_stripped, voice))
|
581 |
if audio_file:
|
|
|
242 |
st.session_state['mp3_files'][filename] = mp3
|
243 |
|
244 |
async def save_chat_entry(username, message, voice, is_markdown=False):
|
245 |
+
if not message.strip() or message == st.session_state.last_transcript:
|
246 |
return None, None
|
247 |
central = pytz.timezone('US/Central')
|
248 |
timestamp = datetime.now(central).strftime("%Y-%m-%d %H:%M:%S")
|
|
|
258 |
await broadcast_message(f"{username}|{message}", "chat")
|
259 |
st.session_state.last_chat_update = time.time()
|
260 |
st.session_state.chat_history.append(entry)
|
261 |
+
st.session_state.last_transcript = message # Update last processed transcript
|
262 |
return md_file, audio_file
|
263 |
|
264 |
async def load_chat():
|
|
|
275 |
|
276 |
# Claude Search Function
|
277 |
async def perform_claude_search(query, username):
|
278 |
+
if not query.strip() or query == st.session_state.last_transcript:
|
279 |
return None, None
|
280 |
client = anthropic.Anthropic(api_key=anthropic_key)
|
281 |
response = client.messages.create(
|
|
|
293 |
|
294 |
# ArXiv Search Function
|
295 |
async def perform_arxiv_search(query, username):
|
296 |
+
if not query.strip() or query == st.session_state.last_transcript:
|
297 |
return None, None
|
298 |
# Step 1: Claude Search
|
299 |
client = anthropic.Anthropic(api_key=anthropic_key)
|
|
|
573 |
# Speech Component at Top Level
|
574 |
mycomponent = components.declare_component("mycomponent", path="mycomponent")
|
575 |
val = mycomponent(my_input_value="")
|
576 |
+
if val and val != st.session_state.last_transcript:
|
577 |
val_stripped = val.strip().replace('\n', ' ')
|
578 |
if val_stripped:
|
|
|
579 |
voice = FUN_USERNAMES.get(st.session_state.username, "en-US-AriaNeural")
|
580 |
md_file, audio_file = asyncio.run(save_chat_entry(st.session_state.username, val_stripped, voice))
|
581 |
if audio_file:
|