Hameed13 commited on
Commit
566c19c
·
verified ·
1 Parent(s): 6d73ed9

Delete setup_token.py

Browse files
Files changed (1) hide show
  1. setup_token.py +0 -52
setup_token.py DELETED
@@ -1,52 +0,0 @@
1
- import os
2
- import sys
3
- import requests
4
- import argparse
5
-
6
- def setup_huggingface_token(token=None):
7
- """
8
- Set up the Hugging Face token for the Space.
9
- This script will help you test the token locally or configure it on Hugging Face.
10
- """
11
- if not token:
12
- # Try to get token from environment
13
- token = os.environ.get("HF_TOKEN")
14
- if not token:
15
- token = os.environ.get("HUGGINGFACE_TOKEN")
16
- if not token:
17
- token = os.environ.get("HF_API_TOKEN")
18
-
19
- if not token:
20
- print("No token provided and no token found in environment variables.")
21
- print("To use this script, either:")
22
- print("1. Set the HF_TOKEN environment variable")
23
- print("2. Pass the token as an argument: python setup_token.py --token YOUR_TOKEN")
24
- return False
25
-
26
- # Test if token works by making a request to the API
27
- url = "https://huggingface.co/novateur/WavTokenizer-medium-speech-75tokens/resolve/main/wavtokenizer_mediumdata_frame75_3s_nq1_code4096_dim512_kmeans200_attn.yaml"
28
- headers = {"Authorization": f"Bearer {token}"}
29
-
30
- try:
31
- response = requests.head(url, headers=headers)
32
- if response.status_code == 200:
33
- print("✅ Token is valid and working!")
34
- print("\nTo set up this token on your Hugging Face Space:")
35
- print("1. Go to your Space settings")
36
- print("2. Navigate to 'Repository secrets'")
37
- print("3. Add a new secret with name 'HF_TOKEN' and the value of your token")
38
- print("\nYour app will automatically use this token when it starts up.")
39
- return True
40
- else:
41
- print(f"❌ Token validation failed with status code: {response.status_code}")
42
- return False
43
- except Exception as e:
44
- print(f"❌ Error validating token: {str(e)}")
45
- return False
46
-
47
- if __name__ == "__main__":
48
- parser = argparse.ArgumentParser(description="Set up Hugging Face token for your Space")
49
- parser.add_argument("--token", help="Your Hugging Face API token")
50
- args = parser.parse_args()
51
-
52
- setup_huggingface_token(args.token)