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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -9
app.py CHANGED
@@ -9,9 +9,11 @@ from datetime import timedelta
9
  from pyannote.audio import Pipeline
10
 
11
  # --- Configuration & Tokens ---
12
- # You can hardcode your token here or use the Sidebar in the App
13
- HF_TOKEN = os.environ.get("HF_TOKEN", "REPLACE_WITH_YOUR_HF_TOKEN")
14
- GEMINI_API_KEY = os.environ.get("GEMINI_API_KEY", "")
 
 
15
 
16
  def format_timecode(seconds, fps=25):
17
  """Converts seconds to HH:MM:SS:FF for Resolve/Premiere."""
@@ -75,11 +77,16 @@ st.title("Documentary AI: Pipeline")
75
 
76
  with st.sidebar:
77
  st.header("Settings")
78
- input_gemini_key = st.text_input("Gemini API Key", type="password", value=GEMINI_API_KEY)
79
- input_hf_token = st.text_input("HF Token (Diarization)", type="password", value=HF_TOKEN)
80
 
81
- active_api_key = input_gemini_key if input_gemini_key else GEMINI_API_KEY
82
- active_hf_token = input_hf_token if input_hf_token else HF_TOKEN
 
 
 
 
 
 
 
83
  fps = st.number_input("Timeline FPS", value=25)
84
 
85
  uploaded_file = st.file_uploader("Upload Video/Audio Clip", type=["mp4", "m4a", "wav", "mp3", "mov"])
@@ -88,8 +95,8 @@ if uploaded_file:
88
  # --- Step 1: Technical Processing ---
89
  if "transcript" not in st.session_state:
90
  if st.button("Step 1: Transcribe & Diarize"):
91
- if not active_hf_token or active_hf_token.startswith("REPLACE"):
92
- st.error("Please provide a valid Hugging Face Token.")
93
  else:
94
  with st.spinner("Processing... Extracting audio, identifying speakers, and transcribing:"):
95
  # Save local temp file
 
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", "")
16
+ ENV_GEMINI_KEY = os.environ.get("GEMINI_API_KEY", "")
17
 
18
  def format_timecode(seconds, fps=25):
19
  """Converts seconds to HH:MM:SS:FF for Resolve/Premiere."""
 
77
 
78
  with st.sidebar:
79
  st.header("Settings")
 
 
80
 
81
+ # Determine default values for inputs
82
+ def_gemini = ENV_GEMINI_KEY if ENV_GEMINI_KEY else HARDCODED_GEMINI_KEY
83
+ def_hf = ENV_HF_TOKEN if ENV_HF_TOKEN else HARDCODED_HF_TOKEN
84
+
85
+ input_gemini_key = st.text_input("Gemini API Key", type="password", value=def_gemini)
86
+ input_hf_token = st.text_input("HF Token (Diarization)", type="password", value=def_hf)
87
+
88
+ active_api_key = input_gemini_key
89
+ active_hf_token = input_hf_token
90
  fps = st.number_input("Timeline FPS", value=25)
91
 
92
  uploaded_file = st.file_uploader("Upload Video/Audio Clip", type=["mp4", "m4a", "wav", "mp3", "mov"])
 
95
  # --- Step 1: Technical Processing ---
96
  if "transcript" not in st.session_state:
97
  if st.button("Step 1: Transcribe & Diarize"):
98
+ if not active_hf_token or "PASTE_YOUR_HF_TOKEN" in active_hf_token:
99
+ st.error("Please provide a valid Hugging Face Token in the sidebar or hardcode it in app.py.")
100
  else:
101
  with st.spinner("Processing... Extracting audio, identifying speakers, and transcribing:"):
102
  # Save local temp file