MusaedMusaedSadeqMusaedAl-Fareh225739
backend folder
10fba92
"""MrrrMe Backend - Utility Helper Functions"""
import os
import requests
def get_avatar_api_url():
"""Get correct avatar API URL based on environment"""
# For Hugging Face Spaces, use same host
if os.path.exists('/.dockerenv') or os.environ.get('SPACE_ID'):
# Running in Docker/HF Spaces - use internal networking
return "http://127.0.0.1:8765"
else:
# Local development
return "http://localhost:8765"
async def check_avatar_service(avatar_api: str):
"""Check if avatar TTS service is running"""
try:
response = requests.get(f"{avatar_api}/", timeout=2)
if response.status_code == 200:
print(f"[Backend] βœ… Avatar TTS service available at {avatar_api}")
else:
print(f"[Backend] ⚠️ Avatar TTS service responded with {response.status_code}")
except requests.exceptions.ConnectionError:
print(f"[Backend] ⚠️ Avatar TTS service NOT available at {avatar_api}")
print(f"[Backend] πŸ’‘ Text-only mode will be used (no avatar speech)")
print(f"[Backend] πŸ“ To enable avatar:")
print(f"[Backend] cd avatar && python speak_server.py")
except Exception as e:
print(f"[Backend] ⚠️ Error checking avatar service: {e}")