Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -65,7 +65,7 @@ def convert_to_wav(audio_file):
|
|
65 |
return wav_file
|
66 |
|
67 |
|
68 |
-
@spaces.GPU(duration=
|
69 |
def transcribe_audio(audio_file, batch_size=4):
|
70 |
start_time = time.time()
|
71 |
# Convert .m4a to .wav
|
@@ -128,25 +128,6 @@ image_html = """
|
|
128 |
</div>
|
129 |
"""
|
130 |
|
131 |
-
# Gradio UI
|
132 |
-
iface = gr.Blocks()
|
133 |
-
|
134 |
-
with iface:
|
135 |
-
gr.HTML(image_html)
|
136 |
-
gr.Markdown("# Upload an audio file to get the transcription")
|
137 |
-
audio_input = gr.Audio(type="filepath")
|
138 |
-
batch_size_input = gr.Slider(minimum=1, maximum=16, step=1, label="Batch Size")
|
139 |
-
transcription_output = gr.Textbox("Transcription | nb-whisper-large-semantic")
|
140 |
-
summary_output = gr.Textbox("Summary | TextRank, graph-based")
|
141 |
-
transcribe_button = gr.Button("Transcribe and Summarize")
|
142 |
-
|
143 |
-
def transcribe_and_summarize(audio_file, batch_size):
|
144 |
-
transcription, result = transcribe_audio(audio_file, batch_size)
|
145 |
-
summary = summarize_text(transcription)
|
146 |
-
return result, summary
|
147 |
-
|
148 |
-
transcribe_button.click(fn=transcribe_and_summarize, inputs=[audio_input, batch_size_input], outputs=[transcription_output, summary_output])
|
149 |
-
|
150 |
def save_to_pdf(transcription, summary):
|
151 |
pdf = FPDF()
|
152 |
pdf.add_page()
|
@@ -165,5 +146,36 @@ def save_to_pdf(transcription, summary):
|
|
165 |
pdf.output(pdf_output_path)
|
166 |
return pdf_output_path
|
167 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
# run
|
169 |
iface.launch(share=True, debug=True)
|
|
|
65 |
return wav_file
|
66 |
|
67 |
|
68 |
+
@spaces.GPU(duration=21600, queue=False)
|
69 |
def transcribe_audio(audio_file, batch_size=4):
|
70 |
start_time = time.time()
|
71 |
# Convert .m4a to .wav
|
|
|
128 |
</div>
|
129 |
"""
|
130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
def save_to_pdf(transcription, summary):
|
132 |
pdf = FPDF()
|
133 |
pdf.add_page()
|
|
|
146 |
pdf.output(pdf_output_path)
|
147 |
return pdf_output_path
|
148 |
|
149 |
+
# Gradio UI
|
150 |
+
iface = gr.Blocks()
|
151 |
+
|
152 |
+
with iface:
|
153 |
+
gr.HTML(image_html)
|
154 |
+
gr.Markdown("# Upload an audio file to get the transcription")
|
155 |
+
audio_input = gr.Audio(type="filepath")
|
156 |
+
batch_size_input = gr.Slider(minimum=7, maximum=16, step=1, label="Batch Size")
|
157 |
+
transcription_output = gr.Textbox("Transcription | nb-whisper-large-semantic")
|
158 |
+
summary_output = gr.Textbox("Summary | TextRank, graph-based")
|
159 |
+
pdf_output = gr.File(label="Download PDF")
|
160 |
+
transcribe_button = gr.Button("Transcribe and Summarize")
|
161 |
+
|
162 |
+
def transcribe_and_summarize(audio_file, batch_size):
|
163 |
+
transcription, result = transcribe_audio(audio_file, batch_size)
|
164 |
+
summary = summarize_text(transcription)
|
165 |
+
pdf_path = save_to_pdf(transcription, summary)
|
166 |
+
return result, summary, pdf_path
|
167 |
+
|
168 |
+
transcribe_button.click(
|
169 |
+
fn=transcribe_and_summarize,
|
170 |
+
inputs=[audio_input, batch_size_input],
|
171 |
+
outputs=[transcription_output, summary_output, pdf_output]
|
172 |
+
)
|
173 |
+
|
174 |
+
# run
|
175 |
+
iface.launch(share=True, debug=True)
|
176 |
+
|
177 |
+
|
178 |
+
|
179 |
+
|
180 |
# run
|
181 |
iface.launch(share=True, debug=True)
|