yukee1992 commited on
Commit
a10029a
Β·
verified Β·
1 Parent(s): 0efaa7e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -20,6 +20,7 @@ current_model = ""
20
  model_loading = False
21
  current_voice_style = "default_female"
22
  voice_cloning_supported = False
 
23
 
24
  # Configure environment
25
  os.makedirs("/tmp/voices", exist_ok=True)
@@ -54,10 +55,10 @@ print("πŸš€ TTS API Starting Up...")
54
  print(f"βœ… Device: {DEVICE}")
55
  print(f"πŸ”§ OCI Upload: {OCI_UPLOAD_API_URL or 'Local only'}")
56
  print("πŸ“ Models will load on first request (lazy loading)")
57
- print("⏰ Startup time:", datetime.now().isoformat())
58
  print("=" * 50)
59
 
60
- # Pydantic models (keep all your existing models and classes the same)
61
  class TTSRequest(BaseModel):
62
  text: str
63
  project_id: str
@@ -73,9 +74,7 @@ class VoiceCloneRequest(BaseModel):
73
  class ChangeVoiceRequest(BaseModel):
74
  voice_style: str
75
 
76
- # Keep all your existing helper functions exactly the same:
77
- # clean_text, upload_to_oci, get_voice_path, clone_voice, supports_voice_cloning, load_tts_model
78
-
79
  def clean_text(text):
80
  """Clean text for TTS generation"""
81
  import re
@@ -213,7 +212,7 @@ def load_tts_model(voice_style="default_female"):
213
  finally:
214
  model_loading = False
215
 
216
- # Keep all your existing endpoints exactly the same:
217
  @app.get("/")
218
  async def root():
219
  """Root endpoint"""
@@ -244,6 +243,7 @@ async def api_health_check():
244
  "device": DEVICE
245
  }
246
 
 
247
  @app.post("/api/tts")
248
  async def generate_tts(request: TTSRequest):
249
  """Generate TTS for a single text"""
 
20
  model_loading = False
21
  current_voice_style = "default_female"
22
  voice_cloning_supported = False
23
+ app_startup_time = datetime.now()
24
 
25
  # Configure environment
26
  os.makedirs("/tmp/voices", exist_ok=True)
 
55
  print(f"βœ… Device: {DEVICE}")
56
  print(f"πŸ”§ OCI Upload: {OCI_UPLOAD_API_URL or 'Local only'}")
57
  print("πŸ“ Models will load on first request (lazy loading)")
58
+ print("⏰ Startup time:", app_startup_time.isoformat())
59
  print("=" * 50)
60
 
61
+ # Pydantic models
62
  class TTSRequest(BaseModel):
63
  text: str
64
  project_id: str
 
74
  class ChangeVoiceRequest(BaseModel):
75
  voice_style: str
76
 
77
+ # Helper functions
 
 
78
  def clean_text(text):
79
  """Clean text for TTS generation"""
80
  import re
 
212
  finally:
213
  model_loading = False
214
 
215
+ # Health check endpoints
216
  @app.get("/")
217
  async def root():
218
  """Root endpoint"""
 
243
  "device": DEVICE
244
  }
245
 
246
+ # API endpoints
247
  @app.post("/api/tts")
248
  async def generate_tts(request: TTSRequest):
249
  """Generate TTS for a single text"""