Spaces:
Runtime error
Runtime error
Update app.py
#9
by
Alpha108
- opened
app.py
CHANGED
|
@@ -19,6 +19,46 @@ from utils.export import ResultExporter
|
|
| 19 |
# Import LangChain components
|
| 20 |
from langchain_groq import ChatGroq
|
| 21 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
class GEOSEOApp:
|
| 24 |
"""Main application class that orchestrates all components"""
|
|
|
|
| 19 |
# Import LangChain components
|
| 20 |
from langchain_groq import ChatGroq
|
| 21 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
| 22 |
+
import streamlit as st
|
| 23 |
+
from utils.lang_utils import detect_language, translate_text
|
| 24 |
+
from utils.audio_utils import transcribe_audio
|
| 25 |
+
|
| 26 |
+
st.title("Multilingual and Voice-to-Text Support")
|
| 27 |
+
|
| 28 |
+
# Upload options
|
| 29 |
+
uploaded_audio = st.file_uploader("Upload Audio (MP3)", type=["mp3"])
|
| 30 |
+
user_text = st.text_area("Or Paste Your Text")
|
| 31 |
+
|
| 32 |
+
input_text = ""
|
| 33 |
+
|
| 34 |
+
# If audio is uploaded
|
| 35 |
+
if uploaded_audio:
|
| 36 |
+
with st.spinner("Transcribing audio..."):
|
| 37 |
+
input_text = transcribe_audio(uploaded_audio)
|
| 38 |
+
st.success("Audio transcribed successfully!")
|
| 39 |
+
st.write("Transcribed Text:")
|
| 40 |
+
st.write(input_text)
|
| 41 |
+
|
| 42 |
+
# If text is given
|
| 43 |
+
elif user_text:
|
| 44 |
+
input_text = user_text
|
| 45 |
+
|
| 46 |
+
# If input is received
|
| 47 |
+
if input_text:
|
| 48 |
+
lang = detect_language(input_text)
|
| 49 |
+
st.write(f"Detected Language: `{lang}`")
|
| 50 |
+
|
| 51 |
+
if lang != "en":
|
| 52 |
+
translated = translate_text(input_text)
|
| 53 |
+
st.write("🔁 Translated to English:")
|
| 54 |
+
st.write(translated)
|
| 55 |
+
final_text = translated
|
| 56 |
+
else:
|
| 57 |
+
final_text = input_text
|
| 58 |
+
|
| 59 |
+
# Now pass final_text to your main logic (scoring, summarizing, etc.)
|
| 60 |
+
st.write("✅ You can now proceed with the optimized or summarized output.")
|
| 61 |
+
|
| 62 |
|
| 63 |
class GEOSEOApp:
|
| 64 |
"""Main application class that orchestrates all components"""
|