Update app.py
Browse files
app.py
CHANGED
@@ -395,20 +395,9 @@ def create_streamlit_interface():
|
|
395 |
chat_votes = await load_votes(QUOTE_VOTES_FILE)
|
396 |
for i, line in enumerate(chat_lines):
|
397 |
if line.strip() and ': ' in line:
|
398 |
-
col1, col2, col3 = st.columns([
|
399 |
with col1:
|
400 |
st.markdown(line)
|
401 |
-
username = line.split(': ')[1].split(' ')[0]
|
402 |
-
audio_file = None
|
403 |
-
cache_key = f"{line}_{FUN_USERNAMES.get(username, 'en-US-AriaNeural')}"
|
404 |
-
if cache_key in st.session_state.audio_cache:
|
405 |
-
audio_file = st.session_state.audio_cache[cache_key]
|
406 |
-
else:
|
407 |
-
cleaned_text = clean_text_for_tts(line.split(': ', 1)[1])
|
408 |
-
audio_file = await async_edge_tts_generate(cleaned_text, FUN_USERNAMES.get(username, "en-US-AriaNeural"))
|
409 |
-
st.session_state.audio_cache[cache_key] = audio_file
|
410 |
-
if audio_file:
|
411 |
-
play_and_download_audio(audio_file)
|
412 |
with col2:
|
413 |
vote_count = chat_votes.get(line.split('. ')[1] if '. ' in line else line, 0)
|
414 |
if st.button(f"π {vote_count}", key=f"chat_vote_{i}"):
|
@@ -425,6 +414,18 @@ def create_streamlit_interface():
|
|
425 |
if st.button("π’ Quote", key=f"quote_{i}"):
|
426 |
st.session_state.quote_line = line
|
427 |
st.rerun()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
428 |
|
429 |
if 'quote_line' in st.session_state:
|
430 |
st.markdown(f"### Quoting: {st.session_state.quote_line}")
|
|
|
395 |
chat_votes = await load_votes(QUOTE_VOTES_FILE)
|
396 |
for i, line in enumerate(chat_lines):
|
397 |
if line.strip() and ': ' in line:
|
398 |
+
col1, col2, col3, col4 = st.columns([3, 1, 1, 2])
|
399 |
with col1:
|
400 |
st.markdown(line)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
401 |
with col2:
|
402 |
vote_count = chat_votes.get(line.split('. ')[1] if '. ' in line else line, 0)
|
403 |
if st.button(f"π {vote_count}", key=f"chat_vote_{i}"):
|
|
|
414 |
if st.button("π’ Quote", key=f"quote_{i}"):
|
415 |
st.session_state.quote_line = line
|
416 |
st.rerun()
|
417 |
+
with col4:
|
418 |
+
username = line.split(': ')[1].split(' ')[0]
|
419 |
+
audio_file = None
|
420 |
+
cache_key = f"{line}_{FUN_USERNAMES.get(username, 'en-US-AriaNeural')}"
|
421 |
+
if cache_key in st.session_state.audio_cache:
|
422 |
+
audio_file = st.session_state.audio_cache[cache_key]
|
423 |
+
else:
|
424 |
+
cleaned_text = clean_text_for_tts(line.split(': ', 1)[1])
|
425 |
+
audio_file = await async_edge_tts_generate(cleaned_text, FUN_USERNAMES.get(username, "en-US-AriaNeural"))
|
426 |
+
st.session_state.audio_cache[cache_key] = audio_file
|
427 |
+
if audio_file:
|
428 |
+
play_and_download_audio(audio_file)
|
429 |
|
430 |
if 'quote_line' in st.session_state:
|
431 |
st.markdown(f"### Quoting: {st.session_state.quote_line}")
|