PyxiLabs commited on
Commit
c759f7b
·
verified ·
1 Parent(s): 9c793a7

Update core/app.py

Browse files
Files changed (1) hide show
  1. core/app.py +24 -51
core/app.py CHANGED
@@ -6,9 +6,6 @@ from pydantic import BaseModel, Field
6
  from typing import Optional
7
  from vocify import generate_speech
8
  import os
9
- from slowapi import Limiter
10
- from slowapi.util import get_remote_address
11
- from slowapi.errors import RateLimitExceeded
12
  from fastapi.middleware.cors import CORSMiddleware
13
 
14
  # Create necessary directories if they don't exist
@@ -22,18 +19,6 @@ app = FastAPI(
22
  swagger_ui_parameters={"favicon": "/static/icon.png"}
23
  )
24
 
25
- # Rate Limiter Setup
26
- limiter = Limiter(key_func=get_remote_address)
27
- app.state.limiter = limiter
28
-
29
- # Rate limit error handler
30
- @app.exception_handler(RateLimitExceeded)
31
- async def rate_limit_exceeded_handler(request: Request, exc: RateLimitExceeded):
32
- return HTTPException(
33
- status_code=429,
34
- detail="Rate limit exceeded. Please try again later."
35
- )
36
-
37
  # Mount static files directory
38
  app.mount("/static", StaticFiles(directory="static"), name="static")
39
 
@@ -48,38 +33,31 @@ MODEL_INFO = {
48
  "owner": "Pyxilabs AI Studio",
49
  "voices": {
50
  # Female Voices
51
- "seraphina": "XB0fDUnXU5powFXDhCwa", # Elegant and sophisticated
52
- "isabella": "LcfcDJNUP1GQjkzn1xUU", # Classic and timeless
53
- "astrid": "jsCqWAovK2LkecY7zXl4", # Strong and Nordic-inspired
54
- "lila": "jBpfuIE2acCO8z3wKNLl", # Playful and charming
55
- "elara": "z9fAnlkpzviPz146aGWa", # Mystical and enchanting
56
- "evelyn": "oWAxZDx7w5VEj9dCyTzz", # Graceful and refined
57
-
58
- # Male Voices
59
- "sebastian": "onwK4e9ZLuTAKqWW03F9", # Strong and authoritative
60
- "finnian": "N2lVS1w4EtoT3dr4eOWO", # Rugged and adventurous
61
- "theodore": "IKne3meq5aSn9XLyUdCD", # Warm and friendly
62
- "magnus": "2EiwWnXFnvU5JabPnv8n", # Bold and powerful
63
- "oliver": "CYw3kZ02Hs0563khs1Fj", # Reliable and approachable
64
- "liam": "g5CIjZEefAph4nQFvHAz", # Modern and confident
65
- "arthur": "SOYHLrjzK2X1ezoPC6cr", # Classic and noble
66
- "elliot": "ZQe5CZNOzWyzPSCn5a3c", # Sophisticated and calm
67
- "nathaniel": "bVMeCyTHy58xNoL34h3p", # Wise and thoughtful
68
-
69
- # Neutral Voices
70
- "rowan": "D38z5RcWu1voky8WS1ja", # Unisex, nature-inspired
71
- "avery": "zcAOhNBS3c14rBihAFp1",
72
  }
73
  }
74
  }
75
 
76
- # Rate limits for free tier
77
- RATE_LIMITS = {
78
- "rpm": 10, # Requests per minute
79
- "rph": 100, # Requests per hour
80
- "rpd": 1000, # Requests per day
81
- }
82
-
83
  # Pydantic model for speech request
84
  class SpeechRequest(BaseModel):
85
  model: Optional[str] = Field(default="Pyx r1-voice")
@@ -89,9 +67,6 @@ class SpeechRequest(BaseModel):
89
  # Endpoint to generate speech
90
  @app.post("/v1/audio/speech")
91
  @app.get("/v1/audio/speech")
