Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -23,16 +23,25 @@ env_path = find_dotenv()
|
|
| 23 |
if env_path:
|
| 24 |
load_dotenv(env_path)
|
| 25 |
|
| 26 |
-
#
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
| 31 |
st.sidebar.success("✅ Authenticated with Hugging Face")
|
| 32 |
-
|
| 33 |
-
st.sidebar.warning("⚠️ Using public models (rate limited)")
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
# Configuration dictionary to store app settings
|
| 38 |
app_config = {
|
|
@@ -242,6 +251,7 @@ def main():
|
|
| 242 |
except Exception as e:
|
| 243 |
st.error(f"An error occurred during transcription setup: {str(e)}")
|
| 244 |
st.exception(e) # Show full traceback for debugging
|
|
|
|
| 245 |
# Clean up temporary files
|
| 246 |
if os.path.exists("temp_uploads"):
|
| 247 |
for file in os.listdir("temp_uploads"):
|
|
|
|
| 23 |
if env_path:
|
| 24 |
load_dotenv(env_path)
|
| 25 |
|
| 26 |
+
# Hugging Face authentication
|
| 27 |
+
HUGGINGFACE_TOKEN = os.environ.get('HUGGINGFACE_TOKEN') or os.environ.get('HF_TOKEN')
|
| 28 |
+
|
| 29 |
+
# Check if we have a valid token
|
| 30 |
+
if HUGGINGFACE_TOKEN and HUGGINGFACE_TOKEN.startswith('hf_'):
|
| 31 |
+
try:
|
| 32 |
+
login(token=HUGGINGFACE_TOKEN, add_to_git_credential=False)
|
| 33 |
st.sidebar.success("✅ Authenticated with Hugging Face")
|
| 34 |
+
except Exception as e:
|
| 35 |
+
st.sidebar.warning(f"⚠️ Using public models (rate limited): {str(e)}")
|
| 36 |
+
HUGGINGFACE_TOKEN = None # Reset token if invalid
|
| 37 |
+
else:
|
| 38 |
+
st.sidebar.warning("""
|
| 39 |
+
⚠️ No Hugging Face token found. Using public models (rate limited).
|
| 40 |
+
|
| 41 |
+
To use your own token:
|
| 42 |
+
1. Get your token from [Hugging Face Settings](https://huggingface.co/settings/tokens)
|
| 43 |
+
2. Add it to your Space's secrets as `HUGGINGFACE_TOKEN`
|
| 44 |
+
""")
|
| 45 |
|
| 46 |
# Configuration dictionary to store app settings
|
| 47 |
app_config = {
|
|
|
|
| 251 |
except Exception as e:
|
| 252 |
st.error(f"An error occurred during transcription setup: {str(e)}")
|
| 253 |
st.exception(e) # Show full traceback for debugging
|
| 254 |
+
|
| 255 |
# Clean up temporary files
|
| 256 |
if os.path.exists("temp_uploads"):
|
| 257 |
for file in os.listdir("temp_uploads"):
|