Spaces:
Sleeping
Sleeping
add summary
Browse files
app.py
CHANGED
@@ -26,20 +26,18 @@ def download_audio(url):
|
|
26 |
code = ydl.download([url])
|
27 |
assert code == 0, "Failed to download audio"
|
28 |
|
29 |
-
text = ""
|
30 |
-
def generate_text(url):
|
31 |
-
download_audio(url)
|
32 |
with open("demo.m4a", "rb") as f:
|
33 |
transcription = client.audio.transcriptions.create(
|
34 |
model="whisper-1",
|
35 |
file=f,
|
36 |
response_format="text"
|
37 |
)
|
38 |
-
|
39 |
-
|
|
|
40 |
|
41 |
def summarize_text():
|
42 |
-
|
43 |
prompt = f"Please summarize the following article in 5 sentences or less: [{text}]"
|
44 |
message = claude_client.messages.create(
|
45 |
model="claude-3-haiku-20240307",
|
@@ -65,7 +63,7 @@ with gr.Blocks() as demo:
|
|
65 |
summary = gr.TextArea(label="Summary")
|
66 |
|
67 |
button_download.click(
|
68 |
-
|
69 |
inputs=[name],
|
70 |
outputs=[output],
|
71 |
)
|
|
|
26 |
code = ydl.download([url])
|
27 |
assert code == 0, "Failed to download audio"
|
28 |
|
|
|
|
|
|
|
29 |
with open("demo.m4a", "rb") as f:
|
30 |
transcription = client.audio.transcriptions.create(
|
31 |
model="whisper-1",
|
32 |
file=f,
|
33 |
response_format="text"
|
34 |
)
|
35 |
+
|
36 |
+
print(transcription.text)
|
37 |
+
return transcription.text
|
38 |
|
39 |
def summarize_text():
|
40 |
+
text = output.value
|
41 |
prompt = f"Please summarize the following article in 5 sentences or less: [{text}]"
|
42 |
message = claude_client.messages.create(
|
43 |
model="claude-3-haiku-20240307",
|
|
|
63 |
summary = gr.TextArea(label="Summary")
|
64 |
|
65 |
button_download.click(
|
66 |
+
download_audio,
|
67 |
inputs=[name],
|
68 |
outputs=[output],
|
69 |
)
|