92
- @limiter.limit(f"{RATE_LIMITS['rpm']}/minute")
93
- @limiter.limit(f"{RATE_LIMITS['rph']}/hour")
94
- @limiter.limit(f"{RATE_LIMITS['rpd']}/day")
95
  async def create_speech(request: Request, speech_request: SpeechRequest):
96
  try:
97
  if speech_request.model != "Pyx r1-voice":
@@ -127,10 +102,8 @@ async def get_models():
127
  "created": model_data["created"],
128
  "owner": model_data["owner"],
129
  "vocals": [
130
- {
131
- "id": voice_name,
132
- }
133
- for voice_name, voice_id in model_data["voices"].items()
134
  ]
135
  }
136
  models_response.append(model_info)
@@ -151,4 +124,4 @@ async def favicon():
151
  # Run the application
152
  if __name__ == "__main__":
153
  import uvicorn
154
- uvicorn.run(app, host="0.0.0.0", port=7860)
 
6
  from typing import Optional
7
  from vocify import generate_speech
8
  import os
 
 
 
9
  from fastapi.middleware.cors import CORSMiddleware
10
 
11
  # Create necessary directories if they don't exist
 
19
  swagger_ui_parameters={"favicon": "/static/icon.png"}
20
  )
21
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  # Mount static files directory
23
  app.mount("/static", StaticFiles(directory="static"), name="static")
24
 
 
33
  "owner": "Pyxilabs AI Studio",
34
  "voices": {
35
  # Female Voices
36
+ "seraphina": "XB0fDUnXU5powFXDhCwa", # Elegant and sophisticated
37
+ "isabella": "LcfcDJNUP1GQjkzn1xUU", # Classic and timeless
38
+ "astrid": "jsCqWAovK2LkecY7zXl4", # Strong and Nordic-inspired
39
+ "lila": "jBpfuIE2acCO8z3wKNLl", # Playful and charming
40
+ "elara": "z9fAnlkpzviPz146aGWa", # Mystical and enchanting
41
+ "evelyn": "oWAxZDx7w5VEj9dCyTzz", # Graceful and refined
42
+
43
+ # Male Voices
44
+ "sebastian": "onwK4e9ZLuTAKqWW03F9", # Strong and authoritative
45
+ "finnian": "N2lVS1w4EtoT3dr4eOWO", # Rugged and adventurous
46
+ "theodore": "IKne3meq5aSn9XLyUdCD", # Warm and friendly
47
+ "magnus": "2EiwWnXFnvU5JabPnv8n", # Bold and powerful
48
+ "oliver": "CYw3kZ02Hs0563khs1Fj", # Reliable and approachable
49
+ "liam": "g5CIjZEefAph4nQFvHAz", # Modern and confident
50
+ "arthur": "SOYHLrjzK2X1ezoPC6cr", # Classic and noble
51
+ "elliot": "ZQe5CZNOzWyzPSCn5a3c", # Sophisticated and calm
52
+ "nathaniel": "bVMeCyTHy58xNoL34h3p", # Wise and thoughtful
53
+
54
+ # Neutral Voices
55
+ "rowan": "D38z5RcWu1voky8WS1ja", # Unisex, nature-inspired
56
+ "avery": "zcAOhNBS3c14rBihAFp1",
57
  }
58
  }
59
  }
60
 
 
 
 
 
 
 
 
61
  # Pydantic model for speech request
62
  class SpeechRequest(BaseModel):
63
  model: Optional[str] = Field(default="Pyx r1-voice")
 
67
  # Endpoint to generate speech
68
  @app.post("/v1/audio/speech")
69
  @app.get("/v1/audio/speech")
 
 
 
70
  async def create_speech(request: Request, speech_request: SpeechRequest):
71
  try:
72
  if speech_request.model != "Pyx r1-voice":
 
102
  "created": model_data["created"],
103
  "owner": model_data["owner"],
104
  "vocals": [
105
+ {"id": voice_name}
106
+ for voice_name in model_data["voices"]
 
 
107
  ]
108
  }
109
  models_response.append(model_info)
 
124
  # Run the application
125
  if __name__ == "__main__":
126
  import uvicorn
127
+ uvicorn.run(app, host="0.0.0.0", port=7860)