awstranscriber2: add property for setting show_speaker_labels

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2240>
This commit is contained in:
Mathieu Duponchelle 2025-05-12 16:25:19 +02:00 committed by GStreamer Marge Bot
parent 79f5bc96d9
commit 0a7cbb8d59
2 changed files with 31 additions and 1 deletions

View file

@ -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,

View file

@ -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<String>,
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::<AwsTranscriberVocabularyFilterMethod>()
.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!(),
}
}