Update app.py
Browse files
app.py
CHANGED
|
@@ -72,7 +72,7 @@ def transcribe_audio(audio_file):
|
|
| 72 |
def search_with_chromadb(query):
|
| 73 |
results = collection.query(query_texts=[query], n_results=5)
|
| 74 |
results_from_pickle = [item['text'] for item in subtitle_data if isinstance(item, dict) and 'text' in item and query.lower() in item['text'].lower()]
|
| 75 |
-
return results['documents'][0] if results['documents'] else [], results_from_pickle[:5]
|
| 76 |
|
| 77 |
# UI Layout with Tabs
|
| 78 |
tab1, tab2 = st.tabs(["Upload & Generate Subtitles", "Search Subtitles"])
|
|
@@ -105,14 +105,13 @@ with tab1:
|
|
| 105 |
|
| 106 |
with tab2:
|
| 107 |
st.subheader("Search Subtitles")
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
for result in top_results_chroma + top_results_pickle:
|
| 117 |
st.info(result)
|
| 118 |
-
|
|
|
|
| 72 |
def search_with_chromadb(query):
|
| 73 |
results = collection.query(query_texts=[query], n_results=5)
|
| 74 |
results_from_pickle = [item['text'] for item in subtitle_data if isinstance(item, dict) and 'text' in item and query.lower() in item['text'].lower()]
|
| 75 |
+
return results['documents'][0][:5] if results['documents'] else [], results_from_pickle[:5]
|
| 76 |
|
| 77 |
# UI Layout with Tabs
|
| 78 |
tab1, tab2 = st.tabs(["Upload & Generate Subtitles", "Search Subtitles"])
|
|
|
|
| 105 |
|
| 106 |
with tab2:
|
| 107 |
st.subheader("Search Subtitles")
|
| 108 |
+
search_word = st.text_input("Search for a word using ChromaDB")
|
| 109 |
+
if search_word.strip():
|
| 110 |
+
top_results_chroma, top_results_pickle = search_with_chromadb(search_word)
|
| 111 |
+
|
| 112 |
+
st.write("### Top 5 Search Results from Transcribed Text & Pickle Data")
|
| 113 |
+
if not top_results_chroma and not top_results_pickle:
|
| 114 |
+
st.warning("No results found.")
|
| 115 |
+
else:
|
| 116 |
for result in top_results_chroma + top_results_pickle:
|
| 117 |
st.info(result)
|
|
|