transcriberbin: expose mix-matrix property on audio sink pads

As the application expects to have the bin buffer the audio stream
internally and output it again unchanged, and transcribers might
expect a set number of channels, we need to expose a property to
let the user control how to downmix the audio stream teed through
the transcriber.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1969>
This commit is contained in:
Mathieu Duponchelle 2024-12-04 21:44:27 +01:00 committed by GStreamer Marge Bot
parent 1ba2468a05
commit e3e7f55a8d
2 changed files with 51 additions and 0 deletions

View file

@ -8799,6 +8799,17 @@
"type": "GstElement",
"writable": true
},
"transcription-mix-matrix": {
"blurb": "Initial transformation matrix for the transcriber audioconvert",
"conditionally-available": false,
"construct": false,
"construct-only": false,
"controllable": false,
"mutable": "ready",
"readable": true,
"type": "GstValueArray",
"writable": true
},
"translation-languages": {
"blurb": "A map of language codes to caption channels, e.g. translation-languages=\"languages, transcript={CC1, 708_1}, fr={708_2, CC3}\" will map the French translation to CC1/service 1 and the original transcript to CC3/service 2",
"conditionally-available": false,

View file

@ -2509,6 +2509,27 @@ impl ObjectImpl for TranscriberSinkPad {
.blurb("A map of language codes to bin descriptions, e.g. synthesis-languages=\"languages, fr=awspolly\" will use the awspolly element to synthesize speech from French translations")
.mutable_playing()
.build(),
gst::ParamSpecArray::builder("transcription-mix-matrix")
.nick("Transcription mix matrix")
.blurb("Initial transformation matrix for the transcriber audioconvert")
.element_spec(
&gst::ParamSpecArray::builder("rows")
.nick("Rows")
.blurb("A row in the matrix")
.element_spec(
&glib::ParamSpecFloat::builder("columns")
.nick("Columns")
.blurb("A column in the matrix")
.minimum(-1.)
.maximum(1.)
.default_value(0.)
.build()
)
.build(),
)
.mutable_ready()
.build()
]
});
@ -2664,6 +2685,15 @@ impl ObjectImpl for TranscriberSinkPad {
}
}
}
"transcription-mix-matrix" => {
let mut ps = self.state.lock().unwrap();
let Ok(pad_state) = ps.as_mut() else {
return;
};
pad_state
.transcriber_aconv
.set_property("mix-matrix", value);
}
_ => unimplemented!(),
}
}
@ -2697,6 +2727,16 @@ impl ObjectImpl for TranscriberSinkPad {
Err(_) => None::<gst::Element>.to_value(),
}
}
"transcription-mix-matrix" => {
let ps = self.state.lock().unwrap();
match ps.as_ref() {
Ok(ps) => ps.transcriber_aconv.property_value("mix-matrix"),
Err(_) => {
let v: Vec<gst::Array> = vec![];
gst::Array::new(&v).to_value()
}
}
}
_ => unimplemented!(),
}
}