Phoenixak99 commited on
Commit
75710eb
·
verified ·
1 Parent(s): d560989

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -7
app.py CHANGED
@@ -268,13 +268,50 @@ 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
- # Duration input
272
- duration = st.slider(
273
- "Duration (in seconds):", min_value=15, max_value=300, value=30, step=1
274
- )
275
-
276
- prompt2 = "Classical ,Low, 40, slow calm"
277
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
278
 
279
 
280
 
@@ -438,6 +475,14 @@ def generate_audio(genre, energy_level, tempo, description, duration):
438
  return
439
 
440
  subscription_data = subscription_response.json()
 
 
 
 
 
 
 
 
441
  if subscription_data["has_exceeded_generation_limit"]:
442
  st.error(
443
  "You have reached your generation limit. "
 
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
+ # Also update the duration slider to show the restriction
272
+ if "jwt_token" in st.session_state:
273
+ auth_headers = get_auth_headers()
274
+ subscription_url = "https://songlabai.com/wp-json/custom-api/v1/subscription"
275
+ try:
276
+ subscription_response = requests.get(subscription_url, headers=auth_headers)
277
+ if subscription_response.status_code == 200:
278
+ subscription_data = subscription_response.json()
279
+ is_free_tier = subscription_data.get("subscription_tier") == "free"
280
+
281
+ if is_free_tier:
282
+ duration = st.slider(
283
+ "Duration (in seconds):",
284
+ min_value=15,
285
+ max_value=30, # Restrict to 30 seconds for free tier
286
+ value=30,
287
+ step=1,
288
+ help="Free tier users are limited to 30-second generations. Upgrade to create longer tracks!"
289
+ )
290
+ else:
291
+ duration = st.slider(
292
+ "Duration (in seconds):",
293
+ min_value=15,
294
+ max_value=300,
295
+ value=30,
296
+ step=1
297
+ )
298
+ except Exception as e:
299
+ st.error(f"Error checking subscription status: {str(e)}")
300
+ duration = st.slider(
301
+ "Duration (in seconds):",
302
+ min_value=15,
303
+ max_value=300,
304
+ value=30,
305
+ step=1
306
+ )
307
+ else:
308
+ duration = st.slider(
309
+ "Duration (in seconds):",
310
+ min_value=15,
311
+ max_value=300,
312
+ value=30,
313
+ step=1
314
+ )
315
 
316
 
317
 
 
475
  return
476
 
477
  subscription_data = subscription_response.json()
478
+
479
+ # Check for free tier duration restriction
480
+ is_free_tier = subscription_data.get("subscription_tier") == "free"
481
+ if is_free_tier and duration > 30:
482
+ st.warning("⚠️ Free tier users are limited to 30-second generations. Your duration has been automatically adjusted.")
483
+ st.info("💡 Upgrade to a premium plan to generate longer tracks!\n\n👉 [Upgrade Now](https://songlabai.com/subscribe/)")
484
+ duration = 30 # Force duration to 30 seconds for free tier
485
+
486
  if subscription_data["has_exceeded_generation_limit"]:
487
  st.error(
488
  "You have reached your generation limit. "