Spaces:
No application file
No application file
Update app.py
Browse files
app.py
CHANGED
|
@@ -744,4 +744,131 @@ with gr.Blocks(title="Voice Transcription & Content Generation") as app:
|
|
| 744 |
with gr.Row():
|
| 745 |
with gr.Column(scale=6):
|
| 746 |
gr.Markdown("### 1) Audio Input")
|
| 747 |
-
upload_audio = gr.Audio(sources=["upload"], type="filepath", label="Upload Audio (MP3/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 744 |
with gr.Row():
|
| 745 |
with gr.Column(scale=6):
|
| 746 |
gr.Markdown("### 1) Audio Input")
|
| 747 |
+
upload_audio = gr.Audio(sources=["upload"], type="filepath", label="Upload Audio (MP3/WAV)")
|
| 748 |
+
record_audio = gr.Audio(sources=["microphone"], type="filepath", label="Record Audio (Microphone)")
|
| 749 |
+
lang_choice = gr.Dropdown(["English", "Urdu"], value="English", label="Transcription / Output Language")
|
| 750 |
+
transcribe_btn = gr.Button("๐ Transcribe Audio", variant="primary")
|
| 751 |
+
trans_status = gr.Textbox(label="Status", interactive=False)
|
| 752 |
+
transcription_box = gr.Textbox(label="Transcribed Text", lines=12)
|
| 753 |
+
clear_btn = gr.Button("๐ Clear", variant="secondary")
|
| 754 |
+
|
| 755 |
+
with gr.Column(scale=6):
|
| 756 |
+
gr.Markdown("### 2) Content Generation & Downloads")
|
| 757 |
+
content_dropdown = gr.Dropdown(
|
| 758 |
+
[
|
| 759 |
+
("themes_subthemes", "Themes & Subthemes"),
|
| 760 |
+
("summary", "Summary"),
|
| 761 |
+
("study_notes", "Study Notes"),
|
| 762 |
+
("tutorial_beginners", "Tutorial for Beginners"),
|
| 763 |
+
("infographic_content", "Infographic Content"),
|
| 764 |
+
("social_facebook", "Facebook Post"),
|
| 765 |
+
("social_linkedin", "LinkedIn Post"),
|
| 766 |
+
("quiz_mcqs", "Quiz - MCQs"),
|
| 767 |
+
("quiz_truefalse", "Quiz - True/False"),
|
| 768 |
+
("quiz_fillblanks", "Quiz - Fill in the Blanks"),
|
| 769 |
+
("quiz_matching", "Quiz - Matching"),
|
| 770 |
+
("quiz_short", "Quiz - Short Answer"),
|
| 771 |
+
("quiz_essay", "Quiz - Essay Questions"),
|
| 772 |
+
("mindmap", "Mind Map"),
|
| 773 |
+
("meeting_minutes", "Meeting Minutes"),
|
| 774 |
+
("translation", "Translation"),
|
| 775 |
+
("powerpoint", "PowerPoint Slides")
|
| 776 |
+
],
|
| 777 |
+
label="Select Content Type",
|
| 778 |
+
value="summary"
|
| 779 |
+
)
|
| 780 |
+
institution_input = gr.Textbox(label="Institution Name (optional)", lines=1)
|
| 781 |
+
writer_input = gr.Textbox(label="Writer Name (optional)", lines=1)
|
| 782 |
+
|
| 783 |
+
generate_docx_btn = gr.Button("๐ Generate & Download DOCX", variant="primary")
|
| 784 |
+
docx_status = gr.Textbox(label="DOCX Status", interactive=False)
|
| 785 |
+
docx_file = gr.File(label="Download DOCX")
|
| 786 |
+
|
| 787 |
+
generate_pptx_btn = gr.Button("๐ฅ๏ธ Generate & Download PPTX", variant="primary")
|
| 788 |
+
pptx_status = gr.Textbox(label="PPTX Status", interactive=False)
|
| 789 |
+
pptx_file = gr.File(label="Download PPTX")
|
| 790 |
+
|
| 791 |
+
gr.Markdown("### Quick Actions")
|
| 792 |
+
with gr.Row():
|
| 793 |
+
qa1 = gr.Button("Summary")
|
| 794 |
+
qa2 = gr.Button("Study Notes")
|
| 795 |
+
qa3 = gr.Button("Themes")
|
| 796 |
+
qa4 = gr.Button("Tutorial")
|
| 797 |
+
with gr.Row():
|
| 798 |
+
qa5 = gr.Button("PowerPoint")
|
| 799 |
+
qa6 = gr.Button("Facebook")
|
| 800 |
+
qa7 = gr.Button("LinkedIn")
|
| 801 |
+
qa8 = gr.Button("Infographic")
|
| 802 |
+
|
| 803 |
+
quick_output = gr.Textbox(label="Quick Output", lines=10)
|
| 804 |
+
|
| 805 |
+
# Wire up events
|
| 806 |
+
transcribe_btn.click(
|
| 807 |
+
fn=ui_transcribe,
|
| 808 |
+
inputs=[upload_audio, record_audio, lang_choice],
|
| 809 |
+
outputs=[transcription_box, trans_status]
|
| 810 |
+
)
|
| 811 |
+
|
| 812 |
+
clear_btn.click(
|
| 813 |
+
fn=lambda: (None, None, "", "", "", None, "", None, ""),
|
| 814 |
+
inputs=None,
|
| 815 |
+
outputs=[upload_audio, record_audio, transcription_box, trans_status, docx_status, docx_file, pptx_status, pptx_file, quick_output]
|
| 816 |
+
)
|
| 817 |
+
|
| 818 |
+
generate_docx_btn.click(
|
| 819 |
+
fn=ui_generate_docx,
|
| 820 |
+
inputs=[transcription_box, content_dropdown, lang_choice, institution_input, writer_input],
|
| 821 |
+
outputs=[quick_output, docx_file, docx_status]
|
| 822 |
+
)
|
| 823 |
+
|
| 824 |
+
generate_pptx_btn.click(
|
| 825 |
+
fn=ui_generate_pptx,
|
| 826 |
+
inputs=[transcription_box, lang_choice, institution_input, writer_input],
|
| 827 |
+
outputs=[pptx_file, pptx_status]
|
| 828 |
+
)
|
| 829 |
+
|
| 830 |
+
# Quick actions
|
| 831 |
+
qa1.click(
|
| 832 |
+
fn=lambda t, l, i, w: ui_generate_quick("summary", t, l, i, w),
|
| 833 |
+
inputs=[transcription_box, lang_choice, institution_input, writer_input],
|
| 834 |
+
outputs=[quick_output]
|
| 835 |
+
)
|
| 836 |
+
qa2.click(
|
| 837 |
+
fn=lambda t, l, i, w: ui_generate_quick("study_notes", t, l, i, w),
|
| 838 |
+
inputs=[transcription_box, lang_choice, institution_input, writer_input],
|
| 839 |
+
outputs=[quick_output]
|
| 840 |
+
)
|
| 841 |
+
qa3.click(
|
| 842 |
+
fn=lambda t, l, i, w: ui_generate_quick("themes_subthemes", t, l, i, w),
|
| 843 |
+
inputs=[transcription_box, lang_choice, institution_input, writer_input],
|
| 844 |
+
outputs=[quick_output]
|
| 845 |
+
)
|
| 846 |
+
qa4.click(
|
| 847 |
+
fn=lambda t, l, i, w: ui_generate_quick("tutorial_beginners", t, l, i, w),
|
| 848 |
+
inputs=[transcription_box, lang_choice, institution_input, writer_input],
|
| 849 |
+
outputs=[quick_output]
|
| 850 |
+
)
|
| 851 |
+
qa5.click(
|
| 852 |
+
fn=lambda t, l, i, w: ui_generate_quick("powerpoint", t, l, i, w),
|
| 853 |
+
inputs=[transcription_box, lang_choice, institution_input, writer_input],
|
| 854 |
+
outputs=[quick_output]
|
| 855 |
+
)
|
| 856 |
+
qa6.click(
|
| 857 |
+
fn=lambda t, l, i, w: ui_generate_quick("social_facebook", t, l, i, w),
|
| 858 |
+
inputs=[transcription_box, lang_choice, institution_input, writer_input],
|
| 859 |
+
outputs=[quick_output]
|
| 860 |
+
)
|
| 861 |
+
qa7.click(
|
| 862 |
+
fn=lambda t, l, i, w: ui_generate_quick("social_linkedin", t, l, i, w),
|
| 863 |
+
inputs=[transcription_box, lang_choice, institution_input, writer_input],
|
| 864 |
+
outputs=[quick_output]
|
| 865 |
+
)
|
| 866 |
+
qa8.click(
|
| 867 |
+
fn=lambda t, l, i, w: ui_generate_quick("infographic_content", t, l, i, w),
|
| 868 |
+
inputs=[transcription_box, lang_choice, institution_input, writer_input],
|
| 869 |
+
outputs=[quick_output]
|
| 870 |
+
)
|
| 871 |
+
|
| 872 |
+
# Launch
|
| 873 |
+
if __name__ == "__main__":
|
| 874 |
+
app.launch()
|