MySafeCode commited on
Commit
c85a928
·
verified ·
1 Parent(s): 828a41e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +269 -113
app.py CHANGED
@@ -1,44 +1,150 @@
1
  import gradio as gr
2
  import requests
3
  import os
 
4
  import json
5
 
6
  # Suno API key
7
- SUNO_KEY = os.environ.get("SunoKey", "")
8
  if not SUNO_KEY:
9
  print("⚠️ SunoKey not set!")
10
 
11
  def submit_song_generation(lyrics_text, style, title, instrumental, model):
12
  """Submit song generation request - IMMEDIATE RESPONSE WITH TASK ID"""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  if not SUNO_KEY:
14
  return "❌ Error: SunoKey not configured", ""
 
15
 
16
  if not lyrics_text.strip() and not instrumental:
17
  return "❌ Error: Please provide lyrics or select instrumental", ""
 
18
 
19
  if not style.strip():
20
  return "❌ Error: Please provide a music style", ""
 
21
 
22
  if not title.strip():
23
  return "❌ Error: Please provide a song title", ""
 
24
 
25
  try:
26
  # Prepare request data
27
- request_data = {
28
- "customMode": True,
29
- "instrumental": instrumental,
30
- "model": model,
31
- "callBackUrl": "https://1hit.no/callback.php",
32
- "style": style,
33
- "title": title,
34
- }
35
-
36
- if not instrumental:
37
  # Apply character limits
38
  if model == "V4" and len(lyrics_text) > 3000:
39
  lyrics_text = lyrics_text[:3000]
 
40
  elif model in ["V4_5", "V4_5PLUS", "V4_5ALL", "V5"] and len(lyrics_text) > 5000:
41
  lyrics_text = lyrics_text[:5000]
 
42
 
43
  request_data["prompt"] = lyrics_text
44
  else:
@@ -57,11 +163,23 @@ def submit_song_generation(lyrics_text, style, title, instrumental, model):
57
 
58
  if resp.status_code != 200:
59
  return f"❌ Submission failed: HTTP {resp.status_code}\n\n{resp.text}", ""
 
 
 
 
 
60
 
61
  data = resp.json()
 
62
 
63
  # Extract task ID - IMMEDIATELY
64
  task_id = None
 
 
 
 
 
 
65
 
66
  # Try different response formats
67
  if "taskId" in data:
@@ -97,7 +215,7 @@ def submit_song_generation(lyrics_text, style, title, instrumental, model):
97
  except Exception as e:
98
  return f"❌ Error: {str(e)}", ""
99
 
100
- def check_song_status(task_id):
101
  """Check song generation status - RETURNS DOWNLOAD LINKS"""
102
  if not task_id:
103
  return "❌ Please enter a Task ID", ""
@@ -115,7 +233,7 @@ def check_song_status(task_id):
115
 
116
  data = resp.json()
117
 
118
- # RAW JSON for debugging
119
  raw_json = f"```json\n{json.dumps(data, indent=2)}\n```"
120
 
121
  if data.get("code") != 200:
@@ -129,6 +247,7 @@ def check_song_status(task_id):
129
  output += f"**Status:** {status}\n"
130
 
131
  if status == "TEXT_SUCCESS":
 
132
  response_data = task_data.get("response", {})
133
  songs = response_data.get("sunoData", [])
134
 
@@ -138,6 +257,8 @@ def check_song_status(task_id):
138
  return output, raw_json
139
 
140
  output += f"## 🎵 SONGS READY! ({len(songs)} tracks)\n\n"
 
 
141
 
142
  for i, song in enumerate(songs, 1):
143
  output += f"### Track {i}\n"
@@ -145,14 +266,19 @@ def check_song_status(task_id):
145
 
146
  # Get all possible URLs
147
  audio_url = song.get('audioUrl')
148
- stream_url = song.get('streamAudioUrl') or song.get('stream_url')
 
 
 
 
 
149
 
150
  # Best URL for listening
151
- best_url = audio_url or stream_url
152
 
153
  if best_url:
154
  output += f"**🎧 Listen Now:** [Click to Play]({best_url})\n"
