Phoenixak99 commited on
Commit
9861c54
Β·
verified Β·
1 Parent(s): f24eb2e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +69 -42
app.py CHANGED
@@ -268,15 +268,40 @@ energy_level = st.radio("Energy Level:", energy_levels, horizontal=True)
268
  description = st.text_input("Description:", "")
269
  tempo = st.slider("Tempo (in bpm):", min_value=40, max_value=100, value=60, step=5)
270
 
271
- # Always show the full duration slider initially
272
- duration = st.slider(
273
- "Duration (in seconds):",
274
- min_value=15,
275
- max_value=300,
276
- value=30,
277
- step=1
278
- )
279
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
 
281
 
282
  def convert_audio_segment_to_float_array(audio_pydub):
@@ -351,28 +376,32 @@ def wait_for_server_warmup(status_placeholder, progress_placeholder, subscriptio
351
  ### πŸ“‹ **Subscription Tiers**
352
 
353
  **Free User**
354
- - 🎡 **Generations:** 3 music generations per month.
355
- - πŸ“₯ **Downloads:** No downloads allowed.
356
- - ⏳ **Wait Time:** Up to 7 minutes when the server is inactive.
357
-
358
- **Tier 2 - $19.99/month**
359
- - 🎡 **Generations:** Up to 3 music generations per day.
360
- - πŸ“₯ **Downloads:** 3 downloads per month.
361
- - ⚑ **Reduced Wait Times:** The server stays active longer, minimizing wait times.
362
-
363
- **Tier 3 - $99/month**
364
- - 🎡 **Generations:** Up to 5 music generations per day.
365
- - πŸ“₯ **Downloads:** 5 downloads per month.
366
- - ⚑ **Minimal Wait Times:** Increased server uptime for faster access.
367
-
368
- **Tier 4 - $499/month**
369
- - 🎡 **Generations:** Up to 20 music generations per day.
370
- - πŸ“₯ **Downloads:** 20 downloads per month.
371
- - πŸš€ **Instant Access:** Server is always active for immediate use.
 
 
 
 
 
372
 
373
  ### πŸš€ **Why Subscribe?**
374
- Subscribing helps keep the server active, reducing or eliminating wait times due to server startup.
375
- Enjoy faster access and a smoother experience with a premium subscription!
376
  """
377
 
378
  start_time = time.time()
@@ -441,19 +470,17 @@ def generate_audio(genre, energy_level, tempo, description, duration):
441
  subscription_data = subscription_response.json()
442
 
443
  # Check for free tier duration restriction
444
- is_free_tier = subscription_data.get("subscription_tier") == "free"
445
- if is_free_tier and duration > 30:
446
- st.warning("⚠️ Free tier users are limited to 30-second generations.")
447
- st.info("πŸ’‘ Upgrade to a premium plan to generate longer tracks!\n\nπŸ‘‰ [Upgrade Now](https://songlabai.com/subscribe/)")
448
- duration = 30 # Force duration to 30 seconds for free tier
449
-
450
- if subscription_data["has_exceeded_generation_limit"]:
451
- st.error(
452
- "You have reached your generation limit. "
453
- "Please upgrade your subscription for additional access.\n\n"
454
- "οΏ½οΏ½οΏ½ [Upgrade Now](https://songlabai.com/subscribe/)"
455
- )
456
- return
457
 
458
  # Check if server is cold
459
  if not check_server_status():
 
268
  description = st.text_input("Description:", "")
269
  tempo = st.slider("Tempo (in bpm):", min_value=40, max_value=100, value=60, step=5)
270
 
271
+ # First, check subscription status if user is logged in
272
+ if st.session_state.get("jwt_token"):
273
+ auth_headers = get_auth_headers()
274
+ subscription_url = "https://songlabai.com/wp-json/custom-api/v1/subscription"
275
+ subscription_response = requests.get(subscription_url, headers=auth_headers)
276
+
277
+ if subscription_response.status_code == 200:
278
+ subscription_data = subscription_response.json()
279
+ subscription_plan_id = subscription_data.get("subscription_plan_id")
280
+ # Free tier has plan ID 576 or null
281
+ is_free_tier = not subscription_plan_id or subscription_plan_id == 576
282
+ else:
283
+ is_free_tier = True # Default to free tier if unable to verify
284
+ else:
285
+ is_free_tier = True # Default to free tier if not logged in
286
+
287
+ # Show appropriate duration slider based on subscription tier
288
+ if is_free_tier:
289
+ duration = st.slider(
290
+ "Duration (in seconds):",
291
+ min_value=15,
292
+ max_value=30, # Restricted to 30 seconds for free tier
293
+ value=30,
294
+ step=1,
295
+ help="Free tier users are limited to 30-second generations. Upgrade to create longer tracks!"
296
+ )
297
+ else:
298
+ duration = st.slider(
299
+ "Duration (in seconds):",
300
+ min_value=15,
301
+ max_value=300,
302
+ value=30,
303
+ step=1
304
+ )
305
 
306
 
307
  def convert_audio_segment_to_float_array(audio_pydub):
 
376
  ### πŸ“‹ **Subscription Tiers**
377
 
378
  **Free User**
379
+ - 🎡 **Generations:** 3 music generations
380
+ - πŸ“₯ **Downloads:** No downloads allowed
381
+ - 🎼 **Submit your track from dashboard**
382
+ - πŸ’° **Receive 50% commission**
383
+ - πŸ’΅ **Tracks sale for $1 on website**
384
+
385
+ **Tier 2 - $24.99/month**
386
+ - 🎡 **Generations:** Up to 3 music generations per day
387
+ - πŸ“₯ **Downloads:** 1 download per month
388
+ - πŸ”’ **Private Tracks:** Create unpublished, private tracks
389
+ - πŸ“Š **Dashboard:** Access your profile and save up to 2 tracks
390
+
391
+ **Tier 3 - $99.99/month**
392
+ - 🎡 **Generations:** Up to 5 music generations per day
393
+ - πŸ“₯ **Downloads:** 5 downloads per month
394
+ - πŸ“Š **Dashboard:** Full profile access for managing and saving your tracks
395
+ - πŸ’Ύ **Storage:** Save up to 10 tracks
396
+
397
+ **Tier 4 - $269.97/month**
398
+ - 🎡 **Generations:** Up to 20 music generations per day
399
+ - πŸ“₯ **Downloads:** 15 downloads per month
400
+ - 🏒 **Commercial Use:** Includes rights for commercial purposes
401
+ - πŸ“Š **Dashboard:** Advanced profile management for commercial accounts
402
 
403
  ### πŸš€ **Why Subscribe?**
404
+ Upgrade now to unlock more features and enhance your music creation experience!
 
405
  """
406
 
407
  start_time = time.time()
 
470
  subscription_data = subscription_response.json()
471
 
472
  # Check for free tier duration restriction
473
+ is_free_tier = not subscription_plan_id or subscription_plan_id == 576
474
+ if is_free_tier:
475
+ if duration > 30:
476
+ st.warning("⚠️ Free tier users are limited to 30-second generations.")
477
+ st.info("πŸ’‘ Upgrade to a premium plan to generate longer tracks!\n\n" +
478
+ "**Available Plans:**\n" +
479
+ "- **$24.99/month:** Up to 3 generations per day, 1 download per month\n" +
480
+ "- **$99.99/month:** Up to 5 generations per day, 5 downloads per month\n" +
481
+ "- **$269.97/month:** Up to 20 generations per day, 15 downloads per month\n\n" +
482
+ "πŸ‘‰ [Upgrade Now](https://songlabai.com/subscribe/)")
483
+ duration = 30 # Force duration to 30 seconds for free tier
 
 
484
 
485
  # Check if server is cold
486
  if not check_server_status():