Spaces:
No application file
No application file
Update app.py
Browse files
app.py
CHANGED
|
@@ -295,8 +295,16 @@ Content:
|
|
| 295 |
|
| 296 |
"quiz_mcqs": f"""{lang_instruction}
|
| 297 |
|
| 298 |
-
Generate 10 multiple-choice questions from this text. Each question should have 4 options.
|
| 299 |
-
Mark the correct answer with an asterisk (*).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 300 |
Write questions directly without any introductory text.
|
| 301 |
|
| 302 |
Text:
|
|
@@ -305,7 +313,11 @@ Text:
|
|
| 305 |
"quiz_truefalse": f"""{lang_instruction}
|
| 306 |
|
| 307 |
Generate 10 True/False questions from this text.
|
| 308 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 309 |
Write questions directly without any introductory text.
|
| 310 |
|
| 311 |
Text:
|
|
@@ -314,7 +326,11 @@ Text:
|
|
| 314 |
"quiz_fillblanks": f"""{lang_instruction}
|
| 315 |
|
| 316 |
Generate 10 fill-in-the-blank questions from this text.
|
| 317 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 318 |
Write questions directly without any introductory text.
|
| 319 |
|
| 320 |
Text:
|
|
@@ -323,7 +339,22 @@ Text:
|
|
| 323 |
"quiz_matching": f"""{lang_instruction}
|
| 324 |
|
| 325 |
Create a matching exercise with 10 items in Column A and their matches in Column B.
|
| 326 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 327 |
Present directly without any introductory text.
|
| 328 |
|
| 329 |
Text:
|
|
@@ -332,6 +363,10 @@ Text:
|
|
| 332 |
"quiz_short": f"""{lang_instruction}
|
| 333 |
|
| 334 |
Generate 10 short-answer questions from this text with brief model answers.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 335 |
Write questions directly without any introductory text.
|
| 336 |
|
| 337 |
Text:
|
|
@@ -340,9 +375,32 @@ Text:
|
|
| 340 |
"quiz_essay": f"""{lang_instruction}
|
| 341 |
|
| 342 |
Generate 5 essay-type questions from this text with key points to cover.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 343 |
Write questions directly without any introductory text.
|
| 344 |
|
| 345 |
Text:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 346 |
{text}""",
|
| 347 |
|
| 348 |
"mindmap": f"""{lang_instruction}
|
|
@@ -512,7 +570,7 @@ def create_docx(content, title, institution_name="", writer_name="", language="E
|
|
| 512 |
|
| 513 |
def create_pptx(content, title, language="English"):
|
| 514 |
"""
|
| 515 |
-
Create PowerPoint presentation with professional design
|
| 516 |
"""
|
| 517 |
try:
|
| 518 |
prs = Presentation()
|
|
@@ -521,25 +579,37 @@ def create_pptx(content, title, language="English"):
|
|
| 521 |
|
| 522 |
is_urdu = language == "Urdu" or is_urdu_text(content)
|
| 523 |
|
|
|
|
| 524 |
title_slide_layout = prs.slide_layouts[0]
|
| 525 |
slide = prs.slides.add_slide(title_slide_layout)
|
| 526 |
|
|
|
|
| 527 |
slide.shapes.title.text = title
|
| 528 |
title_frame = slide.shapes.title.text_frame
|
| 529 |
title_frame.paragraphs[0].font.size = PptxPt(44)
|
| 530 |
title_frame.paragraphs[0].font.bold = True
|
| 531 |
-
title_frame.paragraphs[0].font.color.rgb = PptxRGBColor(
|
| 532 |
|
|
|
|
| 533 |
subtitle = slide.placeholders[1]
|
| 534 |
subtitle_text = f"Generated on {datetime.now().strftime('%B %d, %Y')}"
|
| 535 |
if is_urdu:
|
| 536 |
subtitle_text = f"تیار کردہ: {datetime.now().strftime('%d/%m/%Y')}"
|
| 537 |
subtitle.text = subtitle_text
|
|
|
|
|
|
|
|
|
|
| 538 |
|
|
|
|
| 539 |
objectives_layout = prs.slide_layouts[1]
|
| 540 |
obj_slide = prs.slides.add_slide(objectives_layout)
|
| 541 |
obj_slide.shapes.title.text = "Session Objectives" if not is_urdu else "سیشن کے مقاصد"
|
| 542 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 543 |
obj_frame = obj_slide.shapes.placeholders[1].text_frame
|
| 544 |
obj_frame.clear()
|
| 545 |
|
|
@@ -556,14 +626,22 @@ def create_pptx(content, title, language="English"):
|
|
| 556 |
"تنقیدی سوچ کی مہارت پیدا کرنا"
|
| 557 |
]
|
| 558 |
|
| 559 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 560 |
p = obj_frame.add_paragraph()
|
| 561 |
p.text = obj_text
|
| 562 |
p.font.size = PptxPt(20)
|
|
|
|
| 563 |
p.level = 0
|
| 564 |
if is_urdu:
|
| 565 |
p.alignment = PP_ALIGN.RIGHT
|
| 566 |
|
|
|
|
| 567 |
slides_content = []
|
| 568 |
current_slide = {"title": "", "points": []}
|
| 569 |
|
|
@@ -585,38 +663,55 @@ def create_pptx(content, title, language="English"):
|
|
| 585 |
if current_slide["title"]:
|
| 586 |
slides_content.append(current_slide)
|
| 587 |
|
| 588 |
-
|
| 589 |
-
|
| 590 |
-
PptxRGBColor(0,
|
| 591 |
-
PptxRGBColor(
|
| 592 |
-
PptxRGBColor(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 593 |
]
|
| 594 |
|
| 595 |
for idx, slide_data in enumerate(slides_content):
|
| 596 |
bullet_slide_layout = prs.slide_layouts[1]
|
| 597 |
slide = prs.slides.add_slide(bullet_slide_layout)
|
| 598 |
|
|
|
|
| 599 |
slide.shapes.title.text = slide_data["title"]
|
| 600 |
title_frame = slide.shapes.title.text_frame
|
| 601 |
title_frame.paragraphs[0].font.size = PptxPt(32)
|
| 602 |
title_frame.paragraphs[0].font.bold = True
|
| 603 |
-
title_frame.paragraphs[0].font.color.rgb =
|
| 604 |
|
| 605 |
text_frame = slide.shapes.placeholders[1].text_frame
|
| 606 |
text_frame.clear()
|
| 607 |
|
| 608 |
-
for point in slide_data["points"][:6]:
|
| 609 |
p = text_frame.add_paragraph()
|
| 610 |
p.text = point
|
| 611 |
p.level = 0
|
| 612 |
p.font.size = PptxPt(18)
|
|
|
|
| 613 |
if is_urdu or is_urdu_text(point):
|
| 614 |
p.alignment = PP_ALIGN.RIGHT
|
| 615 |
|
|
|
|
| 616 |
conclusion_layout = prs.slide_layouts[1]
|
| 617 |
conclusion_slide = prs.slides.add_slide(conclusion_layout)
|
| 618 |
conclusion_slide.shapes.title.text = "Conclusion" if not is_urdu else "نتیجہ"
|
| 619 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 620 |
conc_frame = conclusion_slide.shapes.placeholders[1].text_frame
|
| 621 |
conc_frame.clear()
|
| 622 |
|
|
@@ -633,11 +728,18 @@ def create_pptx(content, title, language="English"):
|
|
| 633 |
"مزید معلومات کے لیے رابطہ کریں"
|
| 634 |
]
|
| 635 |
|
| 636 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 637 |
p = conc_frame.add_paragraph()
|
| 638 |
p.text = text
|
| 639 |
p.font.size = PptxPt(24)
|
| 640 |
p.font.bold = True
|
|
|
|
| 641 |
if is_urdu:
|
| 642 |
p.alignment = PP_ALIGN.RIGHT
|
| 643 |
|
|
@@ -660,10 +762,14 @@ def ui_transcribe(upload_audio, record_audio, lang_choice):
|
|
| 660 |
return transcribe_audio_chunked(audio)
|
| 661 |
|
| 662 |
def ui_generate_docx(transcription_box, content_dropdown, lang_choice, institution_input, writer_input):
|
| 663 |
-
"""Handle DOCX generation from UI"""
|
| 664 |
if not transcription_box:
|
| 665 |
return "❌ No transcribed text available", None, "⚠️ Please transcribe audio first"
|
| 666 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 667 |
try:
|
| 668 |
content = generate_content(transcription_box, content_dropdown, lang_choice)
|
| 669 |
|
|
@@ -686,7 +792,8 @@ def ui_generate_docx(transcription_box, content_dropdown, lang_choice, instituti
|
|
| 686 |
"quiz_essay": "Essay Questions" if lang_choice == "English" else "مضمون کے سوالات",
|
| 687 |
"mindmap": "Mind Map" if lang_choice == "English" else "ذہنی نقشہ",
|
| 688 |
"meeting_minutes": "Minutes of Meeting" if lang_choice == "English" else "اجلاس کی کارروائی",
|
| 689 |
-
"translation": f"Translation to {lang_choice}"
|
|
|
|
| 690 |
}
|
| 691 |
|
| 692 |
title = title_map.get(content_dropdown, "Generated Content")
|
|
@@ -774,6 +881,7 @@ students to convert lectures into study notes, and researchers to document their
|
|
| 774 |
("themes_subthemes", "Themes & Subthemes"),
|
| 775 |
("summary", "Summary"),
|
| 776 |
("study_notes", "Study Notes"),
|
|
|
|
| 777 |
("tutorial_beginners", "Tutorial for Beginners"),
|
| 778 |
("infographic_content", "Infographic Content"),
|
| 779 |
("social_facebook", "Facebook Post"),
|
|
@@ -808,12 +916,12 @@ students to convert lectures into study notes, and researchers to document their
|
|
| 808 |
qa1 = gr.Button("Summary")
|
| 809 |
qa2 = gr.Button("Study Notes")
|
| 810 |
qa3 = gr.Button("Themes")
|
| 811 |
-
qa4 = gr.Button("
|
| 812 |
with gr.Row():
|
| 813 |
-
qa5 = gr.Button("
|
| 814 |
qa6 = gr.Button("Facebook")
|
| 815 |
qa7 = gr.Button("LinkedIn")
|
| 816 |
-
qa8 = gr.Button("
|
| 817 |
|
| 818 |
quick_output = gr.Textbox(label="Quick Output", lines=10)
|
| 819 |
|
|
@@ -859,12 +967,12 @@ students to convert lectures into study notes, and researchers to document their
|
|
| 859 |
outputs=[quick_output]
|
| 860 |
)
|
| 861 |
qa4.click(
|
| 862 |
-
fn=lambda t, l, i, w: ui_generate_quick("
|
| 863 |
inputs=[transcription_box, lang_choice, institution_input, writer_input],
|
| 864 |
outputs=[quick_output]
|
| 865 |
)
|
| 866 |
qa5.click(
|
| 867 |
-
fn=lambda t, l, i, w: ui_generate_quick("
|
| 868 |
inputs=[transcription_box, lang_choice, institution_input, writer_input],
|
| 869 |
outputs=[quick_output]
|
| 870 |
)
|
|
@@ -879,7 +987,7 @@ students to convert lectures into study notes, and researchers to document their
|
|
| 879 |
outputs=[quick_output]
|
| 880 |
)
|
| 881 |
qa8.click(
|
| 882 |
-
fn=lambda t, l, i, w: ui_generate_quick("
|
| 883 |
inputs=[transcription_box, lang_choice, institution_input, writer_input],
|
| 884 |
outputs=[quick_output]
|
| 885 |
)
|
|
|
|
| 295 |
|
| 296 |
"quiz_mcqs": f"""{lang_instruction}
|
| 297 |
|
| 298 |
+
Generate 10 multiple-choice questions from this text. Each question should have 4 options (A, B, C, D).
|
| 299 |
+
Mark the correct answer with an asterisk (*) after the option letter.
|
| 300 |
+
Format each question as:
|
| 301 |
+
Question 1: [Question text]
|
| 302 |
+
A) [Option A]
|
| 303 |
+
B) [Option B]
|
| 304 |
+
C) [Option C]
|
| 305 |
+
D) [Option D]
|
| 306 |
+
Correct Answer: [Letter]*
|
| 307 |
+
|
| 308 |
Write questions directly without any introductory text.
|
| 309 |
|
| 310 |
Text:
|
|
|
|
| 313 |
"quiz_truefalse": f"""{lang_instruction}
|
| 314 |
|
| 315 |
Generate 10 True/False questions from this text.
|
| 316 |
+
Format each question as:
|
| 317 |
+
Question 1: [Statement]
|
| 318 |
+
Answer: True / False
|
| 319 |
+
|
| 320 |
+
Provide the correct answer for each question.
|
| 321 |
Write questions directly without any introductory text.
|
| 322 |
|
| 323 |
Text:
|
|
|
|
| 326 |
"quiz_fillblanks": f"""{lang_instruction}
|
| 327 |
|
| 328 |
Generate 10 fill-in-the-blank questions from this text.
|
| 329 |
+
Format each question as:
|
| 330 |
+
Question 1: [Sentence with _____ for blank]
|
| 331 |
+
Answer: [Correct word/phrase]
|
| 332 |
+
|
| 333 |
+
Provide correct answers for each question.
|
| 334 |
Write questions directly without any introductory text.
|
| 335 |
|
| 336 |
Text:
|
|
|
|
| 339 |
"quiz_matching": f"""{lang_instruction}
|
| 340 |
|
| 341 |
Create a matching exercise with 10 items in Column A and their matches in Column B.
|
| 342 |
+
Format as:
|
| 343 |
+
Column A:
|
| 344 |
+
1. [Item 1]
|
| 345 |
+
2. [Item 2]
|
| 346 |
+
...
|
| 347 |
+
|
| 348 |
+
Column B:
|
| 349 |
+
a) [Match option a]
|
| 350 |
+
b) [Match option b]
|
| 351 |
+
...
|
| 352 |
+
|
| 353 |
+
Correct Matches:
|
| 354 |
+
1 - [letter]
|
| 355 |
+
2 - [letter]
|
| 356 |
+
...
|
| 357 |
+
|
| 358 |
Present directly without any introductory text.
|
| 359 |
|
| 360 |
Text:
|
|
|
|
| 363 |
"quiz_short": f"""{lang_instruction}
|
| 364 |
|
| 365 |
Generate 10 short-answer questions from this text with brief model answers.
|
| 366 |
+
Format each question as:
|
| 367 |
+
Question 1: [Question text]
|
| 368 |
+
Model Answer: [2-3 sentence answer]
|
| 369 |
+
|
| 370 |
Write questions directly without any introductory text.
|
| 371 |
|
| 372 |
Text:
|
|
|
|
| 375 |
"quiz_essay": f"""{lang_instruction}
|
| 376 |
|
| 377 |
Generate 5 essay-type questions from this text with key points to cover.
|
| 378 |
+
Format each question as:
|
| 379 |
+
Question 1: [Essay question]
|
| 380 |
+
Key Points to Cover:
|
| 381 |
+
- Point 1
|
| 382 |
+
- Point 2
|
| 383 |
+
- Point 3
|
| 384 |
+
|
| 385 |
Write questions directly without any introductory text.
|
| 386 |
|
| 387 |
Text:
|
| 388 |
+
{text}""",
|
| 389 |
+
|
| 390 |
+
"chapter": f"""{lang_instruction}
|
| 391 |
+
|
| 392 |
+
Create a comprehensive book chapter from this content. Include:
|
| 393 |
+
- Chapter title
|
| 394 |
+
- Introduction (2-3 paragraphs)
|
| 395 |
+
- Main sections with headings (3-5 sections)
|
| 396 |
+
- Each section should have multiple paragraphs
|
| 397 |
+
- Conclusion (2 paragraphs)
|
| 398 |
+
- Key takeaways (5-7 bullet points)
|
| 399 |
+
|
| 400 |
+
Write in an academic style suitable for a textbook.
|
| 401 |
+
Present directly without any introductory text.
|
| 402 |
+
|
| 403 |
+
Content:
|
| 404 |
{text}""",
|
| 405 |
|
| 406 |
"mindmap": f"""{lang_instruction}
|
|
|
|
| 570 |
|
| 571 |
def create_pptx(content, title, language="English"):
|
| 572 |
"""
|
| 573 |
+
Create PowerPoint presentation with colorful professional design
|
| 574 |
"""
|
| 575 |
try:
|
| 576 |
prs = Presentation()
|
|
|
|
| 579 |
|
| 580 |
is_urdu = language == "Urdu" or is_urdu_text(content)
|
| 581 |
|
| 582 |
+
# Title slide with gradient-like colorful design
|
| 583 |
title_slide_layout = prs.slide_layouts[0]
|
| 584 |
slide = prs.slides.add_slide(title_slide_layout)
|
| 585 |
|
| 586 |
+
# Colorful title
|
| 587 |
slide.shapes.title.text = title
|
| 588 |
title_frame = slide.shapes.title.text_frame
|
| 589 |
title_frame.paragraphs[0].font.size = PptxPt(44)
|
| 590 |
title_frame.paragraphs[0].font.bold = True
|
| 591 |
+
title_frame.paragraphs[0].font.color.rgb = PptxRGBColor(25, 25, 112) # Midnight Blue
|
| 592 |
|
| 593 |
+
# Colorful subtitle
|
| 594 |
subtitle = slide.placeholders[1]
|
| 595 |
subtitle_text = f"Generated on {datetime.now().strftime('%B %d, %Y')}"
|
| 596 |
if is_urdu:
|
| 597 |
subtitle_text = f"تیار کردہ: {datetime.now().strftime('%d/%m/%Y')}"
|
| 598 |
subtitle.text = subtitle_text
|
| 599 |
+
for paragraph in subtitle.text_frame.paragraphs:
|
| 600 |
+
paragraph.font.color.rgb = PptxRGBColor(70, 130, 180) # Steel Blue
|
| 601 |
+
paragraph.font.size = PptxPt(20)
|
| 602 |
|
| 603 |
+
# Add session objectives slide with colors
|
| 604 |
objectives_layout = prs.slide_layouts[1]
|
| 605 |
obj_slide = prs.slides.add_slide(objectives_layout)
|
| 606 |
obj_slide.shapes.title.text = "Session Objectives" if not is_urdu else "سیشن کے مقاصد"
|
| 607 |
|
| 608 |
+
# Color the objectives title
|
| 609 |
+
obj_title_frame = obj_slide.shapes.title.text_frame
|
| 610 |
+
obj_title_frame.paragraphs[0].font.color.rgb = PptxRGBColor(220, 20, 60) # Crimson
|
| 611 |
+
obj_title_frame.paragraphs[0].font.bold = True
|
| 612 |
+
|
| 613 |
obj_frame = obj_slide.shapes.placeholders[1].text_frame
|
| 614 |
obj_frame.clear()
|
| 615 |
|
|
|
|
| 626 |
"تنقیدی سوچ کی مہارت پیدا کرنا"
|
| 627 |
]
|
| 628 |
|
| 629 |
+
objective_colors = [
|
| 630 |
+
PptxRGBColor(46, 139, 87), # Sea Green
|
| 631 |
+
PptxRGBColor(255, 140, 0), # Dark Orange
|
| 632 |
+
PptxRGBColor(138, 43, 226) # Blue Violet
|
| 633 |
+
]
|
| 634 |
+
|
| 635 |
+
for idx, obj_text in enumerate(objectives):
|
| 636 |
p = obj_frame.add_paragraph()
|
| 637 |
p.text = obj_text
|
| 638 |
p.font.size = PptxPt(20)
|
| 639 |
+
p.font.color.rgb = objective_colors[idx % len(objective_colors)]
|
| 640 |
p.level = 0
|
| 641 |
if is_urdu:
|
| 642 |
p.alignment = PP_ALIGN.RIGHT
|
| 643 |
|
| 644 |
+
# Parse content into slides
|
| 645 |
slides_content = []
|
| 646 |
current_slide = {"title": "", "points": []}
|
| 647 |
|
|
|
|
| 663 |
if current_slide["title"]:
|
| 664 |
slides_content.append(current_slide)
|
| 665 |
|
| 666 |
+
# Rich color palette for slides
|
| 667 |
+
title_colors = [
|
| 668 |
+
PptxRGBColor(0, 51, 102), # Navy Blue
|
| 669 |
+
PptxRGBColor(139, 0, 0), # Dark Red
|
| 670 |
+
PptxRGBColor(0, 100, 0), # Dark Green
|
| 671 |
+
PptxRGBColor(148, 0, 211), # Dark Violet
|
| 672 |
+
PptxRGBColor(255, 140, 0), # Dark Orange
|
| 673 |
+
PptxRGBColor(0, 139, 139), # Dark Cyan
|
| 674 |
+
]
|
| 675 |
+
|
| 676 |
+
text_colors = [
|
| 677 |
+
PptxRGBColor(47, 79, 79), # Dark Slate Gray
|
| 678 |
+
PptxRGBColor(105, 105, 105), # Dim Gray
|
| 679 |
+
PptxRGBColor(25, 25, 112), # Midnight Blue
|
| 680 |
]
|
| 681 |
|
| 682 |
for idx, slide_data in enumerate(slides_content):
|
| 683 |
bullet_slide_layout = prs.slide_layouts[1]
|
| 684 |
slide = prs.slides.add_slide(bullet_slide_layout)
|
| 685 |
|
| 686 |
+
# Colorful title for each slide
|
| 687 |
slide.shapes.title.text = slide_data["title"]
|
| 688 |
title_frame = slide.shapes.title.text_frame
|
| 689 |
title_frame.paragraphs[0].font.size = PptxPt(32)
|
| 690 |
title_frame.paragraphs[0].font.bold = True
|
| 691 |
+
title_frame.paragraphs[0].font.color.rgb = title_colors[idx % len(title_colors)]
|
| 692 |
|
| 693 |
text_frame = slide.shapes.placeholders[1].text_frame
|
| 694 |
text_frame.clear()
|
| 695 |
|
| 696 |
+
for point_idx, point in enumerate(slide_data["points"][:6]): # Max 6 points per slide
|
| 697 |
p = text_frame.add_paragraph()
|
| 698 |
p.text = point
|
| 699 |
p.level = 0
|
| 700 |
p.font.size = PptxPt(18)
|
| 701 |
+
p.font.color.rgb = text_colors[point_idx % len(text_colors)]
|
| 702 |
if is_urdu or is_urdu_text(point):
|
| 703 |
p.alignment = PP_ALIGN.RIGHT
|
| 704 |
|
| 705 |
+
# Add colorful conclusion slide
|
| 706 |
conclusion_layout = prs.slide_layouts[1]
|
| 707 |
conclusion_slide = prs.slides.add_slide(conclusion_layout)
|
| 708 |
conclusion_slide.shapes.title.text = "Conclusion" if not is_urdu else "نتیجہ"
|
| 709 |
|
| 710 |
+
# Color the conclusion title
|
| 711 |
+
conc_title_frame = conclusion_slide.shapes.title.text_frame
|
| 712 |
+
conc_title_frame.paragraphs[0].font.color.rgb = PptxRGBColor(178, 34, 34) # Firebrick
|
| 713 |
+
conc_title_frame.paragraphs[0].font.bold = True
|
| 714 |
+
|
| 715 |
conc_frame = conclusion_slide.shapes.placeholders[1].text_frame
|
| 716 |
conc_frame.clear()
|
| 717 |
|
|
|
|
| 728 |
"مزید معلومات کے لیے رابطہ کریں"
|
| 729 |
]
|
| 730 |
|
| 731 |
+
conclusion_colors = [
|
| 732 |
+
PptxRGBColor(0, 128, 0), # Green
|
| 733 |
+
PptxRGBColor(255, 69, 0), # Red-Orange
|
| 734 |
+
PptxRGBColor(72, 61, 139) # Dark Slate Blue
|
| 735 |
+
]
|
| 736 |
+
|
| 737 |
+
for idx, text in enumerate(conclusion_text):
|
| 738 |
p = conc_frame.add_paragraph()
|
| 739 |
p.text = text
|
| 740 |
p.font.size = PptxPt(24)
|
| 741 |
p.font.bold = True
|
| 742 |
+
p.font.color.rgb = conclusion_colors[idx]
|
| 743 |
if is_urdu:
|
| 744 |
p.alignment = PP_ALIGN.RIGHT
|
| 745 |
|
|
|
|
| 762 |
return transcribe_audio_chunked(audio)
|
| 763 |
|
| 764 |
def ui_generate_docx(transcription_box, content_dropdown, lang_choice, institution_input, writer_input):
|
| 765 |
+
"""Handle DOCX generation from UI - works for all content types except PowerPoint"""
|
| 766 |
if not transcription_box:
|
| 767 |
return "❌ No transcribed text available", None, "⚠️ Please transcribe audio first"
|
| 768 |
|
| 769 |
+
# PowerPoint should use the dedicated PPTX button
|
| 770 |
+
if content_dropdown == "powerpoint":
|
| 771 |
+
return "⚠️ Please use the 'Generate & Download PPTX' button for PowerPoint presentations", None, "⚠️ Use PPTX button for presentations"
|
| 772 |
+
|
| 773 |
try:
|
| 774 |
content = generate_content(transcription_box, content_dropdown, lang_choice)
|
| 775 |
|
|
|
|
| 792 |
"quiz_essay": "Essay Questions" if lang_choice == "English" else "مضمون کے سوالات",
|
| 793 |
"mindmap": "Mind Map" if lang_choice == "English" else "ذہنی نقشہ",
|
| 794 |
"meeting_minutes": "Minutes of Meeting" if lang_choice == "English" else "اجلاس کی کارروائی",
|
| 795 |
+
"translation": f"Translation to {lang_choice}",
|
| 796 |
+
"chapter": "Book Chapter" if lang_choice == "English" else "کتاب کا باب"
|
| 797 |
}
|
| 798 |
|
| 799 |
title = title_map.get(content_dropdown, "Generated Content")
|
|
|
|
| 881 |
("themes_subthemes", "Themes & Subthemes"),
|
| 882 |
("summary", "Summary"),
|
| 883 |
("study_notes", "Study Notes"),
|
| 884 |
+
("chapter", "Book Chapter"),
|
| 885 |
("tutorial_beginners", "Tutorial for Beginners"),
|
| 886 |
("infographic_content", "Infographic Content"),
|
| 887 |
("social_facebook", "Facebook Post"),
|
|
|
|
| 916 |
qa1 = gr.Button("Summary")
|
| 917 |
qa2 = gr.Button("Study Notes")
|
| 918 |
qa3 = gr.Button("Themes")
|
| 919 |
+
qa4 = gr.Button("Chapter")
|
| 920 |
with gr.Row():
|
| 921 |
+
qa5 = gr.Button("Tutorial")
|
| 922 |
qa6 = gr.Button("Facebook")
|
| 923 |
qa7 = gr.Button("LinkedIn")
|
| 924 |
+
qa8 = gr.Button("MCQs")
|
| 925 |
|
| 926 |
quick_output = gr.Textbox(label="Quick Output", lines=10)
|
| 927 |
|
|
|
|
| 967 |
outputs=[quick_output]
|
| 968 |
)
|
| 969 |
qa4.click(
|
| 970 |
+
fn=lambda t, l, i, w: ui_generate_quick("chapter", t, l, i, w),
|
| 971 |
inputs=[transcription_box, lang_choice, institution_input, writer_input],
|
| 972 |
outputs=[quick_output]
|
| 973 |
)
|
| 974 |
qa5.click(
|
| 975 |
+
fn=lambda t, l, i, w: ui_generate_quick("tutorial_beginners", t, l, i, w),
|
| 976 |
inputs=[transcription_box, lang_choice, institution_input, writer_input],
|
| 977 |
outputs=[quick_output]
|
| 978 |
)
|
|
|
|
| 987 |
outputs=[quick_output]
|
| 988 |
)
|
| 989 |
qa8.click(
|
| 990 |
+
fn=lambda t, l, i, w: ui_generate_quick("quiz_mcqs", t, l, i, w),
|
| 991 |
inputs=[transcription_box, lang_choice, institution_input, writer_input],
|
| 992 |
outputs=[quick_output]
|
| 993 |
)
|