aspirant312 commited on
Commit
14b46fe
·
1 Parent(s): 67f961c

Add HF_TOKEN authentication for gated model access

Browse files
Files changed (1) hide show
  1. api.py +7 -0
api.py CHANGED
@@ -6,9 +6,16 @@ import re
6
  from io import BytesIO
7
  import soundfile as sf
8
  from pydantic import BaseModel
 
 
9
  from parler_tts import ParlerTTSForConditionalGeneration
10
  from transformers import AutoTokenizer
11
 
 
 
 
 
 
12
  # Try to import spaces for HF Spaces deployment
13
  try:
14
  import spaces
 
6
  from io import BytesIO
7
  import soundfile as sf
8
  from pydantic import BaseModel
9
+ import os
10
+ from huggingface_hub import login
11
  from parler_tts import ParlerTTSForConditionalGeneration
12
  from transformers import AutoTokenizer
13
 
14
+ # Authenticate with HuggingFace if token is available
15
+ hf_token = os.getenv("HF_TOKEN")
16
+ if hf_token:
17
+ login(token=hf_token)
18
+
19
  # Try to import spaces for HF Spaces deployment
20
  try:
21
  import spaces