Update app.py
Browse files
app.py
CHANGED
|
@@ -9,9 +9,11 @@ from datetime import timedelta
|
|
| 9 |
from pyannote.audio import Pipeline
|
| 10 |
|
| 11 |
# --- Configuration & Tokens ---
|
| 12 |
-
#
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
| 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 |
-
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 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
|