155
- # Audio player for HTML
156
  output += f"""<audio controls style="width: 100%; margin: 10px 0;">
157
  <source src="{best_url}" type="audio/mpeg">
158
  Your browser does not support audio.
@@ -164,17 +290,48 @@ def check_song_status(task_id):
164
  elif stream_url:
165
  output += f"**💾 Download:** [Stream MP3]({stream_url})\n"
166
 
 
 
 
167
  output += f"**ID:** `{song.get('id', 'N/A')}`\n"
168
  output += f"**Model:** {song.get('modelName', 'N/A')}\n"
169
  output += f"**Tags:** {song.get('tags', 'N/A')}\n"
 
 
 
 
 
 
 
170
 
171
  output += "\n---\n\n"
172
 
 
173
  output += f"**✅ Generation complete!**\n\n"
 
 
 
 
174
 
175
  elif status in ["PENDING", "PROCESSING", "RUNNING"]:
176
  output += f"\n**⏳ Song is still being generated...**\n"
177
  output += "Check again in 30-60 seconds\n"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
 
179
  elif status == "SUCCESS":
180
  output += f"\n**✅ Generation succeeded!**\n"
@@ -183,12 +340,16 @@ def check_song_status(task_id):
183
  elif status == "FAILED":
184
  error_msg = task_data.get("errorMessage", "Unknown error")
185
  output += f"\n**❌ Generation failed:** {error_msg}\n"
 
186
 
187
  else:
188
  output += f"\n**⚠️ Unknown status:** {status}\n"
189
  output += "Check raw data below\n"
190
 
191
- output += f"\n**🔗 Viewer:** [https://1hit.no/viewer.php?task_id={task_id}](https://1hit.no/viewer.php?task_id={task_id})\n"
 
 
 
192
 
193
  return output, raw_json
194
 
@@ -197,7 +358,7 @@ def check_song_status(task_id):
197
 
198
  # Create the app
199
  with gr.Blocks() as app:
200
- gr.Markdown("# 🎵 Suno Song Generator + Player")
201
 
202
  # Store current task ID
203
  current_task_id = gr.State(value="")
@@ -206,14 +367,21 @@ with gr.Blocks() as app:
206
  with gr.Row():
207
  with gr.Column(scale=1):
208
  # Inputs
 
 
209
  lyrics_text = gr.Textbox(
210
  label="Lyrics (leave empty for instrumental)",
211
  placeholder="[Verse 1]\nType your lyrics here...",
212
  lines=8
 
213
  )
214
 
 
 
 
215
  style = gr.Textbox(
216
  label="Music Style",
 
217
  value="Pop",
218
  placeholder="e.g., Rock, Jazz, Electronic"
219
  )
@@ -221,18 +389,28 @@ with gr.Blocks() as app:
221
  title = gr.Textbox(
222
  label="Song Title",
223
  value="My Song"
 
 
224
  )
225
 
226
  with gr.Row():
227
  instrumental = gr.Checkbox(label="Instrumental Only")
 
 
 
 
228
  model = gr.Dropdown(
 
229
  choices=["V5", "V4_5PLUS", "V4_5ALL", "V4_5", "V4"],
230
  value="V4_5ALL",
231
  label="Model"
232
  )
233
 
234
  submit_btn = gr.Button("🚀 Generate Song", variant="primary")
 
 
235
 
 
236
  gr.Markdown("""
237
  **Instructions:**
238
  1. Enter lyrics (or blank for instrumental)
@@ -240,6 +418,11 @@ with gr.Blocks() as app:
240
  3. Click Generate
241
  4. **Copy the Task ID**
242
  5. Check status in next tab
 
 
 
 
 
243
  """)
244
 
245
  with gr.Column(scale=2):
@@ -252,6 +435,7 @@ with gr.Blocks() as app:
252
  with gr.Row():
253
  with gr.Column(scale=1):
254
  gr.Markdown("### Check Song Status")
 
255
 
256
  # Task ID input (auto-fills from generation)
257
  status_task_id = gr.Textbox(
@@ -261,6 +445,7 @@ with gr.Blocks() as app:
261
  )
262
 
263
  check_btn = gr.Button("🔍 Check Status Now", variant="primary")
 
264
 
265
  gr.Markdown("""
266
  **What to expect:**
@@ -281,46 +466,29 @@ with gr.Blocks() as app:
281
  value="*Raw JSON will appear here when you check status*"
282
  )
283
 
