NickVerri commited on
Commit
20c4a2d
·
verified ·
1 Parent(s): 480890a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -4
app.py CHANGED
@@ -10,6 +10,9 @@ from pyannote.audio import Pipeline
10
 
11
  # --- Configuration & Tokens ---
12
  # OPTION 1: Set this as a 'Secret' in Hugging Face Space Settings (Recommended)
 
 
 
13
 
14
  # Logic to determine which keys to use
15
  ENV_HF_TOKEN = os.environ.get("HF_TOKEN", "")
@@ -112,10 +115,22 @@ if uploaded_file:
112
 
113
  # 1. Diarization
114
  try:
115
- pipeline = Pipeline.from_pretrained(
116
- "pyannote/speaker-diarization@2.1",
117
- use_auth_token=active_hf_token
118
- )
 
 
 
 
 
 
 
 
 
 
 
 
119
  diarization = pipeline("audio_optimized.m4a")
120
  except Exception as e:
121
  st.error(f"Diarization Error: {e}")
 
10
 
11
  # --- Configuration & Tokens ---
12
  # OPTION 1: Set this as a 'Secret' in Hugging Face Space Settings (Recommended)
13
+ # OPTION 2: Paste your token between the quotes below to hardcode it permanently
14
+ HARDCODED_HF_TOKEN = "PASTE_YOUR_HF_TOKEN_HERE"
15
+ HARDCODED_GEMINI_KEY = ""
16
 
17
  # Logic to determine which keys to use
18
  ENV_HF_TOKEN = os.environ.get("HF_TOKEN", "")
 
115
 
116
  # 1. Diarization
117
  try:
118
+ # Fix for pyannote.audio 3.0+: 'use_auth_token' is now just 'token'
119
+ try:
120
+ pipeline = Pipeline.from_pretrained(
121
+ "pyannote/speaker-diarization@2.1",
122
+ token=active_hf_token
123
+ )
124
+ except TypeError:
125
+ # Fallback for older versions of pyannote.audio
126
+ pipeline = Pipeline.from_pretrained(
127
+ "pyannote/speaker-diarization@2.1",
128
+ use_auth_token=active_hf_token
129
+ )
130
+
131
+ if torch.cuda.is_available():
132
+ pipeline.to(torch.device("cuda"))
133
+
134
  diarization = pipeline("audio_optimized.m4a")
135
  except Exception as e:
136
  st.error(f"Diarization Error: {e}")