ugmSorcero commited on
Commit
42468fb
1 Parent(s): 6bb1fd5

Fixes linting

Browse files
core/pipelines.py CHANGED
@@ -11,9 +11,10 @@ from haystack.nodes.ranker import SentenceTransformersRanker
11
  from haystack.nodes.audio.document_to_speech import DocumentToSpeech
12
  import os
13
 
14
- data_path = 'data/'
15
  os.makedirs(data_path, exist_ok=True)
16
 
 
17
  def keyword_search(index="documents", split_word_length=100, audio_output=False):
18
  """
19
  **Keyword Search Pipeline**
@@ -49,13 +50,15 @@ def keyword_search(index="documents", split_word_length=100, audio_output=False)
49
  index_pipeline.add_node(
50
  document_store, name="DocumentStore", inputs=["TfidfRetriever"]
51
  )
52
-
53
  if audio_output:
54
  doc2speech = DocumentToSpeech(
55
  model_name_or_path="espnet/kan-bayashi_ljspeech_vits",
56
- generated_audio_dir=Path(data_path + 'audio'),
 
 
 
57
  )
58
- search_pipeline.add_node(doc2speech, name='DocumentToSpeech', inputs=['TfidfRetriever'])
59
 
60
  return search_pipeline, index_pipeline
61
 
 
11
  from haystack.nodes.audio.document_to_speech import DocumentToSpeech
12
  import os
13
 
14
+ data_path = "data/"
15
  os.makedirs(data_path, exist_ok=True)
16
 
17
+
18
  def keyword_search(index="documents", split_word_length=100, audio_output=False):
19
  """
20
  **Keyword Search Pipeline**
 
50
  index_pipeline.add_node(
51
  document_store, name="DocumentStore", inputs=["TfidfRetriever"]
52
  )
53
+
54
  if audio_output:
55
  doc2speech = DocumentToSpeech(
56
  model_name_or_path="espnet/kan-bayashi_ljspeech_vits",
57
+ generated_audio_dir=Path(data_path + "audio"),
58
+ )
59
+ search_pipeline.add_node(
60
+ doc2speech, name="DocumentToSpeech", inputs=["TfidfRetriever"]
61
  )
 
62
 
63
  return search_pipeline, index_pipeline
64
 
core/search_index.py CHANGED
@@ -38,12 +38,10 @@ def search(queries, pipeline):
38
  "fragment_id": res.id,
39
  }
40
  if not score_is_empty:
41
- match.update({'score': res.score})
42
- if hasattr(res, 'content_audio'):
43
- match.update({'content_audio': res.content_audio})
44
- query_results.append(
45
- match
46
- )
47
  if not score_is_empty:
48
  query_results = sorted(
49
  query_results, key=lambda x: x["score"], reverse=True
 
38
  "fragment_id": res.id,
39
  }
40
  if not score_is_empty:
41
+ match.update({"score": res.score})
42
+ if hasattr(res, "content_audio"):
43
+ match.update({"content_audio": res.content_audio})
44
+ query_results.append(match)
 
 
45
  if not score_is_empty:
46
  query_results = sorted(
47
  query_results, key=lambda x: x["score"], reverse=True
interface/components.py CHANGED
@@ -59,10 +59,10 @@ def component_show_search_result(container, results):
59
  st.markdown(f"### Match {idx+1}")
60
  st.markdown(f"**Text**: {document['text']}")
61
  st.markdown(f"**Document**: {document['id']}")
62
- if 'score' in document:
63
  st.markdown(f"**Score**: {document['score']:.3f}")
64
- if 'content_audio' in document:
65
- st.audio(str(document['content_audio']))
66
  st.markdown("---")
67
 
68
 
 
59
  st.markdown(f"### Match {idx+1}")
60
  st.markdown(f"**Text**: {document['text']}")
61
  st.markdown(f"**Document**: {document['id']}")
62
+ if "score" in document:
63
  st.markdown(f"**Score**: {document['score']:.3f}")
64
+ if "content_audio" in document:
65
+ st.audio(str(document["content_audio"]))
66
  st.markdown("---")
67
 
68