284
- with gr.Tab("🎧 Music Player"):
285
- with gr.Row():
286
- with gr.Column(scale=1):
287
- gr.Markdown("### Music Player")
288
- gr.Markdown("Play any MP3 URL or use the default track")
289
-
290
- music_url = gr.Textbox(
291
- label="MP3 URL",
292
- value="https://huggingface.co/spaces/MySafeCode/SUNO-API-V5/resolve/main/Gnomes%20remember.mp3",
293
- info="Enter any direct MP3 URL"
294
- )
295
-
296
- play_btn = gr.Button("▶️ Play This URL", variant="primary")
297
- reset_btn = gr.Button("🔄 Reset to Default", variant="secondary")
298
-
299
- gr.Markdown("""
300
- **Features:**
301
- - Play any public MP3 URL
302
- - Default: "Gnomes remember" track
303
- - Volume control
304
- - Play/pause/seek
305
- """)
306
-
307
- with gr.Column(scale=2):
308
- # Audio player HTML
309
- audio_display = gr.HTML(
310
- value="""<div>
311
- <audio id="mainPlayer" controls style="width: 100%; height: 60px; margin: 20px 0;">
312
- <source src="https://huggingface.co/spaces/MySafeCode/SUNO-API-V5/resolve/main/Gnomes%20remember.mp3" type="audio/mpeg">
313
- Your browser does not support audio.
314
- </audio>
315
- <div style="margin: 10px 0; padding: 10px; background: #f5f5f5; border-radius: 5px;">
316
- <strong>Now Playing:</strong> Gnomes remember.mp3
317
- </div>
318
- </div>"""
319
- )
320
-
321
  with gr.Tab("📋 Instructions"):
322
  gr.Markdown("""
323
  ## 🎵 Complete Workflow
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
324
 
325
  ### 1. Generate Song
326
  - Enter lyrics & settings
@@ -328,28 +496,52 @@ with gr.Blocks() as app:
328
  - **IMMEDIATELY get a Task ID**
329
  - Copy the Task ID
330
 
331
- ### 2. Check Status
332
  - Switch to **Check Status** tab
333
  - Task ID auto-fills
334
  - Click **Check Status Now**
335
  - Wait for **TEXT_SUCCESS** status
336
 
337
- ### 3. Play Music
338
- - Use **Music Player** tab:
339
- - Default track plays automatically
340
- - Paste any MP3 URL to play
341
- - Works with your generated songs!
 
 
 
 
 
 
 
342
 
343
- ### 4. Player Features
344
- - **Default track**: Gnomes remember.mp3
345
- - **Any MP3 URL**: Paste and play
346
- - **From Suno**: Use streamAudioUrl
347
- - **Volume control**: Use player controls
 
 
 
 
 
348
  """)
349
 
350
  # Auto-fill status tab with task ID
351
  def update_status_field(task_id):
352
  return task_id
 
 
 
 
 
 
 
 
 
 
 
 
353
 
