Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,20 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
|
|
|
|
|
|
|
|
6 |
|
7 |
-
# Gradio UI with an audio player
|
8 |
demo = gr.Interface(
|
9 |
-
fn=
|
10 |
-
inputs=[],
|
11 |
-
outputs="
|
12 |
title="Audio Player",
|
13 |
description="Click play to listen to the song."
|
14 |
)
|
15 |
|
16 |
-
# Launch the Space
|
17 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import requests
|
3 |
|
4 |
+
AUDIO_URL = "https://huggingface.co/spaces/Namazlol/my-audio-hosting/resolve/main/mysong.mp3"
|
5 |
+
|
6 |
+
def download_audio():
|
7 |
+
response = requests.get(AUDIO_URL)
|
8 |
+
with open("mysong.mp3", "wb") as f:
|
9 |
+
f.write(response.content)
|
10 |
+
return "mysong.mp3"
|
11 |
|
|
|
12 |
demo = gr.Interface(
|
13 |
+
fn=download_audio,
|
14 |
+
inputs=[],
|
15 |
+
outputs=gr.Audio(type="filepath"),
|
16 |
title="Audio Player",
|
17 |
description="Click play to listen to the song."
|
18 |
)
|
19 |
|
|
|
20 |
demo.launch()
|