From bb641f353c3dd81f5e3b16ecaf1fae669b3ac67b Mon Sep 17 00:00:00 2001 From: Malte Voos Date: Thu, 25 Dec 2025 11:05:19 +0100 Subject: fix whisper subtitles not appearing in subtitle selection menu --- src/app.rs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/app.rs') diff --git a/src/app.rs b/src/app.rs index bdb2ef9..49efd49 100644 --- a/src/app.rs +++ b/src/app.rs @@ -13,6 +13,7 @@ use crate::{ subtitle_view::{SubtitleView, SubtitleViewMsg, SubtitleViewOutput}, subtitles::{ MetadataCollection, SUBTITLE_TRACKS, StreamIndex, SubtitleCue, SubtitleTrack, + TrackMetadata, extraction::{SubtitleExtractor, SubtitleExtractorMsg, SubtitleExtractorOutput}, state::SubtitleState, }, @@ -181,8 +182,8 @@ impl SimpleComponent for App { AppMsg::AddCue(stream_ix, cue) => { SUBTITLE_TRACKS .write() - .get_mut(&stream_ix) - .unwrap() + .entry(stream_ix) + .or_insert(SubtitleTrack::default()) .push_cue(cue.clone()); self.transcript @@ -245,9 +246,23 @@ impl SimpleComponent for App { } AppMsg::Play { url, - metadata, + mut metadata, whisper_stream_index, } => { + if let Some(ix) = whisper_stream_index { + let audio_metadata = metadata.audio.get(&ix).unwrap(); + let subs_metadata = TrackMetadata { + language: audio_metadata.language, + title: Some(match &audio_metadata.title { + Some(title) => { + format!("Auto-generated from audio (Whisper): {}", title) + } + None => "Auto-generated from audio (Whisper)".to_string(), + }), + }; + metadata.subtitles.insert(ix, subs_metadata); + } + self.player .sender() .send(PlayerMsg::SetUrl(url.clone())) -- cgit 1.4.1