354
  current_task_id.change(
355
  fn=update_status_field,
@@ -361,8 +553,8 @@ with gr.Blocks() as app:
361
  def on_generate(lyrics, style, title, instrumental, model):
362
  output, task_id = submit_song_generation(lyrics, style, title, instrumental, model)
363
  if task_id:
364
- return output, task_id, task_id
365
- return output, "", ""
366
 
367
  submit_btn.click(
368
  fn=on_generate,
@@ -371,60 +563,24 @@ with gr.Blocks() as app:
371
  )
372
 
373
  # Check status
374
- def on_check(task_id):
375
- output, raw = check_song_status(task_id)
376
  return output, raw
 
 
 
 
377
 
378
  check_btn.click(
379
  fn=on_check,
380
- inputs=[status_task_id],
381
  outputs=[status_output, raw_output]
382
  )
383
-
384
- # Music player controls
385
- def play_music(url):
386
- if not url.strip():
387
- url = "https://huggingface.co/spaces/MySafeCode/SUNO-API-V5/resolve/main/Gnomes%20remember.mp3"
388
-
389
- # Create HTML with the new URL
390
- html = f"""<div>
391
- <audio id="mainPlayer" controls style="width: 100%; height: 60px; margin: 20px 0;">
392
- <source src="{url}" type="audio/mpeg">
393
- Your browser does not support audio.
394
- </audio>
395
- <div style="margin: 10px 0; padding: 10px; background: #f5f5f5; border-radius: 5px;">
396
- <strong>Now Playing:</strong> {url.split('/')[-1].replace('%20', ' ')}
397
- </div>
398
- </div>"""
399
- return html
400
-
401
- play_btn.click(
402
- fn=play_music,
403
- inputs=[music_url],
404
- outputs=[audio_display]
405
- )
406
-
407
- def reset_music():
408
- url = "https://huggingface.co/spaces/MySafeCode/SUNO-API-V5/resolve/main/Gnomes%20remember.mp3"
409
- html = f"""<div>
410
- <audio id="mainPlayer" controls style="width: 100%; height: 60px; margin: 20px 0;">
411
- <source src="{url}" type="audio/mpeg">
412
- Your browser does not support audio.
413
- </audio>
414
- <div style="margin: 10px 0; padding: 10px; background: #f5f5f5; border-radius: 5px;">
415
- <strong>Now Playing:</strong> Gnomes remember.mp3
416
- </div>
417
- </div>"""
418
- return html, url
419
-
420
- reset_btn.click(
421
- fn=reset_music,
422
- outputs=[audio_display, music_url]
423
- )
424
 
425
- # Launch the app
426
  if __name__ == "__main__":
427
  print("🚀 Starting Suno Song Generator")
428
  print(f"🔑 SunoKey: {'✅ Set' if SUNO_KEY else '❌ Not set'}")
429
  print("🌐 Open your browser to: http://localhost:7860")
 
430
  app.launch(server_name="0.0.0.0", server_port=7860, share=False)
 
1
  import gradio as gr
2
  import requests
3
  import os
4
+
5
  import json
6
 
7
  # Suno API key
 
8
  if not SUNO_KEY:
9
  print("⚠️ SunoKey not set!")
10
 
11
  def submit_song_generation(lyrics_text, style, title, instrumental, model):
12
  """Submit song generation request - IMMEDIATE RESPONSE WITH TASK ID"""
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
  if not SUNO_KEY:
124
  return "❌ Error: SunoKey not configured", ""
125
+
126
 
127
  if not lyrics_text.strip() and not instrumental:
128
  return "❌ Error: Please provide lyrics or select instrumental", ""
129
+
130
 
131
  if not style.strip():
132
  return "❌ Error: Please provide a music style", ""
133
+
134
 
135
  if not title.strip():
136
  return "❌ Error: Please provide a song title", ""
137
+
138
 
139
  try:
140
  # Prepare request data
 
 
 
 
 
 
 
 
 
 
141
  # Apply character limits
142
  if model == "V4" and len(lyrics_text) > 3000:
143
  lyrics_text = lyrics_text[:3000]
144
+
145
  elif model in ["V4_5", "V4_5PLUS", "V4_5ALL", "V5"] and len(lyrics_text) > 5000:
146
  lyrics_text = lyrics_text[:5000]
147
+
148
 
149
  request_data["prompt"] = lyrics_text
150
  else:
 
163
 
164
  if resp.status_code != 200:
165
  return f"❌ Submission failed: HTTP {resp.status_code}\n\n{resp.text}", ""
166
+
167
+
168
+
169
+
170
+
171
 
172
  data = resp.json()
173
+
174
 
175
  # Extract task ID - IMMEDIATELY
176
  task_id = None
177
+
178
+
179
+
180
+
181
+
182
+
183
 
184
  # Try different response formats
185
  if "taskId" in data:
 
215
  except Exception as e:
216
  return f"❌ Error: {str(e)}", ""
217
 
218
+ def check_song_status(task_id, show_raw=False):
219
  """Check song generation status - RETURNS DOWNLOAD LINKS"""
220
  if not task_id:
221
  return "❌ Please enter a Task ID", ""
 
233
 
234
  data = resp.json()
235
 
236
+ # RAW JSON for debugging (always stored, shown if requested)
237
  raw_json = f"```json\n{json.dumps(data, indent=2)}\n```"
238
 
239
  if data.get("code") != 200:
 
247
  output += f"**Status:** {status}\n"
248
 
249
  if status == "TEXT_SUCCESS":
250
+ # This is the key status! Songs are ready!
251
  response_data = task_data.get("response", {})
252
  songs = response_data.get("sunoData", [])
253
 
 
257
  return output, raw_json
258
 
259
  output += f"## 🎵 SONGS READY! ({len(songs)} tracks)\n\n"
260
+
261
+
262
 
263
  for i, song in enumerate(songs, 1):
264
  output += f"### Track {i}\n"
 
266
 
267
  # Get all possible URLs
268
  audio_url = song.get('audioUrl')
269
+ stream_url = song.get('streamAudioUrl') or song.get('streamAudioURL') or song.get('stream_url')
270
+ source_stream = song.get('sourceStreamAudioUrl')
271
+ source_audio = song.get('sourceAudioUrl')
272
+
273
+ # Image URL
274
+ image_url = song.get('imageUrl') or song.get('sourceImageUrl')
275
 
276
  # Best URL for listening
277
+ best_url = audio_url or stream_url or source_stream or source_audio
278
 
279
  if best_url:
280
  output += f"**🎧 Listen Now:** [Click to Play]({best_url})\n"
281
+ # Audio player
282
  output += f"""<audio controls style="width: 100%; margin: 10px 0;">
283
  <source src="{best_url}" type="audio/mpeg">
284
  Your browser does not support audio.
 
290
  elif stream_url:
291
  output += f"**💾 Download:** [Stream MP3]({stream_url})\n"
292
 
293
+ if image_url:
294
+ output += f"**🖼️ Cover Art:** [View Image]({image_url})\n"
295
+
296
  output += f"**ID:** `{song.get('id', 'N/A')}`\n"
297
  output += f"**Model:** {song.get('modelName', 'N/A')}\n"
298
  output += f"**Tags:** {song.get('tags', 'N/A')}\n"
299
+ if song.get('duration'):
300
+ output += f"**Duration:** {song.get('duration')}s\n"
301
+
302
+ # Show first 200 chars of prompt
303
+ prompt = song.get('prompt', '')
304
+ if prompt:
305
+ output += f"**Preview:** {prompt[:200]}...\n"
306
 
307
  output += "\n---\n\n"
308
 
309
+ # Summary
310
  output += f"**✅ Generation complete!**\n\n"
311
+ output += "**To save your songs:**\n"
312
+ output += "1. Right-click 'Listen Now' links → 'Save link as...'\n"
313
+ output += "2. Or use the download links above\n"
314
+ output += "3. Note the Track IDs for reference\n"
315
 
316
  elif status in ["PENDING", "PROCESSING", "RUNNING"]:
317
  output += f"\n**⏳ Song is still being generated...**\n"
318
  output += "Check again in 30-60 seconds\n"
319
+ output += f"This usually takes 1-3 minutes total\n"
320
+
321
+
322
+
323
+
324
+
325
+
326
+
327
+
328
+
329
+
330
+
331
+
332
+
333
+
334
+
335
 
336
  elif status == "SUCCESS":
337
  output += f"\n**✅ Generation succeeded!**\n"
 
340
  elif status == "FAILED":
341
  error_msg = task_data.get("errorMessage", "Unknown error")
342
  output += f"\n**❌ Generation failed:** {error_msg}\n"
343
+
344
 
345
  else:
346
  output += f"\n**⚠️ Unknown status:** {status}\n"
347
  output += "Check raw data below\n"
348
 
349
+ # Always show premium info
350
+ output += f"\n**💡 Tip:** Songs may take 2-3 minutes to fully process\n"
351
+ output += f"**📞 Callback sent to:** https://1hit.no/callback.php\n"
352
+ output += f"**🔗 Viewer:** [https://1hit.no/viewer.php?task_id={task_id}](https://1hit.no/viewer.php?task_id={task_id})\n"
353
 
354
  return output, raw_json
355
 
 
358
 
359
  # Create the app
360
  with gr.Blocks() as app:
361
+ gr.Markdown("# 🎵 Suno Song Generator")
362
 
363
  # Store current task ID
364
  current_task_id = gr.State(value="")
 
367
  with gr.Row():
368
  with gr.Column(scale=1):
369
  # Inputs
370
+
371
+
372
  lyrics_text = gr.Textbox(
373
  label="Lyrics (leave empty for instrumental)",
374
  placeholder="[Verse 1]\nType your lyrics here...",
375
  lines=8
376
+
377
  )
378
 
379
+
380
+
381
+
382
  style = gr.Textbox(
383
  label="Music Style",
384
+
385
  value="Pop",
386
  placeholder="e.g., Rock, Jazz, Electronic"
387
  )
 
389
  title = gr.Textbox(
390
  label="Song Title",
391
  value="My Song"
392
+
393
+
394
  )
395
 
396
  with gr.Row():
397
  instrumental = gr.Checkbox(label="Instrumental Only")
398
+
399
+
400
+
401
+
402
  model = gr.Dropdown(
403
+
404
  choices=["V5", "V4_5PLUS", "V4_5ALL", "V4_5", "V4"],
405
  value="V4_5ALL",
406
  label="Model"
407
  )
408
 
409
  submit_btn = gr.Button("🚀 Generate Song", variant="primary")
410
+
411
+
412
 
413
+
414
  gr.Markdown("""
415
  **Instructions:**
416
  1. Enter lyrics (or blank for instrumental)
 
418
  3. Click Generate
419
  4. **Copy the Task ID**
420
  5. Check status in next tab
421
+
422
+
423
+
424
+
425
+
426
  """)
427
 
428
  with gr.Column(scale=2):
 
435
  with gr.Row():
436
  with gr.Column(scale=1):
437
  gr.Markdown("### Check Song Status")
438
+
439
 
440
  # Task ID input (auto-fills from generation)
441
  status_task_id = gr.Textbox(
 
445
  )
446
 
447
  check_btn = gr.Button("🔍 Check Status Now", variant="primary")
448
+ auto_check = gr.Checkbox(label="Auto-check every 30s", value=False)
449
 
450
  gr.Markdown("""
451
  **What to expect:**
 
466
  value="*Raw JSON will appear here when you check status*"
467
  )
