Phaneendrabayi commited on
Commit
e8ed4f6
·
verified ·
1 Parent(s): f5fb371

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -10
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
- if transcribed_text is None:
109
- st.warning("Please upload and transcribe an audio file in the 'Upload & Generate Subtitles' tab before searching.")
110
- else:
111
- search_word = st.text_input("Search for a word using ChromaDB")
112
- if search_word.strip():
113
- top_results_chroma, top_results_pickle = search_with_chromadb(search_word)
114
-
115
- st.write("### Top 5 Search Results from Transcribed Text & Pickle Data")
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)