Spaces:
Build error
Build error
avacaondata
commited on
Commit
•
05aebdd
1
Parent(s):
5ae3b89
añadidas mejoras visuales
Browse files- app.py +6 -3
- article_app.py +12 -0
- general_utils.py +6 -7
app.py
CHANGED
@@ -170,8 +170,8 @@ def search_and_answer(
|
|
170 |
final_answer = answers[0]["generated_text"]
|
171 |
if do_tts:
|
172 |
audio_answer = tts_es(remove_chars_to_tts(final_answer))
|
173 |
-
final_answer = parse_final_answer(final_answer, contexts)
|
174 |
-
return final_answer, audio_answer if do_tts else "audio_troll.flac"
|
175 |
|
176 |
|
177 |
if __name__ == "__main__":
|
@@ -231,7 +231,10 @@ if __name__ == "__main__":
|
|
231 |
],
|
232 |
outputs=[
|
233 |
gr.outputs.HTML(
|
234 |
-
label="Answer
|
|
|
|
|
|
|
235 |
),
|
236 |
gr.outputs.Audio(label="Answer in audio"),
|
237 |
],
|
|
|
170 |
final_answer = answers[0]["generated_text"]
|
171 |
if do_tts:
|
172 |
audio_answer = tts_es(remove_chars_to_tts(final_answer))
|
173 |
+
final_answer, documents = parse_final_answer(final_answer, contexts)
|
174 |
+
return final_answer, documents, audio_answer if do_tts else "audio_troll.flac"
|
175 |
|
176 |
|
177 |
if __name__ == "__main__":
|
|
|
231 |
],
|
232 |
outputs=[
|
233 |
gr.outputs.HTML(
|
234 |
+
label="Generated Answer."
|
235 |
+
),
|
236 |
+
gr.outputs.HTML(
|
237 |
+
label="Documents used."
|
238 |
),
|
239 |
gr.outputs.Audio(label="Answer in audio"),
|
240 |
],
|
article_app.py
CHANGED
@@ -61,6 +61,18 @@ examples = [
|
|
61 |
"wav2vec2-iic",
|
62 |
False,
|
63 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
[
|
65 |
"¿Qué es la mesoterapia?",
|
66 |
"vacio.flac",
|
|
|
61 |
"wav2vec2-iic",
|
62 |
False,
|
63 |
],
|
64 |
+
[
|
65 |
+
"¿Cómo se genera la apendicitis?",
|
66 |
+
"vacio.flac",
|
67 |
+
"vacio.flac",
|
68 |
+
50,
|
69 |
+
8,
|
70 |
+
3,
|
71 |
+
1.0,
|
72 |
+
250,
|
73 |
+
"wav2vec2-iic",
|
74 |
+
False,
|
75 |
+
],
|
76 |
[
|
77 |
"¿Qué es la mesoterapia?",
|
78 |
"vacio.flac",
|
general_utils.py
CHANGED
@@ -121,18 +121,17 @@ def transcript(input_file, audio_array, processor, model):
|
|
121 |
whole_text = add_question_symbols(whole_text)
|
122 |
return whole_text
|
123 |
|
124 |
-
|
125 |
def parse_final_answer(answer_text: str, contexts: List):
|
126 |
"""Parse the final answer into correct format"""
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
+ "\n".join(
|
131 |
[
|
132 |
-
("""<p style="text-align: justify;">""" + context)[:
|
133 |
+ "[...]</p>"
|
134 |
for context in contexts[:5]
|
135 |
]
|
136 |
)
|
137 |
)
|
138 |
-
return
|
|
|
121 |
whole_text = add_question_symbols(whole_text)
|
122 |
return whole_text
|
123 |
|
124 |
+
# <em>Final Answer:</em>
|
125 |
def parse_final_answer(answer_text: str, contexts: List):
|
126 |
"""Parse the final answer into correct format"""
|
127 |
+
answer = f"<p><b>{answer_text}</b></p> \n\n\n"
|
128 |
+
docs = (
|
129 |
+
"\n".join(
|
|
|
130 |
[
|
131 |
+
("""<p style="text-align: justify;">""" + context)[:250]
|
132 |
+ "[...]</p>"
|
133 |
for context in contexts[:5]
|
134 |
]
|
135 |
)
|
136 |
)
|
137 |
+
return answer, docs
|