468
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
469
  with gr.Tab("📋 Instructions"):
470
  gr.Markdown("""
471
  ## 🎵 Complete Workflow
472
+
473
+
474
+
475
+
476
+
477
+
478
+
479
+
480
+
481
+
482
+
483
+
484
+
485
+
486
+
487
+
488
+
489
+
490
+
491
+
492
 
493
  ### 1. Generate Song
494
  - Enter lyrics & settings
 
496
  - **IMMEDIATELY get a Task ID**
497
  - Copy the Task ID
498
 
499
+ ### 2. Check Status
500
  - Switch to **Check Status** tab
501
  - Task ID auto-fills
502
  - Click **Check Status Now**
503
  - Wait for **TEXT_SUCCESS** status
504
 
505
+ ### 3. Download Songs
506
+ - When **TEXT_SUCCESS** appears:
507
+ - **Listen Now** links with audio players
508
+ - **Download** links for MP3 files
509
+ - Cover art images
510
+ - Track IDs for reference
511
+
512
+ ### 4. Tips
513
+ - Processing: **1-3 minutes**
514
+ - Check every **30 seconds**
515
+ - Use **Auto-check** for convenience
516
+ - Raw data available for debugging
517
 
518
+ ### 5. Status Meanings
519
+ - **TEXT_SUCCESS**: Songs ready!
520
+ - **PENDING/PROCESSING**: Still working
521
+ - **SUCCESS**: Check raw data
522
+ - **FAILED**: Try again
523
+
524
+ ### 6. Callback System
525
+ - Results also sent to: https://1hit.no/callback.php
526
+ - View all results: https://1hit.no/viewer.php
527
+
528
  """)
