refactor: modularize code by creating separate utility modules for environment, configuration, UI setup, API key management, content generation, SEO tools, file processing, and voice processing

This commit is contained in:
ajaysi (aider)
2024-09-14 17:49:34 +05:30
parent 6fe6c52d99
commit 27072adbe5
10 changed files with 302 additions and 69 deletions

View File

@@ -0,0 +1,24 @@
import streamlit as st
from streamlit_mic_recorder import speech_to_text
@st.cache_data
def record_voice(language="en"):
# https://github.com/B4PT0R/streamlit-mic-recorder?tab=readme-ov-file#example
state = st.session_state
if "text_received" not in state:
state.text_received = []
text = speech_to_text(
start_prompt="🎙Press & Speak🔊",
stop_prompt="🔇Stop Recording🚨",
language=language,
use_container_width=True,
just_once=False,
)
if text:
state.text_received.append(text)
result = ""
for text in state.text_received:
result += text
state.text_received = []
return result if result else None