From 0a7cbb8d596579e77bc50b7d4517d95bff63a399 Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Mon, 12 May 2025 16:25:19 +0200 Subject: [PATCH] awstranscriber2: add property for setting show_speaker_labels Part-of: --- docs/plugins/gst_plugins_cache.json | 12 ++++++++++++ net/aws/src/transcriber2/imp.rs | 20 +++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/docs/plugins/gst_plugins_cache.json b/docs/plugins/gst_plugins_cache.json index ba8688feb..f96922cc3 100644 --- a/docs/plugins/gst_plugins_cache.json +++ b/docs/plugins/gst_plugins_cache.json @@ -1504,6 +1504,18 @@ "type": "gchararray", "writable": true }, + "show-speaker-label": { + "blurb": "Defines whether to partition speakers in the transcription output", + "conditionally-available": false, + "construct": false, + "construct-only": false, + "controllable": false, + "default": "false", + "mutable": "ready", + "readable": true, + "type": "gboolean", + "writable": true + }, "vocabulary-filter-method": { "blurb": "Defines how filtered words will be edited, has no effect when vocabulary-filter-name isn't set", "conditionally-available": false, diff --git a/net/aws/src/transcriber2/imp.rs b/net/aws/src/transcriber2/imp.rs index 9d8194af8..31ae91671 100644 --- a/net/aws/src/transcriber2/imp.rs +++ b/net/aws/src/transcriber2/imp.rs @@ -41,6 +41,7 @@ const DEFAULT_INPUT_LANG_CODE: &str = "en-US"; const DEFAULT_STABILITY: AwsTranscriberResultStability = AwsTranscriberResultStability::Low; const DEFAULT_VOCABULARY_FILTER_METHOD: AwsTranscriberVocabularyFilterMethod = AwsTranscriberVocabularyFilterMethod::Mask; +const DEFAULT_SHOW_SPEAKER_LABEL: bool = false; #[derive(Debug, Clone)] pub(super) struct Settings { @@ -55,6 +56,7 @@ pub(super) struct Settings { results_stability: AwsTranscriberResultStability, vocabulary_filter: Option, vocabulary_filter_method: AwsTranscriberVocabularyFilterMethod, + show_speaker_label: bool, } impl Default for Settings { @@ -71,6 +73,7 @@ impl Default for Settings { results_stability: DEFAULT_STABILITY, vocabulary_filter: None, vocabulary_filter_method: DEFAULT_VOCABULARY_FILTER_METHOD, + show_speaker_label: DEFAULT_SHOW_SPEAKER_LABEL, } } } @@ -674,7 +677,8 @@ impl Transcriber { .enable_partial_results_stabilization(true) .partial_results_stability(settings.results_stability.into()) .set_vocabulary_name(settings.vocabulary) - .set_session_id(settings.session_id); + .set_session_id(settings.session_id) + .set_show_speaker_label(Some(settings.show_speaker_label)); if let Some(vocabulary_filter) = settings.vocabulary_filter { builder = builder @@ -965,6 +969,12 @@ impl ObjectImpl for Transcriber { .blurb("Defines how filtered words will be edited, has no effect when vocabulary-filter-name isn't set") .mutable_ready() .build(), + glib::ParamSpecBoolean::builder("show-speaker-label") + .nick("Show Speaker Label") + .blurb("Defines whether to partition speakers in the transcription output") + .default_value(DEFAULT_SHOW_SPEAKER_LABEL) + .mutable_ready() + .build(), ] }); @@ -1035,6 +1045,10 @@ impl ObjectImpl for Transcriber { .get::() .expect("type checked upstream"); } + "show-speaker-label" => { + let mut settings = self.settings.lock().unwrap(); + settings.show_speaker_label = value.get().expect("type checked upstream"); + } _ => unimplemented!(), } } @@ -1085,6 +1099,10 @@ impl ObjectImpl for Transcriber { let settings = self.settings.lock().unwrap(); settings.vocabulary_filter_method.to_value() } + "show-speaker-label" => { + let settings = self.settings.lock().unwrap(); + settings.show_speaker_label.to_value() + } _ => unimplemented!(), } }