Spaces:
Sleeping
Sleeping
summarize updated
Browse files
app.py
CHANGED
@@ -12,7 +12,7 @@ def process_inputs(audio, option, question=None):
|
|
12 |
return generated_text
|
13 |
elif option == "Summarize":
|
14 |
generated_text = generate_text_from_audio(audio)
|
15 |
-
return generate_summary_from_text(generated_text, minLength=
|
16 |
elif option == "text-classification":
|
17 |
generated_text = generate_text_from_audio(audio)
|
18 |
return "", text_classification(generated_text)
|
@@ -49,9 +49,9 @@ def generate_text_from_audio(audio):
|
|
49 |
audio_text_result = pipe(audio_data, generate_kwargs={"task": "translate", "forced_decoder_ids": [[1, None], [2, 50359]]})
|
50 |
return audio_text_result["text"]
|
51 |
|
52 |
-
def generate_summary_from_text(text):
|
53 |
summarizer = pipeline("summarization", model="Falconsai/text_summarization")
|
54 |
-
return summarizer(text, max_length=
|
55 |
|
56 |
def text_classification(text):
|
57 |
classifier = pipeline(task="text-classification", model="SamLowe/roberta-base-go_emotions", top_k=None)
|
|
|
12 |
return generated_text
|
13 |
elif option == "Summarize":
|
14 |
generated_text = generate_text_from_audio(audio)
|
15 |
+
return generate_summary_from_text(generated_text, minLength=20, maxLength=150), None
|
16 |
elif option == "text-classification":
|
17 |
generated_text = generate_text_from_audio(audio)
|
18 |
return "", text_classification(generated_text)
|
|
|
49 |
audio_text_result = pipe(audio_data, generate_kwargs={"task": "translate", "forced_decoder_ids": [[1, None], [2, 50359]]})
|
50 |
return audio_text_result["text"]
|
51 |
|
52 |
+
def generate_summary_from_text(text, minLength, maxLength):
|
53 |
summarizer = pipeline("summarization", model="Falconsai/text_summarization")
|
54 |
+
return summarizer(text, max_length=maxLength, min_length=minLength, do_sample=False)[0]['summary_text']
|
55 |
|
56 |
def text_classification(text):
|
57 |
classifier = pipeline(task="text-classification", model="SamLowe/roberta-base-go_emotions", top_k=None)
|