PyxiLabs commited on
Commit
cf896f2
·
verified ·
1 Parent(s): 52832fd

Update core/app.py

Browse files
Files changed (1) hide show
  1. core/app.py +0 -20
core/app.py CHANGED
@@ -10,7 +10,6 @@ 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
- from langdetect import detect, LangDetectException
14
 
15
  # Create necessary directories if they don't exist
16
  os.makedirs("static", exist_ok=True)
@@ -87,17 +86,6 @@ class SpeechRequest(BaseModel):
87
  input: str = Field(..., max_length=5000)
88
  voice: str
89
 
90
- # Allowed languages
91
- ALLOWED_LANGUAGES = {"en", "ja", "zh", "id"} # Codes for English, Japanese, Chinese, Indonesian
92
-
93
- # Function to validate language
94
- def validate_language(text: str) -> bool:
95
- try:
96
- lang = detect(text)
97
- return lang in ALLOWED_LANGUAGES
98
- except LangDetectException:
99
- return False
100
-
101
  # Endpoint to generate speech
102
  @app.post("/v1/audio/speech")
103
  @app.get("/v1/audio/speech")
@@ -106,13 +94,6 @@ def validate_language(text: str) -> bool:
106
  @limiter.limit(f"{RATE_LIMITS['rpd']}/day")
107
  async def create_speech(request: Request, speech_request: SpeechRequest):
108
  try:
109
- # Validate input language
110
- if not validate_language(speech_request.input):
111
- raise HTTPException(
112
- status_code=400,
113
- detail="Input text must be in English, Japanese, Chinese, or Indonesian."
114
- )
115
-
116
  if speech_request.model != "Pyx r1-voice":
117
  raise HTTPException(status_code=400, detail="Invalid model. Only 'Pyx r1-voice' is supported.")
118
 
@@ -136,7 +117,6 @@ async def create_speech(request: Request, speech_request: SpeechRequest):
136
  raise HTTPException(status_code=500, detail=str(e))
137
 
138
  # Endpoint to get available models
139
- @app.get("/models")
140
  @app.get("/v1/models")
141
  async def get_models():
142
  models_response = []
 
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
15
  os.makedirs("static", exist_ok=True)
 
86
  input: str = Field(..., max_length=5000)
87
  voice: str
88
 
 
 
 
 
 
 
 
 
 
 
 
89
  # Endpoint to generate speech
90
  @app.post("/v1/audio/speech")
91
  @app.get("/v1/audio/speech")
 
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":
98
  raise HTTPException(status_code=400, detail="Invalid model. Only 'Pyx r1-voice' is supported.")
99
 
 
117
  raise HTTPException(status_code=500, detail=str(e))
118
 
119
  # Endpoint to get available models
 
120
  @app.get("/v1/models")
121
  async def get_models():
122
  models_response = []