summa add
Browse files- app.py +25 -3
- requirements.txt +1 -0
app.py
CHANGED
@@ -18,7 +18,7 @@ def speechToText(file):
|
|
18 |
|
19 |
my_text = query(file)
|
20 |
|
21 |
-
sentences = my_text["text"].split(".")
|
22 |
|
23 |
|
24 |
def translate(sentences):
|
@@ -30,11 +30,33 @@ def speechToText(file):
|
|
30 |
|
31 |
return text_translated
|
32 |
|
33 |
-
text_translate = translate(sentences)
|
34 |
|
35 |
#combined_text = ' '.join([item['translation_text'] for sublist in text_translated for item in sublist])
|
36 |
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
demo = gr.Interface(fn=speechToText, inputs="file", outputs="text")
|
40 |
demo.launch()
|
|
|
18 |
|
19 |
my_text = query(file)
|
20 |
|
21 |
+
#sentences = my_text["text"].split(".")
|
22 |
|
23 |
|
24 |
def translate(sentences):
|
|
|
30 |
|
31 |
return text_translated
|
32 |
|
33 |
+
#text_translate = translate(sentences)
|
34 |
|
35 |
#combined_text = ' '.join([item['translation_text'] for sublist in text_translated for item in sublist])
|
36 |
|
37 |
+
def summa(my_text):
|
38 |
+
pipe = pipeline("summarization", model="facebook/bart-large-cnn")
|
39 |
+
|
40 |
+
max = 1024
|
41 |
+
if len(my_text) > max:
|
42 |
+
combined_text_parts = [my_text[i:i + max] for i in range(0, len(my_text), max)]
|
43 |
+
else:
|
44 |
+
combined_text_parts = [my_text]
|
45 |
+
|
46 |
+
summaries = []
|
47 |
+
for part in combined_text_parts:
|
48 |
+
summary = pipe(part, max_length=180, min_length=140, do_sample=False)
|
49 |
+
summaries.append(summary[0]['summary_text'])
|
50 |
+
|
51 |
+
|
52 |
+
full_summary = ' '.join(summaries)
|
53 |
+
|
54 |
+
|
55 |
+
return full_summary
|
56 |
+
|
57 |
+
full_summaries = summa(my_text)
|
58 |
+
|
59 |
+
return full_summaries
|
60 |
|
61 |
demo = gr.Interface(fn=speechToText, inputs="file", outputs="text")
|
62 |
demo.launch()
|
requirements.txt
CHANGED
@@ -4,4 +4,5 @@ tensorflow>=2.0
|
|
4 |
tf-keras
|
5 |
sentencepiece
|
6 |
python_multipart
|
|
|
7 |
requests_toolbelt
|
|
|
4 |
tf-keras
|
5 |
sentencepiece
|
6 |
python_multipart
|
7 |
+
multipart
|
8 |
requests_toolbelt
|