Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1163,9 +1163,32 @@ if __name__ == "__main__":
|
|
1163 |
if not CHATTERBOX_AVAILABLE:
|
1164 |
logger.warning("π¨ IMPORTANT: Upload your ChatterboxTTS package to enable real synthesis!")
|
1165 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1166 |
if os.getenv("SPACE_ID"):
|
1167 |
# Running in Hugging Face Spaces
|
1168 |
logger.info("π Running in Hugging Face Spaces")
|
|
|
|
|
|
|
1169 |
demo = create_gradio_interface()
|
1170 |
demo.launch(
|
1171 |
server_name="0.0.0.0",
|
@@ -1173,25 +1196,16 @@ if __name__ == "__main__":
|
|
1173 |
show_error=True
|
1174 |
)
|
1175 |
else:
|
1176 |
-
# Local development
|
1177 |
-
|
1178 |
-
import threading
|
1179 |
-
|
1180 |
-
def run_fastapi():
|
1181 |
-
uvicorn.run(app, host="0.0.0.0", port=8000, log_level="info")
|
1182 |
-
|
1183 |
-
# Start FastAPI in background
|
1184 |
-
api_thread = threading.Thread(target=run_fastapi, daemon=True)
|
1185 |
-
api_thread.start()
|
1186 |
-
|
1187 |
logger.info("π FastAPI: http://localhost:8000")
|
1188 |
logger.info("π API Docs: http://localhost:8000/docs")
|
1189 |
-
logger.info("
|
1190 |
-
logger.info(" - GET /api/voices")
|
1191 |
-
logger.info(" - POST /api/voices/create")
|
1192 |
-
logger.info(" - DELETE /api/voices/{voice_id}")
|
1193 |
-
logger.info(" - POST /api/tts/synthesize")
|
1194 |
|
1195 |
# Start Gradio
|
1196 |
demo = create_gradio_interface()
|
1197 |
-
demo.launch(
|
|
|
|
|
|
|
|
|
|
1163 |
if not CHATTERBOX_AVAILABLE:
|
1164 |
logger.warning("π¨ IMPORTANT: Upload your ChatterboxTTS package to enable real synthesis!")
|
1165 |
|
1166 |
+
# Always start FastAPI in background (both local and HF Spaces)
|
1167 |
+
import uvicorn
|
1168 |
+
import threading
|
1169 |
+
|
1170 |
+
def run_fastapi():
|
1171 |
+
uvicorn.run(app, host="0.0.0.0", port=8000, log_level="info")
|
1172 |
+
|
1173 |
+
# Start FastAPI in background thread
|
1174 |
+
api_thread = threading.Thread(target=run_fastapi, daemon=True)
|
1175 |
+
api_thread.start()
|
1176 |
+
|
1177 |
+
logger.info("π FastAPI Server: Starting on port 8000")
|
1178 |
+
logger.info("π API Documentation will be available")
|
1179 |
+
logger.info("π API Endpoints:")
|
1180 |
+
logger.info(" - GET /api/voices")
|
1181 |
+
logger.info(" - POST /api/voices/create")
|
1182 |
+
logger.info(" - DELETE /api/voices/{voice_id}")
|
1183 |
+
logger.info(" - POST /api/tts/synthesize")
|
1184 |
+
logger.info(" - GET /api/audio/{audio_id}")
|
1185 |
+
|
1186 |
if os.getenv("SPACE_ID"):
|
1187 |
# Running in Hugging Face Spaces
|
1188 |
logger.info("π Running in Hugging Face Spaces")
|
1189 |
+
logger.info("π API will be available at: https://[your-space-name].hf.space:8000")
|
1190 |
+
logger.info("π API Docs will be at: https://[your-space-name].hf.space:8000/docs")
|
1191 |
+
|
1192 |
demo = create_gradio_interface()
|
1193 |
demo.launch(
|
1194 |
server_name="0.0.0.0",
|
|
|
1196 |
show_error=True
|
1197 |
)
|
1198 |
else:
|
1199 |
+
# Local development
|
1200 |
+
logger.info("π» Running in Local Development")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1201 |
logger.info("π FastAPI: http://localhost:8000")
|
1202 |
logger.info("π API Docs: http://localhost:8000/docs")
|
1203 |
+
logger.info("π΅ Gradio UI: http://localhost:7861")
|
|
|
|
|
|
|
|
|
1204 |
|
1205 |
# Start Gradio
|
1206 |
demo = create_gradio_interface()
|
1207 |
+
demo.launch(
|
1208 |
+
share=True,
|
1209 |
+
server_name="0.0.0.0",
|
1210 |
+
server_port=7861
|
1211 |
+
)
|