import time import os from fastrtc import get_cloudflare_turn_credentials def main(): print("\n" + "="*40) print(" 🔍 DEBUG: Fetching Cloudflare TURN Credentials") print("="*40 + "\n") try: # get_cloudflare_turn_credentials relies on the HF_TOKEN environment variable. # This is automatically provided in Hugging Face Spaces. creds = get_cloudflare_turn_credentials() print("✅ Success! Here is the RTC Configuration:") print("-" * 20) print(creds) print("-" * 20) except Exception as e: print("❌ Error fetching credentials.") print(f"Details: {e}") print("\nPossible fix: Ensure 'HF_TOKEN' is set in your Space secrets.") print("\n" + "="*40) print(" 💤 Script sleeping... Check the 'Logs' tab to see the output above.") print("="*40 + "\n") # Keep the Space running so you can read the logs without it crashing/restarting while True: time.sleep(60) if __name__ == "__main__": main()