Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import sys
|
| 3 |
+
import logging
|
| 4 |
+
|
| 5 |
+
# Configure logging
|
| 6 |
+
logging.basicConfig(
|
| 7 |
+
level=logging.INFO,
|
| 8 |
+
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
| 9 |
+
handlers=[logging.StreamHandler(sys.stdout)]
|
| 10 |
+
)
|
| 11 |
+
logger = logging.getLogger(__name__)
|
| 12 |
+
|
| 13 |
+
# Log system information
|
| 14 |
+
logger.info("Starting Conversational Speech System")
|
| 15 |
+
logger.info(f"Python version: {sys.version}")
|
| 16 |
+
logger.info(f"Current directory: {os.getcwd()}")
|
| 17 |
+
|
| 18 |
+
try:
|
| 19 |
+
# Run setup to optimize environment
|
| 20 |
+
logger.info("Running setup...")
|
| 21 |
+
import setup
|
| 22 |
+
setup.preload_models()
|
| 23 |
+
|
| 24 |
+
# Import the main application
|
| 25 |
+
logger.info("Importing speech conversation app...")
|
| 26 |
+
from speech_conversation_app import demo
|
| 27 |
+
|
| 28 |
+
# Launch the application
|
| 29 |
+
logger.info("Launching application...")
|
| 30 |
+
demo.launch()
|
| 31 |
+
|
| 32 |
+
except Exception as e:
|
| 33 |
+
logger.error(f"Failed to start application: {e}", exc_info=True)
|
| 34 |
+
|
| 35 |
+
# Fallback to basic Gradio interface if the main app fails
|
| 36 |
+
import gradio as gr
|
| 37 |
+
|
| 38 |
+
def fallback_app():
|
| 39 |
+
with gr.Blocks() as fallback_demo:
|
| 40 |
+
gr.Markdown("""
|
| 41 |
+
# Conversational Speech System
|
| 42 |
+
|
| 43 |
+
**Error:** The application encountered a problem during startup.
|
| 44 |
+
|
| 45 |
+
Common issues:
|
| 46 |
+
- Memory limitations on the hosting environment
|
| 47 |
+
- Missing dependencies
|
| 48 |
+
- GPU resource limitations
|
| 49 |
+
|
| 50 |
+
Please check the logs for more details or try again later.
|
| 51 |
+
""")
|
| 52 |
+
|
| 53 |
+
return fallback_demo
|
| 54 |
+
|
| 55 |
+
logger.info("Launching fallback application...")
|
| 56 |
+
fallback_app().launch()
|