Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,32 +2,18 @@ import gradio as gr
|
|
| 2 |
import re
|
| 3 |
|
| 4 |
def convert_suno_to_mp3(url: str):
|
| 5 |
-
"""
|
| 6 |
-
Convert a Suno song URL to the direct MP3 link.
|
| 7 |
-
"""
|
| 8 |
match = re.search(r'suno\.com/song/([a-f0-9\-]+)', url)
|
| 9 |
if not match:
|
| 10 |
return "Invalid Suno URL", None
|
| 11 |
song_id = match.group(1)
|
| 12 |
mp3_url = f"https://cdn1.suno.ai/{song_id}.mp3"
|
| 13 |
-
return mp3_url, mp3_url
|
| 14 |
-
|
| 15 |
-
with gr.Blocks() as demo:
|
| 16 |
-
gr.Markdown("## Suno Song → Direct MP3 Converter")
|
| 17 |
-
|
| 18 |
-
with gr.Row():
|
| 19 |
-
song_input = gr.Textbox(label="Enter Suno song URL", placeholder="https://suno.com/song/...")
|
| 20 |
-
mp3_output = gr.Textbox(label="MP3 URL")
|
| 21 |
-
download_btn = gr.File(label="Download MP3")
|
| 22 |
-
|
| 23 |
-
def convert(url):
|
| 24 |
-
mp3_link, downloadable = convert_suno_to_mp3(url)
|
| 25 |
-
return mp3_link, downloadable
|
| 26 |
-
|
| 27 |
-
# bind the function to input changes
|
| 28 |
-
song_input.change(convert, inputs=song_input, outputs=[mp3_output, download_btn])
|
| 29 |
-
|
| 30 |
-
# 🚀 Add API name explicitly
|
| 31 |
-
demo.launch(api_name="convert")
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
|
|
|
|
|
| 2 |
import re
|
| 3 |
|
| 4 |
def convert_suno_to_mp3(url: str):
|
|
|
|
|
|
|
|
|
|
| 5 |
match = re.search(r'suno\.com/song/([a-f0-9\-]+)', url)
|
| 6 |
if not match:
|
| 7 |
return "Invalid Suno URL", None
|
| 8 |
song_id = match.group(1)
|
| 9 |
mp3_url = f"https://cdn1.suno.ai/{song_id}.mp3"
|
| 10 |
+
return mp3_url, mp3_url
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
demo = gr.Interface(
|
| 13 |
+
fn=convert_suno_to_mp3,
|
| 14 |
+
inputs=gr.Textbox(label="Enter Suno song URL"),
|
| 15 |
+
outputs=[gr.Textbox(label="MP3 URL"), gr.File(label="Download MP3")],
|
| 16 |
+
api_name="convert" # ✅ works here
|
| 17 |
+
)
|
| 18 |
|
| 19 |
+
demo.launch()
|