529
 
530
  # Auto-fill status tab with task ID
531
  def update_status_field(task_id):
532
  return task_id
533
+
534
+
535
+
536
+
537
+
538
+
539
+
540
+
541
+
542
+
543
+
544
+
545
 
546
  current_task_id.change(
547
  fn=update_status_field,
 
553
  def on_generate(lyrics, style, title, instrumental, model):
554
  output, task_id = submit_song_generation(lyrics, style, title, instrumental, model)
555
  if task_id:
556
+ return output, task_id, task_id # Also updates status_task_id
557
+ return output, "", "" # Clear if error
558
 
559
  submit_btn.click(
560
  fn=on_generate,
 
563
  )
564
 
565
  # Check status
566
+ def on_check(task_id, show_raw):
567
+ output, raw = check_song_status(task_id, show_raw)
568
  return output, raw
569
+
570
+
571
+
572
+
573
 
574
  check_btn.click(
575
  fn=on_check,
576
+ inputs=[status_task_id, gr.State(True)], # Always show raw
577
  outputs=[status_output, raw_output]
578
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
579
 
580
+
581
  if __name__ == "__main__":
582
  print("🚀 Starting Suno Song Generator")
583
  print(f"🔑 SunoKey: {'✅ Set' if SUNO_KEY else '❌ Not set'}")
584
  print("🌐 Open your browser to: http://localhost:7860")
585
+
586
  app.launch(server_name="0.0.0.0", server_port=7860, share=False)