Add canonical audio preparation and meeting context support
This commit is contained in:
@@ -7,11 +7,13 @@ import re
|
||||
import shutil
|
||||
import sys
|
||||
import time
|
||||
from collections.abc import Callable, Mapping, Sequence
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable, Mapping, Sequence
|
||||
from typing import Any
|
||||
|
||||
from src.meeting_lab.audio import prepare_audio
|
||||
from src.meeting_lab.diarization import (
|
||||
DEFAULT_MODEL as DEFAULT_DIARIZATION_MODEL,
|
||||
diarize_audio,
|
||||
@@ -44,6 +46,8 @@ class MvpMeetingConfig:
|
||||
audio_file: Path
|
||||
whisper_model: Path
|
||||
whisper_executable: str = "whisper-cli"
|
||||
ffmpeg_executable: str = "ffmpeg"
|
||||
audio_normalization: bool = True
|
||||
context_file: Path | None = None
|
||||
output_root: Path = DEFAULT_OUTPUT_ROOT
|
||||
language: str = "de"
|
||||
@@ -187,6 +191,7 @@ def run_mvp_meeting(
|
||||
stage_runtimes: dict[str, float | None] = {
|
||||
"validation": round(validation_runtime, 3),
|
||||
"setup": None,
|
||||
"audio_preparation": None,
|
||||
"whisper": None,
|
||||
"transcript_validation": None,
|
||||
"protocol": None,
|
||||
@@ -198,6 +203,7 @@ def run_mvp_meeting(
|
||||
"run_id": run_dir.name,
|
||||
"timestamp": timestamp,
|
||||
"input_audio": str(config.audio_file.resolve()),
|
||||
"audio_preparation": None,
|
||||
"transcript_output": str(transcript_path.resolve()),
|
||||
"protocol_output": str(protocol_path.resolve()),
|
||||
"whisper_model": str(config.whisper_model.resolve()),
|
||||
@@ -238,6 +244,33 @@ def run_mvp_meeting(
|
||||
},
|
||||
)
|
||||
|
||||
preparation_started = time.perf_counter()
|
||||
current_stage = "audio_preparation"
|
||||
stage_started = preparation_started
|
||||
prepared_audio = prepare_audio(
|
||||
config.audio_file,
|
||||
audio_dir / "prepared.wav",
|
||||
ffmpeg_executable=config.ffmpeg_executable,
|
||||
normalization_enabled=config.audio_normalization,
|
||||
)
|
||||
stage_runtimes["audio_preparation"] = round(
|
||||
time.perf_counter() - preparation_started, 3
|
||||
)
|
||||
current_stage = "preparing"
|
||||
preparation_metadata = prepared_audio.metadata()
|
||||
metadata["audio_preparation"] = preparation_metadata
|
||||
_write_json(audio_dir / "preparation_metadata.json", preparation_metadata)
|
||||
_write_json(
|
||||
audio_dir / "input_manifest.json",
|
||||
{
|
||||
"source_file": str(config.audio_file.resolve()),
|
||||
"filename": config.audio_file.name,
|
||||
"size_bytes": config.audio_file.stat().st_size,
|
||||
"format": config.audio_file.suffix.lower().removeprefix("."),
|
||||
"prepared_audio": preparation_metadata,
|
||||
},
|
||||
)
|
||||
|
||||
preserved_context: Path | None = None
|
||||
if effective_context is not None:
|
||||
preserved_context = context_dir / "meeting_context.yaml"
|
||||
@@ -252,7 +285,7 @@ def run_mvp_meeting(
|
||||
stage_started = time.perf_counter()
|
||||
_emit(progress_sink, "transcription", "started", overall_started)
|
||||
transcription = transcribe_audio(
|
||||
config.audio_file,
|
||||
prepared_audio.prepared_path,
|
||||
config.whisper_model,
|
||||
transcript_dir,
|
||||
config.language,
|
||||
@@ -275,7 +308,7 @@ def run_mvp_meeting(
|
||||
_emit(progress_sink, "diarization", "started", overall_started)
|
||||
diarization_dir = run_dir / "diarization"
|
||||
diarization = diarize_audio(
|
||||
config.audio_file,
|
||||
prepared_audio.prepared_path,
|
||||
diarization_dir,
|
||||
config.diarization,
|
||||
runtime=config.diarization_runtime,
|
||||
@@ -330,6 +363,7 @@ def run_mvp_meeting(
|
||||
except Exception as exc:
|
||||
metadata_stage = {
|
||||
"preparing": "setup",
|
||||
"audio_preparation": "audio_preparation",
|
||||
"transcription": "whisper",
|
||||
"diarization": "diarization",
|
||||
"protocol_generation": "protocol",
|
||||
|
||||
Reference in New Issue
Block a user