mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-05-20 17:28:49 +00:00
awstranscriber: add vocabulary property
AWS offers the option of creating "vocabularies", lists of words that are likely to be encountered. Those can be created through the AWS console, and are given a name. That name can then be specified when starting a transcription job.
This commit is contained in:
parent
77bf0c945e
commit
7c61fd9e7a
|
@ -121,6 +121,7 @@ struct Settings {
|
|||
latency_ms: u32,
|
||||
language_code: Option<String>,
|
||||
use_partial_results: bool,
|
||||
vocabulary: Option<String>,
|
||||
}
|
||||
|
||||
impl Default for Settings {
|
||||
|
@ -129,6 +130,7 @@ impl Default for Settings {
|
|||
latency_ms: DEFAULT_LATENCY_MS,
|
||||
language_code: Some("en-US".to_string()),
|
||||
use_partial_results: DEFAULT_USE_PARTIAL_RESULTS,
|
||||
vocabulary: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -869,6 +871,11 @@ impl Transcriber {
|
|||
signed.add_param("language-code", language_code);
|
||||
signed.add_param("media-encoding", "pcm");
|
||||
signed.add_param("sample-rate", &sample_rate.to_string());
|
||||
|
||||
if let Some(ref vocabulary) = settings.vocabulary {
|
||||
signed.add_param("vocabulary-name", vocabulary);
|
||||
}
|
||||
|
||||
let url = signed.generate_presigned_url(&creds, &std::time::Duration::from_secs(60), true);
|
||||
|
||||
let (ws, _) = {
|
||||
|
@ -1047,6 +1054,15 @@ impl ObjectImpl for Transcriber {
|
|||
DEFAULT_LATENCY_MS,
|
||||
glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY,
|
||||
),
|
||||
glib::ParamSpec::string(
|
||||
"vocabulary-name",
|
||||
"Vocabulary Name",
|
||||
"The name of a custom vocabulary, see \
|
||||
<https://docs.aws.amazon.com/transcribe/latest/dg/how-vocabulary.html> \
|
||||
for more information",
|
||||
None,
|
||||
glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY,
|
||||
),
|
||||
]
|
||||
});
|
||||
|
||||
|
@ -1081,6 +1097,10 @@ impl ObjectImpl for Transcriber {
|
|||
let mut settings = self.settings.lock().unwrap();
|
||||
settings.use_partial_results = value.get_some().expect("type checked upstream");
|
||||
}
|
||||
"vocabulary-name" => {
|
||||
let mut settings = self.settings.lock().unwrap();
|
||||
settings.vocabulary = value.get().expect("type checked upstream");
|
||||
}
|
||||
_ => unimplemented!(),
|
||||
}
|
||||
}
|
||||
|
@ -1099,6 +1119,10 @@ impl ObjectImpl for Transcriber {
|
|||
let settings = self.settings.lock().unwrap();
|
||||
settings.use_partial_results.to_value()
|
||||
}
|
||||
"vocabulary-name" => {
|
||||
let settings = self.settings.lock().unwrap();
|
||||
settings.vocabulary.to_value()
|
||||
}
|
||||
_ => unimplemented!(),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue