Peter Michael Gits Claude commited on
Commit Β·
49028b7
1
Parent(s): 57bc78b
feat: Add environment variable diagnostic script
Browse files- Create debug_env_vars.py to check HF environment variable detection
- Helps troubleshoot STT_SERVICE_MODE and TTS_SERVICE_MODE issues
- Shows all environment variables and service mode detection
- Useful for debugging Hugging Face Spaces configuration
π€ Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- debug_env_vars.py +60 -0
debug_env_vars.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Debug script to check environment variables in Hugging Face Spaces
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
import os
|
| 7 |
+
import sys
|
| 8 |
+
|
| 9 |
+
def check_environment_variables():
|
| 10 |
+
"""Check if environment variables are properly set"""
|
| 11 |
+
|
| 12 |
+
print("π ENVIRONMENT VARIABLE DIAGNOSTIC")
|
| 13 |
+
print("=" * 50)
|
| 14 |
+
|
| 15 |
+
# Check all environment variables
|
| 16 |
+
print("π All Environment Variables:")
|
| 17 |
+
env_vars = dict(os.environ)
|
| 18 |
+
|
| 19 |
+
# Look for our specific variables
|
| 20 |
+
target_vars = ["STT_SERVICE_MODE", "TTS_SERVICE_MODE"]
|
| 21 |
+
|
| 22 |
+
print(f"\nπ― Target Variables:")
|
| 23 |
+
for var in target_vars:
|
| 24 |
+
value = os.environ.get(var, "NOT SET")
|
| 25 |
+
print(f" {var} = '{value}'")
|
| 26 |
+
|
| 27 |
+
print(f"\nπ All Variables Starting with 'STT' or 'TTS':")
|
| 28 |
+
for key, value in env_vars.items():
|
| 29 |
+
if key.startswith(("STT", "TTS")):
|
| 30 |
+
print(f" {key} = '{value}'")
|
| 31 |
+
|
| 32 |
+
print(f"\nπ Total Environment Variables: {len(env_vars)}")
|
| 33 |
+
|
| 34 |
+
# Check common HF environment variables
|
| 35 |
+
print(f"\nπ Hugging Face Environment:")
|
| 36 |
+
hf_vars = ["SPACE_ID", "SPACE_AUTHOR", "SPACE_REPO", "SPACE_TITLE"]
|
| 37 |
+
for var in hf_vars:
|
| 38 |
+
value = os.environ.get(var, "NOT SET")
|
| 39 |
+
print(f" {var} = '{value}'")
|
| 40 |
+
|
| 41 |
+
# Test our service mode detection
|
| 42 |
+
print(f"\nποΈ Service Mode Detection Test:")
|
| 43 |
+
stt_mode = os.environ.get("STT_SERVICE_MODE", "websocket").lower()
|
| 44 |
+
tts_mode = os.environ.get("TTS_SERVICE_MODE", "websocket").lower()
|
| 45 |
+
|
| 46 |
+
print(f" STT Mode Detected: '{stt_mode}'")
|
| 47 |
+
print(f" TTS Mode Detected: '{tts_mode}'")
|
| 48 |
+
|
| 49 |
+
if stt_mode == "websocket":
|
| 50 |
+
print(" β
STT should run in WebSocket mode")
|
| 51 |
+
else:
|
| 52 |
+
print(" β STT will NOT run in WebSocket mode")
|
| 53 |
+
|
| 54 |
+
if tts_mode == "websocket":
|
| 55 |
+
print(" β
TTS should run in WebSocket mode")
|
| 56 |
+
else:
|
| 57 |
+
print(" β TTS will NOT run in WebSocket mode")
|
| 58 |
+
|
| 59 |
+
if __name__ == "__main__":
|
| 60 |
+
check_environment_variables()
|