Commit ·
4ea7fc4
1
Parent(s): 993d3cf
Remove OpenAI Cleanup Stage From The Pipeline
Browse files- README.md +8 -10
- app.py +11 -34
- requirements.txt +0 -1
README.md
CHANGED
|
@@ -9,7 +9,7 @@ python_version: "3.12"
|
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
| 11 |
license: mit
|
| 12 |
-
short_description: End-to-end Parakeet + Pyannote
|
| 13 |
---
|
| 14 |
|
| 15 |
This Space is optimized for API usage on ZeroGPU.
|
|
@@ -19,7 +19,6 @@ Single production pipeline:
|
|
| 19 |
1. Parakeet transcription (word timestamps) on ZeroGPU
|
| 20 |
2. Pyannote Community-1 diarization on ZeroGPU
|
| 21 |
3. Merge transcript + diarization (CPU)
|
| 22 |
-
4. OpenAI speaker inference + cleanup (CPU)
|
| 23 |
|
| 24 |
Model setup is global/outside `@spaces.GPU` so setup time is not billed to ZeroGPU windows.
|
| 25 |
|
|
@@ -30,10 +29,10 @@ Model setup is global/outside `@spaces.GPU` so setup time is not billed to ZeroG
|
|
| 30 |
## `/run_complete_pipeline` inputs
|
| 31 |
- `audio_file` (file path from Gradio client upload)
|
| 32 |
- `huggingface_token`
|
| 33 |
-
- `openai_api_key`
|
| 34 |
-
- `executive_names_csv`
|
| 35 |
|
| 36 |
-
Returns:
|
| 37 |
|
| 38 |
## `/get_debug_output` inputs
|
| 39 |
- `run_id` (optional)
|
|
@@ -42,7 +41,6 @@ Returns: raw/debug payload for the latest run (or specific run if provided), inc
|
|
| 42 |
- Parakeet raw output + ZeroGPU timing
|
| 43 |
- Pyannote raw output + ZeroGPU timing
|
| 44 |
- merged transcript payload
|
| 45 |
-
- OpenAI raw responses + token usage
|
| 46 |
- aggregated timing
|
| 47 |
|
| 48 |
## IPython example
|
|
@@ -54,12 +52,12 @@ AUDIO_FILE = "Q3-FY26_5min.mp3"
|
|
| 54 |
|
| 55 |
client = Client(SPACE)
|
| 56 |
|
| 57 |
-
# Run end-to-end pipeline
|
| 58 |
-
|
| 59 |
audio_file=handle_file(AUDIO_FILE),
|
| 60 |
huggingface_token="hf_xxx",
|
| 61 |
-
openai_api_key="
|
| 62 |
-
executive_names_csv="
|
| 63 |
api_name="/run_complete_pipeline",
|
| 64 |
)
|
| 65 |
|
|
|
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
| 11 |
license: mit
|
| 12 |
+
short_description: End-to-end Parakeet + Pyannote transcript pipeline
|
| 13 |
---
|
| 14 |
|
| 15 |
This Space is optimized for API usage on ZeroGPU.
|
|
|
|
| 19 |
1. Parakeet transcription (word timestamps) on ZeroGPU
|
| 20 |
2. Pyannote Community-1 diarization on ZeroGPU
|
| 21 |
3. Merge transcript + diarization (CPU)
|
|
|
|
| 22 |
|
| 23 |
Model setup is global/outside `@spaces.GPU` so setup time is not billed to ZeroGPU windows.
|
| 24 |
|
|
|
|
| 29 |
## `/run_complete_pipeline` inputs
|
| 30 |
- `audio_file` (file path from Gradio client upload)
|
| 31 |
- `huggingface_token`
|
| 32 |
+
- `openai_api_key` (accepted for compatibility, unused in Space)
|
| 33 |
+
- `executive_names_csv` (accepted for compatibility, unused in Space)
|
| 34 |
|
| 35 |
+
Returns: merged transcript JSON only.
|
| 36 |
|
| 37 |
## `/get_debug_output` inputs
|
| 38 |
- `run_id` (optional)
|
|
|
|
| 41 |
- Parakeet raw output + ZeroGPU timing
|
| 42 |
- Pyannote raw output + ZeroGPU timing
|
| 43 |
- merged transcript payload
|
|
|
|
| 44 |
- aggregated timing
|
| 45 |
|
| 46 |
## IPython example
|
|
|
|
| 52 |
|
| 53 |
client = Client(SPACE)
|
| 54 |
|
| 55 |
+
# Run end-to-end pipeline (returns merged transcript)
|
| 56 |
+
merged_transcript = client.predict(
|
| 57 |
audio_file=handle_file(AUDIO_FILE),
|
| 58 |
huggingface_token="hf_xxx",
|
| 59 |
+
openai_api_key="", # unused
|
| 60 |
+
executive_names_csv="", # unused
|
| 61 |
api_name="/run_complete_pipeline",
|
| 62 |
)
|
| 63 |
|
app.py
CHANGED
|
@@ -12,7 +12,6 @@ from src.diarization_service import run_chunked_diarization
|
|
| 12 |
from src.merge_service import merge_parakeet_pyannote_outputs
|
| 13 |
from src.models.parakeet_model import preload_parakeet_model, run_parakeet
|
| 14 |
from src.models.pyannote_community_model import preload_pyannote_pipeline, run_pyannote_community_chunk
|
| 15 |
-
from src.openai_cleanup_service import run_openai_cleanup_pipeline
|
| 16 |
from src.utils import get_audio_duration_seconds
|
| 17 |
|
| 18 |
# Suppress a known deprecation warning emitted by a transitive dependency in spaces.
|
|
@@ -58,14 +57,11 @@ def _store_debug_payload(payload: dict[str, Any]) -> str:
|
|
| 58 |
def _parse_main_request(
|
| 59 |
audio_file: str | None,
|
| 60 |
huggingface_token: str | None,
|
| 61 |
-
openai_api_key: str | None,
|
| 62 |
) -> None:
|
| 63 |
if audio_file is None:
|
| 64 |
raise gr.Error("No audio file submitted. Upload an audio file first.")
|
| 65 |
if not huggingface_token or not huggingface_token.strip():
|
| 66 |
raise gr.Error("huggingface_token is required for pyannote/speaker-diarization-community-1.")
|
| 67 |
-
if not openai_api_key or not openai_api_key.strip():
|
| 68 |
-
raise gr.Error("openai_api_key is required for speaker inference and cleanup.")
|
| 69 |
|
| 70 |
|
| 71 |
# Global setup (outside @spaces.GPU) so setup cost is not charged to ZeroGPU inference window.
|
|
@@ -116,7 +112,10 @@ def run_complete_pipeline(
|
|
| 116 |
openai_api_key: str,
|
| 117 |
executive_names_csv: str,
|
| 118 |
):
|
| 119 |
-
|
|
|
|
|
|
|
|
|
|
| 120 |
_raise_preload_error_if_any(PARAKEET_V3)
|
| 121 |
|
| 122 |
started_at = time.perf_counter()
|
|
@@ -159,18 +158,6 @@ def run_complete_pipeline(
|
|
| 159 |
diarization_key="exclusive_speaker_diarization",
|
| 160 |
)
|
| 161 |
|
| 162 |
-
# 4) OpenAI speaker inference + cleanup outside ZeroGPU.
|
| 163 |
-
openai_result = run_openai_cleanup_pipeline(
|
| 164 |
-
merged_transcript=merged_transcript,
|
| 165 |
-
openai_api_key=openai_api_key,
|
| 166 |
-
executive_names_csv=executive_names_csv,
|
| 167 |
-
cleanup_model="gpt-5",
|
| 168 |
-
timeout_seconds=600.0,
|
| 169 |
-
max_turns_per_chunk=80,
|
| 170 |
-
max_chars_per_chunk=22000,
|
| 171 |
-
)
|
| 172 |
-
cleaned_transcript = openai_result["cleaned_transcript"]
|
| 173 |
-
|
| 174 |
total_gpu_window_seconds = float(parakeet_response["zerogpu_timing"].get("gpu_window_seconds", 0.0)) + float(
|
| 175 |
pyannote_response.get("zerogpu_timing", {}).get("gpu_window_seconds", 0.0)
|
| 176 |
)
|
|
@@ -187,20 +174,16 @@ def run_complete_pipeline(
|
|
| 187 |
},
|
| 188 |
"inputs": {
|
| 189 |
"audio_file": str(audio_file),
|
| 190 |
-
"executive_names_csv": executive_names_csv or "",
|
| 191 |
"huggingface_token_provided": bool(huggingface_token),
|
| 192 |
-
"openai_api_key_provided": bool(openai_api_key),
|
| 193 |
},
|
| 194 |
"parakeet_response": parakeet_response,
|
| 195 |
"pyannote_response": pyannote_response,
|
| 196 |
"merged_transcript": merged_transcript,
|
| 197 |
-
"openai_debug": openai_result.get("debug", {}),
|
| 198 |
-
"final_transcript": cleaned_transcript,
|
| 199 |
}
|
| 200 |
_store_debug_payload(debug_payload)
|
| 201 |
|
| 202 |
-
# Return
|
| 203 |
-
return
|
| 204 |
|
| 205 |
|
| 206 |
def get_debug_output(run_id: str | None):
|
|
@@ -215,10 +198,10 @@ def get_debug_output(run_id: str | None):
|
|
| 215 |
return {"run_id": _LAST_DEBUG_RUN_ID, "debug": _DEBUG_RUNS[_LAST_DEBUG_RUN_ID]}
|
| 216 |
|
| 217 |
|
| 218 |
-
with gr.Blocks(title="Parakeet + Pyannote
|
| 219 |
gr.Markdown(
|
| 220 |
"# End-to-end transcript pipeline\n"
|
| 221 |
-
"Runs Parakeet transcription, Pyannote diarization,
|
| 222 |
)
|
| 223 |
|
| 224 |
audio_file = gr.Audio(
|
|
@@ -230,17 +213,11 @@ with gr.Blocks(title="Parakeet + Pyannote + OpenAI Pipeline") as demo:
|
|
| 230 |
label="HuggingFace token",
|
| 231 |
type="password",
|
| 232 |
)
|
| 233 |
-
openai_api_key = gr.Textbox(
|
| 234 |
-
|
| 235 |
-
type="password",
|
| 236 |
-
)
|
| 237 |
-
executive_names_csv = gr.Textbox(
|
| 238 |
-
label="Executive names / terms (comma-separated)",
|
| 239 |
-
placeholder="Ashok Vaswani,Devang Gheewala,Kotak 811,CASA,NIM",
|
| 240 |
-
)
|
| 241 |
|
| 242 |
run_btn = gr.Button("Run full pipeline")
|
| 243 |
-
output = gr.JSON(label="
|
| 244 |
|
| 245 |
run_btn.click(
|
| 246 |
fn=run_complete_pipeline,
|
|
|
|
| 12 |
from src.merge_service import merge_parakeet_pyannote_outputs
|
| 13 |
from src.models.parakeet_model import preload_parakeet_model, run_parakeet
|
| 14 |
from src.models.pyannote_community_model import preload_pyannote_pipeline, run_pyannote_community_chunk
|
|
|
|
| 15 |
from src.utils import get_audio_duration_seconds
|
| 16 |
|
| 17 |
# Suppress a known deprecation warning emitted by a transitive dependency in spaces.
|
|
|
|
| 57 |
def _parse_main_request(
|
| 58 |
audio_file: str | None,
|
| 59 |
huggingface_token: str | None,
|
|
|
|
| 60 |
) -> None:
|
| 61 |
if audio_file is None:
|
| 62 |
raise gr.Error("No audio file submitted. Upload an audio file first.")
|
| 63 |
if not huggingface_token or not huggingface_token.strip():
|
| 64 |
raise gr.Error("huggingface_token is required for pyannote/speaker-diarization-community-1.")
|
|
|
|
|
|
|
| 65 |
|
| 66 |
|
| 67 |
# Global setup (outside @spaces.GPU) so setup cost is not charged to ZeroGPU inference window.
|
|
|
|
| 112 |
openai_api_key: str,
|
| 113 |
executive_names_csv: str,
|
| 114 |
):
|
| 115 |
+
# Kept in signature for compatibility with existing clients; not used on Space.
|
| 116 |
+
_ = openai_api_key
|
| 117 |
+
_ = executive_names_csv
|
| 118 |
+
_parse_main_request(audio_file, huggingface_token)
|
| 119 |
_raise_preload_error_if_any(PARAKEET_V3)
|
| 120 |
|
| 121 |
started_at = time.perf_counter()
|
|
|
|
| 158 |
diarization_key="exclusive_speaker_diarization",
|
| 159 |
)
|
| 160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
total_gpu_window_seconds = float(parakeet_response["zerogpu_timing"].get("gpu_window_seconds", 0.0)) + float(
|
| 162 |
pyannote_response.get("zerogpu_timing", {}).get("gpu_window_seconds", 0.0)
|
| 163 |
)
|
|
|
|
| 174 |
},
|
| 175 |
"inputs": {
|
| 176 |
"audio_file": str(audio_file),
|
|
|
|
| 177 |
"huggingface_token_provided": bool(huggingface_token),
|
|
|
|
| 178 |
},
|
| 179 |
"parakeet_response": parakeet_response,
|
| 180 |
"pyannote_response": pyannote_response,
|
| 181 |
"merged_transcript": merged_transcript,
|
|
|
|
|
|
|
| 182 |
}
|
| 183 |
_store_debug_payload(debug_payload)
|
| 184 |
|
| 185 |
+
# Return merged transcript JSON (OpenAI cleanup is intentionally local/off-space).
|
| 186 |
+
return merged_transcript
|
| 187 |
|
| 188 |
|
| 189 |
def get_debug_output(run_id: str | None):
|
|
|
|
| 198 |
return {"run_id": _LAST_DEBUG_RUN_ID, "debug": _DEBUG_RUNS[_LAST_DEBUG_RUN_ID]}
|
| 199 |
|
| 200 |
|
| 201 |
+
with gr.Blocks(title="Parakeet + Pyannote Pipeline") as demo:
|
| 202 |
gr.Markdown(
|
| 203 |
"# End-to-end transcript pipeline\n"
|
| 204 |
+
"Runs Parakeet transcription, Pyannote diarization, then merges into a combined transcript JSON."
|
| 205 |
)
|
| 206 |
|
| 207 |
audio_file = gr.Audio(
|
|
|
|
| 213 |
label="HuggingFace token",
|
| 214 |
type="password",
|
| 215 |
)
|
| 216 |
+
openai_api_key = gr.Textbox(label="OpenAI API key (unused in Space)", type="password")
|
| 217 |
+
executive_names_csv = gr.Textbox(label="Executive names / terms (unused in Space)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
|
| 219 |
run_btn = gr.Button("Run full pipeline")
|
| 220 |
+
output = gr.JSON(label="Combined transcript JSON")
|
| 221 |
|
| 222 |
run_btn.click(
|
| 223 |
fn=run_complete_pipeline,
|
requirements.txt
CHANGED
|
@@ -8,4 +8,3 @@ transformers
|
|
| 8 |
accelerate
|
| 9 |
nemo_toolkit[asr]
|
| 10 |
pyannote.audio
|
| 11 |
-
openai
|
|
|
|
| 8 |
accelerate
|
| 9 |
nemo_toolkit[asr]
|
| 10 |
pyannote.audio
|
|
|