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:
24
lib/utils/voice_processing.py
Normal file
24
lib/utils/voice_processing.py
Normal 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
|
||||
Reference in New Issue
Block a user