Spaces:
Sleeping
Sleeping
Dwitee Krishna Panda
commited on
Commit
·
ce47ffe
1
Parent(s):
a9c2826
adding mindmap
Browse files
app.py
CHANGED
|
@@ -8,6 +8,7 @@ import langdetect
|
|
| 8 |
import moviepy.editor as mp
|
| 9 |
import yt_dlp
|
| 10 |
import whisper
|
|
|
|
| 11 |
|
| 12 |
print("Starting the program...")
|
| 13 |
|
|
@@ -67,6 +68,20 @@ def generate_summary_stream(transcription):
|
|
| 67 |
bullet_summary = "\n".join(f"• {sentence.strip()}" for sentence in raw_summary.split('.') if sentence.strip())
|
| 68 |
return bullet_summary
|
| 69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
def process_youtube(url):
|
| 71 |
if not url:
|
| 72 |
return "No URL", None
|
|
@@ -101,8 +116,10 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 101 |
with gr.Row():
|
| 102 |
transcription_output = gr.Textbox(label="📝 Transcription", lines=10, show_copy_button=True)
|
| 103 |
summary_output = gr.Textbox(label="📊 Summary Points", lines=10, show_copy_button=True)
|
|
|
|
| 104 |
|
| 105 |
summary_button = gr.Button("📝 Generate Summary")
|
|
|
|
| 106 |
|
| 107 |
def process_video_and_update(video):
|
| 108 |
if video is None:
|
|
@@ -113,5 +130,6 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 113 |
video_button.click(process_video_and_update, inputs=[video_input], outputs=[transcription_output, summary_output])
|
| 114 |
url_button.click(process_youtube, inputs=[url_input], outputs=[transcription_output, summary_output])
|
| 115 |
summary_button.click(generate_summary_stream, inputs=[transcription_output], outputs=[summary_output])
|
|
|
|
| 116 |
|
| 117 |
demo.launch(share=True)
|
|
|
|
| 8 |
import moviepy.editor as mp
|
| 9 |
import yt_dlp
|
| 10 |
import whisper
|
| 11 |
+
from graphviz import Digraph
|
| 12 |
|
| 13 |
print("Starting the program...")
|
| 14 |
|
|
|
|
| 68 |
bullet_summary = "\n".join(f"• {sentence.strip()}" for sentence in raw_summary.split('.') if sentence.strip())
|
| 69 |
return bullet_summary
|
| 70 |
|
| 71 |
+
def generate_mindmap_from_summary(summary_text):
|
| 72 |
+
dot = Digraph(comment='Mind Map')
|
| 73 |
+
dot.node('A', 'Summary')
|
| 74 |
+
|
| 75 |
+
lines = summary_text.split('\n')
|
| 76 |
+
for idx, line in enumerate(lines):
|
| 77 |
+
node_id = f'B{idx}'
|
| 78 |
+
dot.node(node_id, line.replace("• ", "").strip())
|
| 79 |
+
dot.edge('A', node_id)
|
| 80 |
+
|
| 81 |
+
output_path = generate_unique_filename(".png")
|
| 82 |
+
dot.render(output_path, format='png', cleanup=True)
|
| 83 |
+
return output_path + ".png"
|
| 84 |
+
|
| 85 |
def process_youtube(url):
|
| 86 |
if not url:
|
| 87 |
return "No URL", None
|
|
|
|
| 116 |
with gr.Row():
|
| 117 |
transcription_output = gr.Textbox(label="📝 Transcription", lines=10, show_copy_button=True)
|
| 118 |
summary_output = gr.Textbox(label="📊 Summary Points", lines=10, show_copy_button=True)
|
| 119 |
+
mindmap_output = gr.Image(label="🧠 Mind Map")
|
| 120 |
|
| 121 |
summary_button = gr.Button("📝 Generate Summary")
|
| 122 |
+
mindmap_button = gr.Button("🧠 Generate Mind Map")
|
| 123 |
|
| 124 |
def process_video_and_update(video):
|
| 125 |
if video is None:
|
|
|
|
| 130 |
video_button.click(process_video_and_update, inputs=[video_input], outputs=[transcription_output, summary_output])
|
| 131 |
url_button.click(process_youtube, inputs=[url_input], outputs=[transcription_output, summary_output])
|
| 132 |
summary_button.click(generate_summary_stream, inputs=[transcription_output], outputs=[summary_output])
|
| 133 |
+
mindmap_button.click(generate_mindmap_from_summary, inputs=[summary_output], outputs=[mindmap_output])
|
| 134 |
|
| 135 |
demo.launch(share=True)
|