From 7c61fd9e7a836bc10d105fe46414f43c7c18f4dd Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Fri, 19 Feb 2021 21:54:08 +0100 Subject: [PATCH] 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. --- net/rusoto/src/aws_transcriber/imp.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/net/rusoto/src/aws_transcriber/imp.rs b/net/rusoto/src/aws_transcriber/imp.rs index b035562c..4cb213fe 100644 --- a/net/rusoto/src/aws_transcriber/imp.rs +++ b/net/rusoto/src/aws_transcriber/imp.rs @@ -121,6 +121,7 @@ struct Settings { latency_ms: u32, language_code: Option, use_partial_results: bool, + vocabulary: Option, } 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 \ + \ + 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!(), } }