| |
| """ |
| Debug script to check environment variables in Hugging Face Spaces |
| """ |
|
|
| import os |
| import sys |
|
|
| def check_environment_variables(): |
| """Check if environment variables are properly set""" |
| |
| print("π ENVIRONMENT VARIABLE DIAGNOSTIC") |
| print("=" * 50) |
| |
| |
| print("π All Environment Variables:") |
| env_vars = dict(os.environ) |
| |
| |
| target_vars = ["STT_SERVICE_MODE", "TTS_SERVICE_MODE"] |
| |
| print(f"\nπ― Target Variables:") |
| for var in target_vars: |
| value = os.environ.get(var, "NOT SET") |
| print(f" {var} = '{value}'") |
| |
| print(f"\nπ All Variables Starting with 'STT' or 'TTS':") |
| for key, value in env_vars.items(): |
| if key.startswith(("STT", "TTS")): |
| print(f" {key} = '{value}'") |
| |
| print(f"\nπ Total Environment Variables: {len(env_vars)}") |
| |
| |
| print(f"\nπ Hugging Face Environment:") |
| hf_vars = ["SPACE_ID", "SPACE_AUTHOR", "SPACE_REPO", "SPACE_TITLE"] |
| for var in hf_vars: |
| value = os.environ.get(var, "NOT SET") |
| print(f" {var} = '{value}'") |
| |
| |
| print(f"\nποΈ Service Mode Detection Test:") |
| stt_mode = os.environ.get("STT_SERVICE_MODE", "websocket").lower() |
| tts_mode = os.environ.get("TTS_SERVICE_MODE", "websocket").lower() |
| |
| print(f" STT Mode Detected: '{stt_mode}'") |
| print(f" TTS Mode Detected: '{tts_mode}'") |
| |
| if stt_mode == "websocket": |
| print(" β
STT should run in WebSocket mode") |
| else: |
| print(" β STT will NOT run in WebSocket mode") |
| |
| if tts_mode == "websocket": |
| print(" β
TTS should run in WebSocket mode") |
| else: |
| print(" β TTS will NOT run in WebSocket mode") |
|
|
| if __name__ == "__main__": |
| check_environment_variables() |