Add speaker-attributed meeting transcription

This commit is contained in:
2026-06-12 12:18:35 +00:00
parent 7516e0ad61
commit 8fd5e5b464
7 changed files with 571 additions and 13 deletions
+22 -4
View File
@@ -6,15 +6,26 @@ from typing import Callable
from discord.ext import voice_recv
from recording import MANIFEST_NAME, MeetingSink
logger = logging.getLogger(__name__)
class MeetingRecorder:
"""Wrapper around discord-ext-voice-recv's listen/stop_listening API."""
"""Wrapper around discord-ext-voice-recv's listen/stop_listening API.
Records a hybrid capture:
* a mixed archive WAV at ``output_path`` (everyone, silence-padded)
* one speech-only WAV per speaker under ``tracks/`` next to the archive
* a ``tracks.json`` manifest in that ``tracks/`` directory
"""
def __init__(self, voice_client: voice_recv.VoiceRecvClient, output_path: str):
self.vc = voice_client
self.output_path = output_path
self.tracks_dir = str(Path(output_path).parent / "tracks")
self.manifest_path = str(Path(self.tracks_dir) / MANIFEST_NAME)
self.recording = False
self.sink: voice_recv.AudioSink | None = None
@@ -23,11 +34,18 @@ class MeetingRecorder:
raise RuntimeError("Voice client is already listening")
Path(self.output_path).parent.mkdir(parents=True, exist_ok=True)
wave_sink = voice_recv.WaveSink(self.output_path)
self.sink = voice_recv.SilenceGeneratorSink(wave_sink)
meeting_sink = MeetingSink(self.output_path, self.tracks_dir)
# SilenceGeneratorSink keeps the mixed archive timeline faithful when
# packets are dropped; MeetingSink itself excludes silence frames from
# the per-speaker tracks.
self.sink = voice_recv.SilenceGeneratorSink(meeting_sink)
self.vc.listen(self.sink, after=after_callback)
self.recording = True
logger.info("Voice receive started: output_path=%s", self.output_path)
logger.info(
"Voice receive started: output_path=%s tracks_dir=%s",
self.output_path,
self.tracks_dir,
)
async def stop(self) -> None:
if not self.recording: