voiceCal / debug_env_vars.py
Peter Michael Gits
feat: Add environment variable diagnostic script
49028b7
#!/usr/bin/env python3
"""
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)
# Check all environment variables
print("πŸ“‹ All Environment Variables:")
env_vars = dict(os.environ)
# Look for our specific variables
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)}")
# Check common HF environment variables
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}'")
# Test our service mode detection
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()