Spaces:
Sleeping
Sleeping
Update app_gradio.py
Browse files- app_gradio.py +12 -12
app_gradio.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
"""
|
| 2 |
-
SongLab AI - Gradio Interface
|
| 3 |
Modern, minimalist music generation interface with WordPress integration
|
| 4 |
Includes: Music, Vocals, Video Generation, Audio Effects
|
| 5 |
"""
|
|
@@ -203,7 +203,7 @@ class WordPressAPI:
|
|
| 203 |
}
|
| 204 |
|
| 205 |
def check_audio_eligibility(self, jwt_token: str, duration: int, has_lyrics: bool = False) -> Dict[str, Any]:
|
| 206 |
-
"""Check if user can generate audio (includes
|
| 207 |
try:
|
| 208 |
response = requests.post(
|
| 209 |
f"{self.base_url}/wp-json/audio-api/v1/check-eligibility",
|
|
@@ -215,12 +215,12 @@ class WordPressAPI:
|
|
| 215 |
return response.json()
|
| 216 |
except Exception as e:
|
| 217 |
print(f"Error checking audio eligibility: {e}")
|
| 218 |
-
# On error, allow
|
| 219 |
return {
|
| 220 |
'can_generate': True,
|
| 221 |
'reason': 'error_fallback',
|
| 222 |
'uses_credit': False,
|
| 223 |
-
'free_samples_remaining':
|
| 224 |
'remaining_credits': 0
|
| 225 |
}
|
| 226 |
|
|
@@ -239,16 +239,16 @@ class WordPressAPI:
|
|
| 239 |
return {}
|
| 240 |
|
| 241 |
def check_video_eligibility(self, jwt_token: str, is_custom_mode: bool = False) -> Dict[str, Any]:
|
| 242 |
-
"""Check if user can generate videos (includes
|
| 243 |
try:
|
| 244 |
# Get video credits
|
| 245 |
video_credits = self.get_video_credits(jwt_token)
|
| 246 |
-
|
| 247 |
if not video_credits:
|
| 248 |
-
# If API fails, allow
|
| 249 |
return {
|
| 250 |
'can_generate': True,
|
| 251 |
-
'free_remaining':
|
| 252 |
'credits': 0,
|
| 253 |
'reason': 'free_generation'
|
| 254 |
}
|
|
@@ -302,10 +302,10 @@ class WordPressAPI:
|
|
| 302 |
|
| 303 |
except Exception as e:
|
| 304 |
print(f"Error checking video eligibility: {e}")
|
| 305 |
-
# On error, allow
|
| 306 |
return {
|
| 307 |
'can_generate': True,
|
| 308 |
-
'free_remaining':
|
| 309 |
'credits': 0,
|
| 310 |
'reason': 'error_fallback'
|
| 311 |
}
|
|
@@ -1292,7 +1292,7 @@ def generate_commercial_ad(
|
|
| 1292 |
|
| 1293 |
error_msg = f"β Cannot generate video: {reason}"
|
| 1294 |
if free_remaining == 0 and credits == 0:
|
| 1295 |
-
error_msg += "\n\nπ‘ You have
|
| 1296 |
error_msg += "\nπ¦ Or purchase credits at https://songlabai.com/credit-pricing/"
|
| 1297 |
|
| 1298 |
return None, error_msg
|
|
@@ -1594,7 +1594,7 @@ def create_ui():
|
|
| 1594 |
# Tab 1: Music Generation
|
| 1595 |
with gr.Tab("π΅ Generate Music"):
|
| 1596 |
gr.Markdown("### Create Your Track")
|
| 1597 |
-
gr.Markdown("*π
|
| 1598 |
|
| 1599 |
with gr.Row():
|
| 1600 |
with gr.Column(scale=2):
|
|
|
|
| 1 |
"""
|
| 2 |
+
SongLab AI - Gradio Interface
|
| 3 |
Modern, minimalist music generation interface with WordPress integration
|
| 4 |
Includes: Music, Vocals, Video Generation, Audio Effects
|
| 5 |
"""
|
|
|
|
| 203 |
}
|
| 204 |
|
| 205 |
def check_audio_eligibility(self, jwt_token: str, duration: int, has_lyrics: bool = False) -> Dict[str, Any]:
|
| 206 |
+
"""Check if user can generate audio (includes 1 free sample)"""
|
| 207 |
try:
|
| 208 |
response = requests.post(
|
| 209 |
f"{self.base_url}/wp-json/audio-api/v1/check-eligibility",
|
|
|
|
| 215 |
return response.json()
|
| 216 |
except Exception as e:
|
| 217 |
print(f"Error checking audio eligibility: {e}")
|
| 218 |
+
# On error, allow 1 free sample as fallback
|
| 219 |
return {
|
| 220 |
'can_generate': True,
|
| 221 |
'reason': 'error_fallback',
|
| 222 |
'uses_credit': False,
|
| 223 |
+
'free_samples_remaining': 1,
|
| 224 |
'remaining_credits': 0
|
| 225 |
}
|
| 226 |
|
|
|
|
| 239 |
return {}
|
| 240 |
|
| 241 |
def check_video_eligibility(self, jwt_token: str, is_custom_mode: bool = False) -> Dict[str, Any]:
|
| 242 |
+
"""Check if user can generate videos (includes 1 free preset generation)"""
|
| 243 |
try:
|
| 244 |
# Get video credits
|
| 245 |
video_credits = self.get_video_credits(jwt_token)
|
| 246 |
+
|
| 247 |
if not video_credits:
|
| 248 |
+
# If API fails, allow 1 free generation as fallback
|
| 249 |
return {
|
| 250 |
'can_generate': True,
|
| 251 |
+
'free_remaining': 1,
|
| 252 |
'credits': 0,
|
| 253 |
'reason': 'free_generation'
|
| 254 |
}
|
|
|
|
| 302 |
|
| 303 |
except Exception as e:
|
| 304 |
print(f"Error checking video eligibility: {e}")
|
| 305 |
+
# On error, allow 1 free generation as fallback
|
| 306 |
return {
|
| 307 |
'can_generate': True,
|
| 308 |
+
'free_remaining': 1,
|
| 309 |
'credits': 0,
|
| 310 |
'reason': 'error_fallback'
|
| 311 |
}
|
|
|
|
| 1292 |
|
| 1293 |
error_msg = f"β Cannot generate video: {reason}"
|
| 1294 |
if free_remaining == 0 and credits == 0:
|
| 1295 |
+
error_msg += "\n\nπ‘ You have 1 FREE generation with PRESET mode (non-custom settings)!"
|
| 1296 |
error_msg += "\nπ¦ Or purchase credits at https://songlabai.com/credit-pricing/"
|
| 1297 |
|
| 1298 |
return None, error_msg
|
|
|
|
| 1594 |
# Tab 1: Music Generation
|
| 1595 |
with gr.Tab("π΅ Generate Music"):
|
| 1596 |
gr.Markdown("### Create Your Track")
|
| 1597 |
+
gr.Markdown("*π 1 free sample! Pay $5 to download or purchase credits for unlimited downloads.*")
|
| 1598 |
|
| 1599 |
with gr.Row():
|
| 1600 |
with gr.Column(scale=2):
|