From 9972c83c60e0a52785b89c04b8c6c50419e4da34 Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Mon, 25 Nov 2024 18:08:09 +0100 Subject: [PATCH] aws/transcriber: put posting of warning messages behind property Repeated warning messages are fairly noisy with gst-launch, better make this behavior opt-in. Part-of: --- net/aws/src/transcriber/imp.rs | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/net/aws/src/transcriber/imp.rs b/net/aws/src/transcriber/imp.rs index 7a511271..44d31fdf 100644 --- a/net/aws/src/transcriber/imp.rs +++ b/net/aws/src/transcriber/imp.rs @@ -74,6 +74,7 @@ pub const GRANULARITY: gst::ClockTime = gst::ClockTime::from_mseconds(100); const OUTPUT_LANG_CODE_PROPERTY: &str = "language-code"; const DEFAULT_OUTPUT_LANG_CODE: Option<&str> = None; +const DEFAULT_POST_LATE_WARNINGS: bool = false; const TRANSLATION_TOKENIZATION_PROPERTY: &str = "tokenization-method"; @@ -92,6 +93,7 @@ pub(super) struct Settings { session_token: Option, pub vocabulary_filter: Option, pub vocabulary_filter_method: AwsTranscriberVocabularyFilterMethod, + post_late_warnings: bool, } impl Default for Settings { @@ -110,6 +112,7 @@ impl Default for Settings { session_token: None, vocabulary_filter: None, vocabulary_filter_method: DEFAULT_VOCABULARY_FILTER_METHOD, + post_late_warnings: DEFAULT_POST_LATE_WARNINGS, } } } @@ -1557,17 +1560,28 @@ impl TranslationPadTask { "Updating item PTS ({pts} < {last_position}), consider increasing latency", ); - let details = gst::Structure::builder("awstranscriber/late-item") - .field("original-pts", pts) - .field("last-position", last_position) - .build(); + let post_late_warnings = self + .pad + .parent() + .imp() + .settings + .lock() + .unwrap() + .post_late_warnings; - gst::element_warning!( - self.pad.parent(), - gst::LibraryError::Settings, - ["Late transcription item, updating PTS"], - details: details - ); + if post_late_warnings { + let details = gst::Structure::builder("awstranscriber/late-item") + .field("original-pts", pts) + .field("last-position", last_position) + .build(); + + gst::element_warning!( + self.pad.parent(), + gst::LibraryError::Settings, + ["Late transcription item, updating PTS"], + details: details + ); + } pts = last_position; // FIXME if the resulting duration is zero, we might as well not push it.