Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -77,23 +77,26 @@ def generate_summary(transcription):
|
|
| 77 |
|
| 78 |
# Define the main function to handle transcription and summary generation
|
| 79 |
|
| 80 |
-
def process_lecture(
|
| 81 |
transcription = ""
|
| 82 |
-
if
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
audio_path = download_youtube_audio(input_value)
|
| 89 |
with open(audio_path, "rb") as f:
|
| 90 |
transcription = transcribe_audio(f)
|
| 91 |
-
|
| 92 |
-
|
|
|
|
| 93 |
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
|
|
|
|
|
|
|
|
|
| 97 |
|
| 98 |
# Set up Gradio interface
|
| 99 |
with gr.Blocks() as demo:
|
|
@@ -117,6 +120,7 @@ with gr.Blocks() as demo:
|
|
| 117 |
transcription_output = gr.Textbox(label="Lecture Transcription with Timestamps", interactive=False)
|
| 118 |
summary_output = gr.Textbox(label="Summarized Lecture Notes", interactive=False)
|
| 119 |
|
| 120 |
-
submit_btn.click(fn=process_lecture, inputs=[
|
| 121 |
|
| 122 |
-
# Launch the interface
|
|
|
|
|
|
| 77 |
|
| 78 |
# Define the main function to handle transcription and summary generation
|
| 79 |
|
| 80 |
+
def process_lecture(input_type, audio_input, pdf_input, youtube_input, lesson_plan):
|
| 81 |
transcription = ""
|
| 82 |
+
if input_type == "Audio File":
|
| 83 |
+
if audio_input is not None:
|
| 84 |
+
transcription = transcribe_audio(audio_input)
|
| 85 |
+
elif input_type == "YouTube URL":
|
| 86 |
+
if youtube_input:
|
| 87 |
+
audio_path = download_youtube_audio(youtube_input)
|
|
|
|
| 88 |
with open(audio_path, "rb") as f:
|
| 89 |
transcription = transcribe_audio(f)
|
| 90 |
+
elif input_type == "PDF Document":
|
| 91 |
+
if pdf_input is not None:
|
| 92 |
+
transcription = extract_text_from_pdf(pdf_input)
|
| 93 |
|
| 94 |
+
if transcription:
|
| 95 |
+
transcription_text = "\n".join([f"{segment['start']:.2f}-{segment['end']:.2f}: {segment['text']}" for segment in transcription['segments']])
|
| 96 |
+
summary = generate_summary(transcription)
|
| 97 |
+
return transcription_text, summary
|
| 98 |
+
else:
|
| 99 |
+
return "No transcription available.", "No summary available."
|
| 100 |
|
| 101 |
# Set up Gradio interface
|
| 102 |
with gr.Blocks() as demo:
|
|
|
|
| 120 |
transcription_output = gr.Textbox(label="Lecture Transcription with Timestamps", interactive=False)
|
| 121 |
summary_output = gr.Textbox(label="Summarized Lecture Notes", interactive=False)
|
| 122 |
|
| 123 |
+
submit_btn.click(fn=process_lecture, inputs=[input_type, audio_input, pdf_input, youtube_input, lesson_plan_input], outputs=[transcription_output, summary_output])
|
| 124 |
|
| 125 |
+
# Launch the interface
|
| 126 |
+
demo.launch(share=True)
|