PatienceIzere commited on
Commit
f71888e
·
verified ·
1 Parent(s): 34a1847

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py CHANGED
@@ -10,6 +10,23 @@ import glob
10
  import shutil
11
  import time
12
  from hf_transcriber import HFTranscriber
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  # Configuration dictionary to store app settings
15
  app_config = {
 
10
  import shutil
11
  import time
12
  from hf_transcriber import HFTranscriber
13
+ from huggingface_hub import login
14
+
15
+ # Load environment variables from .env file if it exists
16
+ from dotenv import load_dotenv
17
+ load_dotenv()
18
+
19
+ # Authenticate with Hugging Face
20
+ HUGGINGFACE_TOKEN = os.environ.get('HUGGINGFACE_TOKEN')
21
+ if HUGGINGFACE_TOKEN:
22
+ try:
23
+ login(token=HUGGINGFACE_TOKEN)
24
+ st.success("Successfully authenticated with Hugging Face.")
25
+ except Exception as e:
26
+ st.warning(f"Could not authenticate with Hugging Face: {str(e)}")
27
+ else:
28
+ st.warning("Hugging Face token not found. Some models may not work without authentication.")
29
+ st.info("Create a .env file with HUGGINGFACE_TOKEN=your_token_here or set it in your environment variables.")
30
 
31
  # Configuration dictionary to store app settings
32
  app_config = {