aboutsummaryrefslogtreecommitdiff
path: root/src/app.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/app.rs')
-rw-r--r--src/app.rs21
1 files changed, 18 insertions, 3 deletions
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()))