google_cloud_speech_v2/model.rs
1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17#![allow(rustdoc::bare_urls)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![allow(rustdoc::invalid_html_tags)]
20#![allow(rustdoc::redundant_explicit_links)]
21#![no_implicit_prelude]
22extern crate async_trait;
23extern crate bytes;
24extern crate gaxi;
25extern crate google_cloud_gax;
26extern crate google_cloud_location;
27extern crate google_cloud_longrunning;
28extern crate google_cloud_lro;
29extern crate google_cloud_rpc;
30extern crate serde;
31extern crate serde_json;
32extern crate serde_with;
33extern crate std;
34extern crate tracing;
35extern crate wkt;
36
37mod debug;
38mod deserialize;
39mod serialize;
40
41/// Request message for the
42/// [CreateRecognizer][google.cloud.speech.v2.Speech.CreateRecognizer] method.
43///
44/// [google.cloud.speech.v2.Speech.CreateRecognizer]: crate::client::Speech::create_recognizer
45#[derive(Clone, Default, PartialEq)]
46#[non_exhaustive]
47pub struct CreateRecognizerRequest {
48 /// Required. The Recognizer to create.
49 pub recognizer: std::option::Option<crate::model::Recognizer>,
50
51 /// If set, validate the request and preview the Recognizer, but do not
52 /// actually create it.
53 pub validate_only: bool,
54
55 /// The ID to use for the Recognizer, which will become the final component of
56 /// the Recognizer's resource name.
57 ///
58 /// This value should be 4-63 characters, and valid characters
59 /// are /[a-z][0-9]-/.
60 pub recognizer_id: std::string::String,
61
62 /// Required. The project and location where this Recognizer will be created.
63 /// The expected format is `projects/{project}/locations/{location}`.
64 pub parent: std::string::String,
65
66 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
67}
68
69impl CreateRecognizerRequest {
70 /// Creates a new default instance.
71 pub fn new() -> Self {
72 std::default::Default::default()
73 }
74
75 /// Sets the value of [recognizer][crate::model::CreateRecognizerRequest::recognizer].
76 ///
77 /// # Example
78 /// ```ignore,no_run
79 /// # use google_cloud_speech_v2::model::CreateRecognizerRequest;
80 /// use google_cloud_speech_v2::model::Recognizer;
81 /// let x = CreateRecognizerRequest::new().set_recognizer(Recognizer::default()/* use setters */);
82 /// ```
83 pub fn set_recognizer<T>(mut self, v: T) -> Self
84 where
85 T: std::convert::Into<crate::model::Recognizer>,
86 {
87 self.recognizer = std::option::Option::Some(v.into());
88 self
89 }
90
91 /// Sets or clears the value of [recognizer][crate::model::CreateRecognizerRequest::recognizer].
92 ///
93 /// # Example
94 /// ```ignore,no_run
95 /// # use google_cloud_speech_v2::model::CreateRecognizerRequest;
96 /// use google_cloud_speech_v2::model::Recognizer;
97 /// let x = CreateRecognizerRequest::new().set_or_clear_recognizer(Some(Recognizer::default()/* use setters */));
98 /// let x = CreateRecognizerRequest::new().set_or_clear_recognizer(None::<Recognizer>);
99 /// ```
100 pub fn set_or_clear_recognizer<T>(mut self, v: std::option::Option<T>) -> Self
101 where
102 T: std::convert::Into<crate::model::Recognizer>,
103 {
104 self.recognizer = v.map(|x| x.into());
105 self
106 }
107
108 /// Sets the value of [validate_only][crate::model::CreateRecognizerRequest::validate_only].
109 ///
110 /// # Example
111 /// ```ignore,no_run
112 /// # use google_cloud_speech_v2::model::CreateRecognizerRequest;
113 /// let x = CreateRecognizerRequest::new().set_validate_only(true);
114 /// ```
115 pub fn set_validate_only<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
116 self.validate_only = v.into();
117 self
118 }
119
120 /// Sets the value of [recognizer_id][crate::model::CreateRecognizerRequest::recognizer_id].
121 ///
122 /// # Example
123 /// ```ignore,no_run
124 /// # use google_cloud_speech_v2::model::CreateRecognizerRequest;
125 /// let x = CreateRecognizerRequest::new().set_recognizer_id("example");
126 /// ```
127 pub fn set_recognizer_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
128 self.recognizer_id = v.into();
129 self
130 }
131
132 /// Sets the value of [parent][crate::model::CreateRecognizerRequest::parent].
133 ///
134 /// # Example
135 /// ```ignore,no_run
136 /// # use google_cloud_speech_v2::model::CreateRecognizerRequest;
137 /// # let project_id = "project_id";
138 /// # let location_id = "location_id";
139 /// let x = CreateRecognizerRequest::new().set_parent(format!("projects/{project_id}/locations/{location_id}"));
140 /// ```
141 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
142 self.parent = v.into();
143 self
144 }
145}
146
147impl wkt::message::Message for CreateRecognizerRequest {
148 fn typename() -> &'static str {
149 "type.googleapis.com/google.cloud.speech.v2.CreateRecognizerRequest"
150 }
151}
152
153/// Represents the metadata of a long-running operation.
154#[derive(Clone, Default, PartialEq)]
155#[non_exhaustive]
156pub struct OperationMetadata {
157 /// The time the operation was created.
158 pub create_time: std::option::Option<wkt::Timestamp>,
159
160 /// The time the operation was last updated.
161 pub update_time: std::option::Option<wkt::Timestamp>,
162
163 /// The resource path for the target of the operation.
164 pub resource: std::string::String,
165
166 /// The method that triggered the operation.
167 pub method: std::string::String,
168
169 /// The [KMS key
170 /// name](https://cloud.google.com/kms/docs/resource-hierarchy#keys) with which
171 /// the content of the Operation is encrypted. The expected format is
172 /// `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
173 pub kms_key_name: std::string::String,
174
175 /// The [KMS key version
176 /// name](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions)
177 /// with which content of the Operation is encrypted. The expected format is
178 /// `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}`.
179 pub kms_key_version_name: std::string::String,
180
181 /// The percent progress of the Operation. Values can range from 0-100. If the
182 /// value is 100, then the operation is finished.
183 pub progress_percent: i32,
184
185 /// The request that spawned the Operation.
186 pub request: std::option::Option<crate::model::operation_metadata::Request>,
187
188 /// Specific metadata per RPC.
189 pub metadata: std::option::Option<crate::model::operation_metadata::Metadata>,
190
191 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
192}
193
194impl OperationMetadata {
195 /// Creates a new default instance.
196 pub fn new() -> Self {
197 std::default::Default::default()
198 }
199
200 /// Sets the value of [create_time][crate::model::OperationMetadata::create_time].
201 ///
202 /// # Example
203 /// ```ignore,no_run
204 /// # use google_cloud_speech_v2::model::OperationMetadata;
205 /// use wkt::Timestamp;
206 /// let x = OperationMetadata::new().set_create_time(Timestamp::default()/* use setters */);
207 /// ```
208 pub fn set_create_time<T>(mut self, v: T) -> Self
209 where
210 T: std::convert::Into<wkt::Timestamp>,
211 {
212 self.create_time = std::option::Option::Some(v.into());
213 self
214 }
215
216 /// Sets or clears the value of [create_time][crate::model::OperationMetadata::create_time].
217 ///
218 /// # Example
219 /// ```ignore,no_run
220 /// # use google_cloud_speech_v2::model::OperationMetadata;
221 /// use wkt::Timestamp;
222 /// let x = OperationMetadata::new().set_or_clear_create_time(Some(Timestamp::default()/* use setters */));
223 /// let x = OperationMetadata::new().set_or_clear_create_time(None::<Timestamp>);
224 /// ```
225 pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
226 where
227 T: std::convert::Into<wkt::Timestamp>,
228 {
229 self.create_time = v.map(|x| x.into());
230 self
231 }
232
233 /// Sets the value of [update_time][crate::model::OperationMetadata::update_time].
234 ///
235 /// # Example
236 /// ```ignore,no_run
237 /// # use google_cloud_speech_v2::model::OperationMetadata;
238 /// use wkt::Timestamp;
239 /// let x = OperationMetadata::new().set_update_time(Timestamp::default()/* use setters */);
240 /// ```
241 pub fn set_update_time<T>(mut self, v: T) -> Self
242 where
243 T: std::convert::Into<wkt::Timestamp>,
244 {
245 self.update_time = std::option::Option::Some(v.into());
246 self
247 }
248
249 /// Sets or clears the value of [update_time][crate::model::OperationMetadata::update_time].
250 ///
251 /// # Example
252 /// ```ignore,no_run
253 /// # use google_cloud_speech_v2::model::OperationMetadata;
254 /// use wkt::Timestamp;
255 /// let x = OperationMetadata::new().set_or_clear_update_time(Some(Timestamp::default()/* use setters */));
256 /// let x = OperationMetadata::new().set_or_clear_update_time(None::<Timestamp>);
257 /// ```
258 pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
259 where
260 T: std::convert::Into<wkt::Timestamp>,
261 {
262 self.update_time = v.map(|x| x.into());
263 self
264 }
265
266 /// Sets the value of [resource][crate::model::OperationMetadata::resource].
267 ///
268 /// # Example
269 /// ```ignore,no_run
270 /// # use google_cloud_speech_v2::model::OperationMetadata;
271 /// let x = OperationMetadata::new().set_resource("example");
272 /// ```
273 pub fn set_resource<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
274 self.resource = v.into();
275 self
276 }
277
278 /// Sets the value of [method][crate::model::OperationMetadata::method].
279 ///
280 /// # Example
281 /// ```ignore,no_run
282 /// # use google_cloud_speech_v2::model::OperationMetadata;
283 /// let x = OperationMetadata::new().set_method("example");
284 /// ```
285 pub fn set_method<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
286 self.method = v.into();
287 self
288 }
289
290 /// Sets the value of [kms_key_name][crate::model::OperationMetadata::kms_key_name].
291 ///
292 /// # Example
293 /// ```ignore,no_run
294 /// # use google_cloud_speech_v2::model::OperationMetadata;
295 /// let x = OperationMetadata::new().set_kms_key_name("example");
296 /// ```
297 pub fn set_kms_key_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
298 self.kms_key_name = v.into();
299 self
300 }
301
302 /// Sets the value of [kms_key_version_name][crate::model::OperationMetadata::kms_key_version_name].
303 ///
304 /// # Example
305 /// ```ignore,no_run
306 /// # use google_cloud_speech_v2::model::OperationMetadata;
307 /// let x = OperationMetadata::new().set_kms_key_version_name("example");
308 /// ```
309 pub fn set_kms_key_version_name<T: std::convert::Into<std::string::String>>(
310 mut self,
311 v: T,
312 ) -> Self {
313 self.kms_key_version_name = v.into();
314 self
315 }
316
317 /// Sets the value of [progress_percent][crate::model::OperationMetadata::progress_percent].
318 ///
319 /// # Example
320 /// ```ignore,no_run
321 /// # use google_cloud_speech_v2::model::OperationMetadata;
322 /// let x = OperationMetadata::new().set_progress_percent(42);
323 /// ```
324 pub fn set_progress_percent<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
325 self.progress_percent = v.into();
326 self
327 }
328
329 /// Sets the value of [request][crate::model::OperationMetadata::request].
330 ///
331 /// Note that all the setters affecting `request` are mutually
332 /// exclusive.
333 ///
334 /// # Example
335 /// ```ignore,no_run
336 /// # use google_cloud_speech_v2::model::OperationMetadata;
337 /// use google_cloud_speech_v2::model::BatchRecognizeRequest;
338 /// let x = OperationMetadata::new().set_request(Some(
339 /// google_cloud_speech_v2::model::operation_metadata::Request::BatchRecognizeRequest(BatchRecognizeRequest::default().into())));
340 /// ```
341 pub fn set_request<
342 T: std::convert::Into<std::option::Option<crate::model::operation_metadata::Request>>,
343 >(
344 mut self,
345 v: T,
346 ) -> Self {
347 self.request = v.into();
348 self
349 }
350
351 /// The value of [request][crate::model::OperationMetadata::request]
352 /// if it holds a `BatchRecognizeRequest`, `None` if the field is not set or
353 /// holds a different branch.
354 pub fn batch_recognize_request(
355 &self,
356 ) -> std::option::Option<&std::boxed::Box<crate::model::BatchRecognizeRequest>> {
357 #[allow(unreachable_patterns)]
358 self.request.as_ref().and_then(|v| match v {
359 crate::model::operation_metadata::Request::BatchRecognizeRequest(v) => {
360 std::option::Option::Some(v)
361 }
362 _ => std::option::Option::None,
363 })
364 }
365
366 /// Sets the value of [request][crate::model::OperationMetadata::request]
367 /// to hold a `BatchRecognizeRequest`.
368 ///
369 /// Note that all the setters affecting `request` are
370 /// mutually exclusive.
371 ///
372 /// # Example
373 /// ```ignore,no_run
374 /// # use google_cloud_speech_v2::model::OperationMetadata;
375 /// use google_cloud_speech_v2::model::BatchRecognizeRequest;
376 /// let x = OperationMetadata::new().set_batch_recognize_request(BatchRecognizeRequest::default()/* use setters */);
377 /// assert!(x.batch_recognize_request().is_some());
378 /// assert!(x.create_recognizer_request().is_none());
379 /// assert!(x.update_recognizer_request().is_none());
380 /// assert!(x.delete_recognizer_request().is_none());
381 /// assert!(x.undelete_recognizer_request().is_none());
382 /// assert!(x.create_custom_class_request().is_none());
383 /// assert!(x.update_custom_class_request().is_none());
384 /// assert!(x.delete_custom_class_request().is_none());
385 /// assert!(x.undelete_custom_class_request().is_none());
386 /// assert!(x.create_phrase_set_request().is_none());
387 /// assert!(x.update_phrase_set_request().is_none());
388 /// assert!(x.delete_phrase_set_request().is_none());
389 /// assert!(x.undelete_phrase_set_request().is_none());
390 /// assert!(x.update_config_request().is_none());
391 /// ```
392 pub fn set_batch_recognize_request<
393 T: std::convert::Into<std::boxed::Box<crate::model::BatchRecognizeRequest>>,
394 >(
395 mut self,
396 v: T,
397 ) -> Self {
398 self.request = std::option::Option::Some(
399 crate::model::operation_metadata::Request::BatchRecognizeRequest(v.into()),
400 );
401 self
402 }
403
404 /// The value of [request][crate::model::OperationMetadata::request]
405 /// if it holds a `CreateRecognizerRequest`, `None` if the field is not set or
406 /// holds a different branch.
407 pub fn create_recognizer_request(
408 &self,
409 ) -> std::option::Option<&std::boxed::Box<crate::model::CreateRecognizerRequest>> {
410 #[allow(unreachable_patterns)]
411 self.request.as_ref().and_then(|v| match v {
412 crate::model::operation_metadata::Request::CreateRecognizerRequest(v) => {
413 std::option::Option::Some(v)
414 }
415 _ => std::option::Option::None,
416 })
417 }
418
419 /// Sets the value of [request][crate::model::OperationMetadata::request]
420 /// to hold a `CreateRecognizerRequest`.
421 ///
422 /// Note that all the setters affecting `request` are
423 /// mutually exclusive.
424 ///
425 /// # Example
426 /// ```ignore,no_run
427 /// # use google_cloud_speech_v2::model::OperationMetadata;
428 /// use google_cloud_speech_v2::model::CreateRecognizerRequest;
429 /// let x = OperationMetadata::new().set_create_recognizer_request(CreateRecognizerRequest::default()/* use setters */);
430 /// assert!(x.create_recognizer_request().is_some());
431 /// assert!(x.batch_recognize_request().is_none());
432 /// assert!(x.update_recognizer_request().is_none());
433 /// assert!(x.delete_recognizer_request().is_none());
434 /// assert!(x.undelete_recognizer_request().is_none());
435 /// assert!(x.create_custom_class_request().is_none());
436 /// assert!(x.update_custom_class_request().is_none());
437 /// assert!(x.delete_custom_class_request().is_none());
438 /// assert!(x.undelete_custom_class_request().is_none());
439 /// assert!(x.create_phrase_set_request().is_none());
440 /// assert!(x.update_phrase_set_request().is_none());
441 /// assert!(x.delete_phrase_set_request().is_none());
442 /// assert!(x.undelete_phrase_set_request().is_none());
443 /// assert!(x.update_config_request().is_none());
444 /// ```
445 pub fn set_create_recognizer_request<
446 T: std::convert::Into<std::boxed::Box<crate::model::CreateRecognizerRequest>>,
447 >(
448 mut self,
449 v: T,
450 ) -> Self {
451 self.request = std::option::Option::Some(
452 crate::model::operation_metadata::Request::CreateRecognizerRequest(v.into()),
453 );
454 self
455 }
456
457 /// The value of [request][crate::model::OperationMetadata::request]
458 /// if it holds a `UpdateRecognizerRequest`, `None` if the field is not set or
459 /// holds a different branch.
460 pub fn update_recognizer_request(
461 &self,
462 ) -> std::option::Option<&std::boxed::Box<crate::model::UpdateRecognizerRequest>> {
463 #[allow(unreachable_patterns)]
464 self.request.as_ref().and_then(|v| match v {
465 crate::model::operation_metadata::Request::UpdateRecognizerRequest(v) => {
466 std::option::Option::Some(v)
467 }
468 _ => std::option::Option::None,
469 })
470 }
471
472 /// Sets the value of [request][crate::model::OperationMetadata::request]
473 /// to hold a `UpdateRecognizerRequest`.
474 ///
475 /// Note that all the setters affecting `request` are
476 /// mutually exclusive.
477 ///
478 /// # Example
479 /// ```ignore,no_run
480 /// # use google_cloud_speech_v2::model::OperationMetadata;
481 /// use google_cloud_speech_v2::model::UpdateRecognizerRequest;
482 /// let x = OperationMetadata::new().set_update_recognizer_request(UpdateRecognizerRequest::default()/* use setters */);
483 /// assert!(x.update_recognizer_request().is_some());
484 /// assert!(x.batch_recognize_request().is_none());
485 /// assert!(x.create_recognizer_request().is_none());
486 /// assert!(x.delete_recognizer_request().is_none());
487 /// assert!(x.undelete_recognizer_request().is_none());
488 /// assert!(x.create_custom_class_request().is_none());
489 /// assert!(x.update_custom_class_request().is_none());
490 /// assert!(x.delete_custom_class_request().is_none());
491 /// assert!(x.undelete_custom_class_request().is_none());
492 /// assert!(x.create_phrase_set_request().is_none());
493 /// assert!(x.update_phrase_set_request().is_none());
494 /// assert!(x.delete_phrase_set_request().is_none());
495 /// assert!(x.undelete_phrase_set_request().is_none());
496 /// assert!(x.update_config_request().is_none());
497 /// ```
498 pub fn set_update_recognizer_request<
499 T: std::convert::Into<std::boxed::Box<crate::model::UpdateRecognizerRequest>>,
500 >(
501 mut self,
502 v: T,
503 ) -> Self {
504 self.request = std::option::Option::Some(
505 crate::model::operation_metadata::Request::UpdateRecognizerRequest(v.into()),
506 );
507 self
508 }
509
510 /// The value of [request][crate::model::OperationMetadata::request]
511 /// if it holds a `DeleteRecognizerRequest`, `None` if the field is not set or
512 /// holds a different branch.
513 pub fn delete_recognizer_request(
514 &self,
515 ) -> std::option::Option<&std::boxed::Box<crate::model::DeleteRecognizerRequest>> {
516 #[allow(unreachable_patterns)]
517 self.request.as_ref().and_then(|v| match v {
518 crate::model::operation_metadata::Request::DeleteRecognizerRequest(v) => {
519 std::option::Option::Some(v)
520 }
521 _ => std::option::Option::None,
522 })
523 }
524
525 /// Sets the value of [request][crate::model::OperationMetadata::request]
526 /// to hold a `DeleteRecognizerRequest`.
527 ///
528 /// Note that all the setters affecting `request` are
529 /// mutually exclusive.
530 ///
531 /// # Example
532 /// ```ignore,no_run
533 /// # use google_cloud_speech_v2::model::OperationMetadata;
534 /// use google_cloud_speech_v2::model::DeleteRecognizerRequest;
535 /// let x = OperationMetadata::new().set_delete_recognizer_request(DeleteRecognizerRequest::default()/* use setters */);
536 /// assert!(x.delete_recognizer_request().is_some());
537 /// assert!(x.batch_recognize_request().is_none());
538 /// assert!(x.create_recognizer_request().is_none());
539 /// assert!(x.update_recognizer_request().is_none());
540 /// assert!(x.undelete_recognizer_request().is_none());
541 /// assert!(x.create_custom_class_request().is_none());
542 /// assert!(x.update_custom_class_request().is_none());
543 /// assert!(x.delete_custom_class_request().is_none());
544 /// assert!(x.undelete_custom_class_request().is_none());
545 /// assert!(x.create_phrase_set_request().is_none());
546 /// assert!(x.update_phrase_set_request().is_none());
547 /// assert!(x.delete_phrase_set_request().is_none());
548 /// assert!(x.undelete_phrase_set_request().is_none());
549 /// assert!(x.update_config_request().is_none());
550 /// ```
551 pub fn set_delete_recognizer_request<
552 T: std::convert::Into<std::boxed::Box<crate::model::DeleteRecognizerRequest>>,
553 >(
554 mut self,
555 v: T,
556 ) -> Self {
557 self.request = std::option::Option::Some(
558 crate::model::operation_metadata::Request::DeleteRecognizerRequest(v.into()),
559 );
560 self
561 }
562
563 /// The value of [request][crate::model::OperationMetadata::request]
564 /// if it holds a `UndeleteRecognizerRequest`, `None` if the field is not set or
565 /// holds a different branch.
566 pub fn undelete_recognizer_request(
567 &self,
568 ) -> std::option::Option<&std::boxed::Box<crate::model::UndeleteRecognizerRequest>> {
569 #[allow(unreachable_patterns)]
570 self.request.as_ref().and_then(|v| match v {
571 crate::model::operation_metadata::Request::UndeleteRecognizerRequest(v) => {
572 std::option::Option::Some(v)
573 }
574 _ => std::option::Option::None,
575 })
576 }
577
578 /// Sets the value of [request][crate::model::OperationMetadata::request]
579 /// to hold a `UndeleteRecognizerRequest`.
580 ///
581 /// Note that all the setters affecting `request` are
582 /// mutually exclusive.
583 ///
584 /// # Example
585 /// ```ignore,no_run
586 /// # use google_cloud_speech_v2::model::OperationMetadata;
587 /// use google_cloud_speech_v2::model::UndeleteRecognizerRequest;
588 /// let x = OperationMetadata::new().set_undelete_recognizer_request(UndeleteRecognizerRequest::default()/* use setters */);
589 /// assert!(x.undelete_recognizer_request().is_some());
590 /// assert!(x.batch_recognize_request().is_none());
591 /// assert!(x.create_recognizer_request().is_none());
592 /// assert!(x.update_recognizer_request().is_none());
593 /// assert!(x.delete_recognizer_request().is_none());
594 /// assert!(x.create_custom_class_request().is_none());
595 /// assert!(x.update_custom_class_request().is_none());
596 /// assert!(x.delete_custom_class_request().is_none());
597 /// assert!(x.undelete_custom_class_request().is_none());
598 /// assert!(x.create_phrase_set_request().is_none());
599 /// assert!(x.update_phrase_set_request().is_none());
600 /// assert!(x.delete_phrase_set_request().is_none());
601 /// assert!(x.undelete_phrase_set_request().is_none());
602 /// assert!(x.update_config_request().is_none());
603 /// ```
604 pub fn set_undelete_recognizer_request<
605 T: std::convert::Into<std::boxed::Box<crate::model::UndeleteRecognizerRequest>>,
606 >(
607 mut self,
608 v: T,
609 ) -> Self {
610 self.request = std::option::Option::Some(
611 crate::model::operation_metadata::Request::UndeleteRecognizerRequest(v.into()),
612 );
613 self
614 }
615
616 /// The value of [request][crate::model::OperationMetadata::request]
617 /// if it holds a `CreateCustomClassRequest`, `None` if the field is not set or
618 /// holds a different branch.
619 pub fn create_custom_class_request(
620 &self,
621 ) -> std::option::Option<&std::boxed::Box<crate::model::CreateCustomClassRequest>> {
622 #[allow(unreachable_patterns)]
623 self.request.as_ref().and_then(|v| match v {
624 crate::model::operation_metadata::Request::CreateCustomClassRequest(v) => {
625 std::option::Option::Some(v)
626 }
627 _ => std::option::Option::None,
628 })
629 }
630
631 /// Sets the value of [request][crate::model::OperationMetadata::request]
632 /// to hold a `CreateCustomClassRequest`.
633 ///
634 /// Note that all the setters affecting `request` are
635 /// mutually exclusive.
636 ///
637 /// # Example
638 /// ```ignore,no_run
639 /// # use google_cloud_speech_v2::model::OperationMetadata;
640 /// use google_cloud_speech_v2::model::CreateCustomClassRequest;
641 /// let x = OperationMetadata::new().set_create_custom_class_request(CreateCustomClassRequest::default()/* use setters */);
642 /// assert!(x.create_custom_class_request().is_some());
643 /// assert!(x.batch_recognize_request().is_none());
644 /// assert!(x.create_recognizer_request().is_none());
645 /// assert!(x.update_recognizer_request().is_none());
646 /// assert!(x.delete_recognizer_request().is_none());
647 /// assert!(x.undelete_recognizer_request().is_none());
648 /// assert!(x.update_custom_class_request().is_none());
649 /// assert!(x.delete_custom_class_request().is_none());
650 /// assert!(x.undelete_custom_class_request().is_none());
651 /// assert!(x.create_phrase_set_request().is_none());
652 /// assert!(x.update_phrase_set_request().is_none());
653 /// assert!(x.delete_phrase_set_request().is_none());
654 /// assert!(x.undelete_phrase_set_request().is_none());
655 /// assert!(x.update_config_request().is_none());
656 /// ```
657 pub fn set_create_custom_class_request<
658 T: std::convert::Into<std::boxed::Box<crate::model::CreateCustomClassRequest>>,
659 >(
660 mut self,
661 v: T,
662 ) -> Self {
663 self.request = std::option::Option::Some(
664 crate::model::operation_metadata::Request::CreateCustomClassRequest(v.into()),
665 );
666 self
667 }
668
669 /// The value of [request][crate::model::OperationMetadata::request]
670 /// if it holds a `UpdateCustomClassRequest`, `None` if the field is not set or
671 /// holds a different branch.
672 pub fn update_custom_class_request(
673 &self,
674 ) -> std::option::Option<&std::boxed::Box<crate::model::UpdateCustomClassRequest>> {
675 #[allow(unreachable_patterns)]
676 self.request.as_ref().and_then(|v| match v {
677 crate::model::operation_metadata::Request::UpdateCustomClassRequest(v) => {
678 std::option::Option::Some(v)
679 }
680 _ => std::option::Option::None,
681 })
682 }
683
684 /// Sets the value of [request][crate::model::OperationMetadata::request]
685 /// to hold a `UpdateCustomClassRequest`.
686 ///
687 /// Note that all the setters affecting `request` are
688 /// mutually exclusive.
689 ///
690 /// # Example
691 /// ```ignore,no_run
692 /// # use google_cloud_speech_v2::model::OperationMetadata;
693 /// use google_cloud_speech_v2::model::UpdateCustomClassRequest;
694 /// let x = OperationMetadata::new().set_update_custom_class_request(UpdateCustomClassRequest::default()/* use setters */);
695 /// assert!(x.update_custom_class_request().is_some());
696 /// assert!(x.batch_recognize_request().is_none());
697 /// assert!(x.create_recognizer_request().is_none());
698 /// assert!(x.update_recognizer_request().is_none());
699 /// assert!(x.delete_recognizer_request().is_none());
700 /// assert!(x.undelete_recognizer_request().is_none());
701 /// assert!(x.create_custom_class_request().is_none());
702 /// assert!(x.delete_custom_class_request().is_none());
703 /// assert!(x.undelete_custom_class_request().is_none());
704 /// assert!(x.create_phrase_set_request().is_none());
705 /// assert!(x.update_phrase_set_request().is_none());
706 /// assert!(x.delete_phrase_set_request().is_none());
707 /// assert!(x.undelete_phrase_set_request().is_none());
708 /// assert!(x.update_config_request().is_none());
709 /// ```
710 pub fn set_update_custom_class_request<
711 T: std::convert::Into<std::boxed::Box<crate::model::UpdateCustomClassRequest>>,
712 >(
713 mut self,
714 v: T,
715 ) -> Self {
716 self.request = std::option::Option::Some(
717 crate::model::operation_metadata::Request::UpdateCustomClassRequest(v.into()),
718 );
719 self
720 }
721
722 /// The value of [request][crate::model::OperationMetadata::request]
723 /// if it holds a `DeleteCustomClassRequest`, `None` if the field is not set or
724 /// holds a different branch.
725 pub fn delete_custom_class_request(
726 &self,
727 ) -> std::option::Option<&std::boxed::Box<crate::model::DeleteCustomClassRequest>> {
728 #[allow(unreachable_patterns)]
729 self.request.as_ref().and_then(|v| match v {
730 crate::model::operation_metadata::Request::DeleteCustomClassRequest(v) => {
731 std::option::Option::Some(v)
732 }
733 _ => std::option::Option::None,
734 })
735 }
736
737 /// Sets the value of [request][crate::model::OperationMetadata::request]
738 /// to hold a `DeleteCustomClassRequest`.
739 ///
740 /// Note that all the setters affecting `request` are
741 /// mutually exclusive.
742 ///
743 /// # Example
744 /// ```ignore,no_run
745 /// # use google_cloud_speech_v2::model::OperationMetadata;
746 /// use google_cloud_speech_v2::model::DeleteCustomClassRequest;
747 /// let x = OperationMetadata::new().set_delete_custom_class_request(DeleteCustomClassRequest::default()/* use setters */);
748 /// assert!(x.delete_custom_class_request().is_some());
749 /// assert!(x.batch_recognize_request().is_none());
750 /// assert!(x.create_recognizer_request().is_none());
751 /// assert!(x.update_recognizer_request().is_none());
752 /// assert!(x.delete_recognizer_request().is_none());
753 /// assert!(x.undelete_recognizer_request().is_none());
754 /// assert!(x.create_custom_class_request().is_none());
755 /// assert!(x.update_custom_class_request().is_none());
756 /// assert!(x.undelete_custom_class_request().is_none());
757 /// assert!(x.create_phrase_set_request().is_none());
758 /// assert!(x.update_phrase_set_request().is_none());
759 /// assert!(x.delete_phrase_set_request().is_none());
760 /// assert!(x.undelete_phrase_set_request().is_none());
761 /// assert!(x.update_config_request().is_none());
762 /// ```
763 pub fn set_delete_custom_class_request<
764 T: std::convert::Into<std::boxed::Box<crate::model::DeleteCustomClassRequest>>,
765 >(
766 mut self,
767 v: T,
768 ) -> Self {
769 self.request = std::option::Option::Some(
770 crate::model::operation_metadata::Request::DeleteCustomClassRequest(v.into()),
771 );
772 self
773 }
774
775 /// The value of [request][crate::model::OperationMetadata::request]
776 /// if it holds a `UndeleteCustomClassRequest`, `None` if the field is not set or
777 /// holds a different branch.
778 pub fn undelete_custom_class_request(
779 &self,
780 ) -> std::option::Option<&std::boxed::Box<crate::model::UndeleteCustomClassRequest>> {
781 #[allow(unreachable_patterns)]
782 self.request.as_ref().and_then(|v| match v {
783 crate::model::operation_metadata::Request::UndeleteCustomClassRequest(v) => {
784 std::option::Option::Some(v)
785 }
786 _ => std::option::Option::None,
787 })
788 }
789
790 /// Sets the value of [request][crate::model::OperationMetadata::request]
791 /// to hold a `UndeleteCustomClassRequest`.
792 ///
793 /// Note that all the setters affecting `request` are
794 /// mutually exclusive.
795 ///
796 /// # Example
797 /// ```ignore,no_run
798 /// # use google_cloud_speech_v2::model::OperationMetadata;
799 /// use google_cloud_speech_v2::model::UndeleteCustomClassRequest;
800 /// let x = OperationMetadata::new().set_undelete_custom_class_request(UndeleteCustomClassRequest::default()/* use setters */);
801 /// assert!(x.undelete_custom_class_request().is_some());
802 /// assert!(x.batch_recognize_request().is_none());
803 /// assert!(x.create_recognizer_request().is_none());
804 /// assert!(x.update_recognizer_request().is_none());
805 /// assert!(x.delete_recognizer_request().is_none());
806 /// assert!(x.undelete_recognizer_request().is_none());
807 /// assert!(x.create_custom_class_request().is_none());
808 /// assert!(x.update_custom_class_request().is_none());
809 /// assert!(x.delete_custom_class_request().is_none());
810 /// assert!(x.create_phrase_set_request().is_none());
811 /// assert!(x.update_phrase_set_request().is_none());
812 /// assert!(x.delete_phrase_set_request().is_none());
813 /// assert!(x.undelete_phrase_set_request().is_none());
814 /// assert!(x.update_config_request().is_none());
815 /// ```
816 pub fn set_undelete_custom_class_request<
817 T: std::convert::Into<std::boxed::Box<crate::model::UndeleteCustomClassRequest>>,
818 >(
819 mut self,
820 v: T,
821 ) -> Self {
822 self.request = std::option::Option::Some(
823 crate::model::operation_metadata::Request::UndeleteCustomClassRequest(v.into()),
824 );
825 self
826 }
827
828 /// The value of [request][crate::model::OperationMetadata::request]
829 /// if it holds a `CreatePhraseSetRequest`, `None` if the field is not set or
830 /// holds a different branch.
831 pub fn create_phrase_set_request(
832 &self,
833 ) -> std::option::Option<&std::boxed::Box<crate::model::CreatePhraseSetRequest>> {
834 #[allow(unreachable_patterns)]
835 self.request.as_ref().and_then(|v| match v {
836 crate::model::operation_metadata::Request::CreatePhraseSetRequest(v) => {
837 std::option::Option::Some(v)
838 }
839 _ => std::option::Option::None,
840 })
841 }
842
843 /// Sets the value of [request][crate::model::OperationMetadata::request]
844 /// to hold a `CreatePhraseSetRequest`.
845 ///
846 /// Note that all the setters affecting `request` are
847 /// mutually exclusive.
848 ///
849 /// # Example
850 /// ```ignore,no_run
851 /// # use google_cloud_speech_v2::model::OperationMetadata;
852 /// use google_cloud_speech_v2::model::CreatePhraseSetRequest;
853 /// let x = OperationMetadata::new().set_create_phrase_set_request(CreatePhraseSetRequest::default()/* use setters */);
854 /// assert!(x.create_phrase_set_request().is_some());
855 /// assert!(x.batch_recognize_request().is_none());
856 /// assert!(x.create_recognizer_request().is_none());
857 /// assert!(x.update_recognizer_request().is_none());
858 /// assert!(x.delete_recognizer_request().is_none());
859 /// assert!(x.undelete_recognizer_request().is_none());
860 /// assert!(x.create_custom_class_request().is_none());
861 /// assert!(x.update_custom_class_request().is_none());
862 /// assert!(x.delete_custom_class_request().is_none());
863 /// assert!(x.undelete_custom_class_request().is_none());
864 /// assert!(x.update_phrase_set_request().is_none());
865 /// assert!(x.delete_phrase_set_request().is_none());
866 /// assert!(x.undelete_phrase_set_request().is_none());
867 /// assert!(x.update_config_request().is_none());
868 /// ```
869 pub fn set_create_phrase_set_request<
870 T: std::convert::Into<std::boxed::Box<crate::model::CreatePhraseSetRequest>>,
871 >(
872 mut self,
873 v: T,
874 ) -> Self {
875 self.request = std::option::Option::Some(
876 crate::model::operation_metadata::Request::CreatePhraseSetRequest(v.into()),
877 );
878 self
879 }
880
881 /// The value of [request][crate::model::OperationMetadata::request]
882 /// if it holds a `UpdatePhraseSetRequest`, `None` if the field is not set or
883 /// holds a different branch.
884 pub fn update_phrase_set_request(
885 &self,
886 ) -> std::option::Option<&std::boxed::Box<crate::model::UpdatePhraseSetRequest>> {
887 #[allow(unreachable_patterns)]
888 self.request.as_ref().and_then(|v| match v {
889 crate::model::operation_metadata::Request::UpdatePhraseSetRequest(v) => {
890 std::option::Option::Some(v)
891 }
892 _ => std::option::Option::None,
893 })
894 }
895
896 /// Sets the value of [request][crate::model::OperationMetadata::request]
897 /// to hold a `UpdatePhraseSetRequest`.
898 ///
899 /// Note that all the setters affecting `request` are
900 /// mutually exclusive.
901 ///
902 /// # Example
903 /// ```ignore,no_run
904 /// # use google_cloud_speech_v2::model::OperationMetadata;
905 /// use google_cloud_speech_v2::model::UpdatePhraseSetRequest;
906 /// let x = OperationMetadata::new().set_update_phrase_set_request(UpdatePhraseSetRequest::default()/* use setters */);
907 /// assert!(x.update_phrase_set_request().is_some());
908 /// assert!(x.batch_recognize_request().is_none());
909 /// assert!(x.create_recognizer_request().is_none());
910 /// assert!(x.update_recognizer_request().is_none());
911 /// assert!(x.delete_recognizer_request().is_none());
912 /// assert!(x.undelete_recognizer_request().is_none());
913 /// assert!(x.create_custom_class_request().is_none());
914 /// assert!(x.update_custom_class_request().is_none());
915 /// assert!(x.delete_custom_class_request().is_none());
916 /// assert!(x.undelete_custom_class_request().is_none());
917 /// assert!(x.create_phrase_set_request().is_none());
918 /// assert!(x.delete_phrase_set_request().is_none());
919 /// assert!(x.undelete_phrase_set_request().is_none());
920 /// assert!(x.update_config_request().is_none());
921 /// ```
922 pub fn set_update_phrase_set_request<
923 T: std::convert::Into<std::boxed::Box<crate::model::UpdatePhraseSetRequest>>,
924 >(
925 mut self,
926 v: T,
927 ) -> Self {
928 self.request = std::option::Option::Some(
929 crate::model::operation_metadata::Request::UpdatePhraseSetRequest(v.into()),
930 );
931 self
932 }
933
934 /// The value of [request][crate::model::OperationMetadata::request]
935 /// if it holds a `DeletePhraseSetRequest`, `None` if the field is not set or
936 /// holds a different branch.
937 pub fn delete_phrase_set_request(
938 &self,
939 ) -> std::option::Option<&std::boxed::Box<crate::model::DeletePhraseSetRequest>> {
940 #[allow(unreachable_patterns)]
941 self.request.as_ref().and_then(|v| match v {
942 crate::model::operation_metadata::Request::DeletePhraseSetRequest(v) => {
943 std::option::Option::Some(v)
944 }
945 _ => std::option::Option::None,
946 })
947 }
948
949 /// Sets the value of [request][crate::model::OperationMetadata::request]
950 /// to hold a `DeletePhraseSetRequest`.
951 ///
952 /// Note that all the setters affecting `request` are
953 /// mutually exclusive.
954 ///
955 /// # Example
956 /// ```ignore,no_run
957 /// # use google_cloud_speech_v2::model::OperationMetadata;
958 /// use google_cloud_speech_v2::model::DeletePhraseSetRequest;
959 /// let x = OperationMetadata::new().set_delete_phrase_set_request(DeletePhraseSetRequest::default()/* use setters */);
960 /// assert!(x.delete_phrase_set_request().is_some());
961 /// assert!(x.batch_recognize_request().is_none());
962 /// assert!(x.create_recognizer_request().is_none());
963 /// assert!(x.update_recognizer_request().is_none());
964 /// assert!(x.delete_recognizer_request().is_none());
965 /// assert!(x.undelete_recognizer_request().is_none());
966 /// assert!(x.create_custom_class_request().is_none());
967 /// assert!(x.update_custom_class_request().is_none());
968 /// assert!(x.delete_custom_class_request().is_none());
969 /// assert!(x.undelete_custom_class_request().is_none());
970 /// assert!(x.create_phrase_set_request().is_none());
971 /// assert!(x.update_phrase_set_request().is_none());
972 /// assert!(x.undelete_phrase_set_request().is_none());
973 /// assert!(x.update_config_request().is_none());
974 /// ```
975 pub fn set_delete_phrase_set_request<
976 T: std::convert::Into<std::boxed::Box<crate::model::DeletePhraseSetRequest>>,
977 >(
978 mut self,
979 v: T,
980 ) -> Self {
981 self.request = std::option::Option::Some(
982 crate::model::operation_metadata::Request::DeletePhraseSetRequest(v.into()),
983 );
984 self
985 }
986
987 /// The value of [request][crate::model::OperationMetadata::request]
988 /// if it holds a `UndeletePhraseSetRequest`, `None` if the field is not set or
989 /// holds a different branch.
990 pub fn undelete_phrase_set_request(
991 &self,
992 ) -> std::option::Option<&std::boxed::Box<crate::model::UndeletePhraseSetRequest>> {
993 #[allow(unreachable_patterns)]
994 self.request.as_ref().and_then(|v| match v {
995 crate::model::operation_metadata::Request::UndeletePhraseSetRequest(v) => {
996 std::option::Option::Some(v)
997 }
998 _ => std::option::Option::None,
999 })
1000 }
1001
1002 /// Sets the value of [request][crate::model::OperationMetadata::request]
1003 /// to hold a `UndeletePhraseSetRequest`.
1004 ///
1005 /// Note that all the setters affecting `request` are
1006 /// mutually exclusive.
1007 ///
1008 /// # Example
1009 /// ```ignore,no_run
1010 /// # use google_cloud_speech_v2::model::OperationMetadata;
1011 /// use google_cloud_speech_v2::model::UndeletePhraseSetRequest;
1012 /// let x = OperationMetadata::new().set_undelete_phrase_set_request(UndeletePhraseSetRequest::default()/* use setters */);
1013 /// assert!(x.undelete_phrase_set_request().is_some());
1014 /// assert!(x.batch_recognize_request().is_none());
1015 /// assert!(x.create_recognizer_request().is_none());
1016 /// assert!(x.update_recognizer_request().is_none());
1017 /// assert!(x.delete_recognizer_request().is_none());
1018 /// assert!(x.undelete_recognizer_request().is_none());
1019 /// assert!(x.create_custom_class_request().is_none());
1020 /// assert!(x.update_custom_class_request().is_none());
1021 /// assert!(x.delete_custom_class_request().is_none());
1022 /// assert!(x.undelete_custom_class_request().is_none());
1023 /// assert!(x.create_phrase_set_request().is_none());
1024 /// assert!(x.update_phrase_set_request().is_none());
1025 /// assert!(x.delete_phrase_set_request().is_none());
1026 /// assert!(x.update_config_request().is_none());
1027 /// ```
1028 pub fn set_undelete_phrase_set_request<
1029 T: std::convert::Into<std::boxed::Box<crate::model::UndeletePhraseSetRequest>>,
1030 >(
1031 mut self,
1032 v: T,
1033 ) -> Self {
1034 self.request = std::option::Option::Some(
1035 crate::model::operation_metadata::Request::UndeletePhraseSetRequest(v.into()),
1036 );
1037 self
1038 }
1039
1040 /// The value of [request][crate::model::OperationMetadata::request]
1041 /// if it holds a `UpdateConfigRequest`, `None` if the field is not set or
1042 /// holds a different branch.
1043 #[deprecated]
1044 pub fn update_config_request(
1045 &self,
1046 ) -> std::option::Option<&std::boxed::Box<crate::model::UpdateConfigRequest>> {
1047 #[allow(unreachable_patterns)]
1048 self.request.as_ref().and_then(|v| match v {
1049 crate::model::operation_metadata::Request::UpdateConfigRequest(v) => {
1050 std::option::Option::Some(v)
1051 }
1052 _ => std::option::Option::None,
1053 })
1054 }
1055
1056 /// Sets the value of [request][crate::model::OperationMetadata::request]
1057 /// to hold a `UpdateConfigRequest`.
1058 ///
1059 /// Note that all the setters affecting `request` are
1060 /// mutually exclusive.
1061 ///
1062 /// # Example
1063 /// ```ignore,no_run
1064 /// # use google_cloud_speech_v2::model::OperationMetadata;
1065 /// use google_cloud_speech_v2::model::UpdateConfigRequest;
1066 /// let x = OperationMetadata::new().set_update_config_request(UpdateConfigRequest::default()/* use setters */);
1067 /// assert!(x.update_config_request().is_some());
1068 /// assert!(x.batch_recognize_request().is_none());
1069 /// assert!(x.create_recognizer_request().is_none());
1070 /// assert!(x.update_recognizer_request().is_none());
1071 /// assert!(x.delete_recognizer_request().is_none());
1072 /// assert!(x.undelete_recognizer_request().is_none());
1073 /// assert!(x.create_custom_class_request().is_none());
1074 /// assert!(x.update_custom_class_request().is_none());
1075 /// assert!(x.delete_custom_class_request().is_none());
1076 /// assert!(x.undelete_custom_class_request().is_none());
1077 /// assert!(x.create_phrase_set_request().is_none());
1078 /// assert!(x.update_phrase_set_request().is_none());
1079 /// assert!(x.delete_phrase_set_request().is_none());
1080 /// assert!(x.undelete_phrase_set_request().is_none());
1081 /// ```
1082 #[deprecated]
1083 pub fn set_update_config_request<
1084 T: std::convert::Into<std::boxed::Box<crate::model::UpdateConfigRequest>>,
1085 >(
1086 mut self,
1087 v: T,
1088 ) -> Self {
1089 self.request = std::option::Option::Some(
1090 crate::model::operation_metadata::Request::UpdateConfigRequest(v.into()),
1091 );
1092 self
1093 }
1094
1095 /// Sets the value of [metadata][crate::model::OperationMetadata::metadata].
1096 ///
1097 /// Note that all the setters affecting `metadata` are mutually
1098 /// exclusive.
1099 ///
1100 /// # Example
1101 /// ```ignore,no_run
1102 /// # use google_cloud_speech_v2::model::OperationMetadata;
1103 /// use google_cloud_speech_v2::model::BatchRecognizeMetadata;
1104 /// let x = OperationMetadata::new().set_metadata(Some(
1105 /// google_cloud_speech_v2::model::operation_metadata::Metadata::BatchRecognizeMetadata(BatchRecognizeMetadata::default().into())));
1106 /// ```
1107 pub fn set_metadata<
1108 T: std::convert::Into<std::option::Option<crate::model::operation_metadata::Metadata>>,
1109 >(
1110 mut self,
1111 v: T,
1112 ) -> Self {
1113 self.metadata = v.into();
1114 self
1115 }
1116
1117 /// The value of [metadata][crate::model::OperationMetadata::metadata]
1118 /// if it holds a `BatchRecognizeMetadata`, `None` if the field is not set or
1119 /// holds a different branch.
1120 pub fn batch_recognize_metadata(
1121 &self,
1122 ) -> std::option::Option<&std::boxed::Box<crate::model::BatchRecognizeMetadata>> {
1123 #[allow(unreachable_patterns)]
1124 self.metadata.as_ref().and_then(|v| match v {
1125 crate::model::operation_metadata::Metadata::BatchRecognizeMetadata(v) => {
1126 std::option::Option::Some(v)
1127 }
1128 _ => std::option::Option::None,
1129 })
1130 }
1131
1132 /// Sets the value of [metadata][crate::model::OperationMetadata::metadata]
1133 /// to hold a `BatchRecognizeMetadata`.
1134 ///
1135 /// Note that all the setters affecting `metadata` are
1136 /// mutually exclusive.
1137 ///
1138 /// # Example
1139 /// ```ignore,no_run
1140 /// # use google_cloud_speech_v2::model::OperationMetadata;
1141 /// use google_cloud_speech_v2::model::BatchRecognizeMetadata;
1142 /// let x = OperationMetadata::new().set_batch_recognize_metadata(BatchRecognizeMetadata::default()/* use setters */);
1143 /// assert!(x.batch_recognize_metadata().is_some());
1144 /// ```
1145 pub fn set_batch_recognize_metadata<
1146 T: std::convert::Into<std::boxed::Box<crate::model::BatchRecognizeMetadata>>,
1147 >(
1148 mut self,
1149 v: T,
1150 ) -> Self {
1151 self.metadata = std::option::Option::Some(
1152 crate::model::operation_metadata::Metadata::BatchRecognizeMetadata(v.into()),
1153 );
1154 self
1155 }
1156}
1157
1158impl wkt::message::Message for OperationMetadata {
1159 fn typename() -> &'static str {
1160 "type.googleapis.com/google.cloud.speech.v2.OperationMetadata"
1161 }
1162}
1163
1164/// Defines additional types related to [OperationMetadata].
1165pub mod operation_metadata {
1166 #[allow(unused_imports)]
1167 use super::*;
1168
1169 /// The request that spawned the Operation.
1170 #[derive(Clone, Debug, PartialEq)]
1171 #[non_exhaustive]
1172 pub enum Request {
1173 /// The BatchRecognizeRequest that spawned the Operation.
1174 BatchRecognizeRequest(std::boxed::Box<crate::model::BatchRecognizeRequest>),
1175 /// The CreateRecognizerRequest that spawned the Operation.
1176 CreateRecognizerRequest(std::boxed::Box<crate::model::CreateRecognizerRequest>),
1177 /// The UpdateRecognizerRequest that spawned the Operation.
1178 UpdateRecognizerRequest(std::boxed::Box<crate::model::UpdateRecognizerRequest>),
1179 /// The DeleteRecognizerRequest that spawned the Operation.
1180 DeleteRecognizerRequest(std::boxed::Box<crate::model::DeleteRecognizerRequest>),
1181 /// The UndeleteRecognizerRequest that spawned the Operation.
1182 UndeleteRecognizerRequest(std::boxed::Box<crate::model::UndeleteRecognizerRequest>),
1183 /// The CreateCustomClassRequest that spawned the Operation.
1184 CreateCustomClassRequest(std::boxed::Box<crate::model::CreateCustomClassRequest>),
1185 /// The UpdateCustomClassRequest that spawned the Operation.
1186 UpdateCustomClassRequest(std::boxed::Box<crate::model::UpdateCustomClassRequest>),
1187 /// The DeleteCustomClassRequest that spawned the Operation.
1188 DeleteCustomClassRequest(std::boxed::Box<crate::model::DeleteCustomClassRequest>),
1189 /// The UndeleteCustomClassRequest that spawned the Operation.
1190 UndeleteCustomClassRequest(std::boxed::Box<crate::model::UndeleteCustomClassRequest>),
1191 /// The CreatePhraseSetRequest that spawned the Operation.
1192 CreatePhraseSetRequest(std::boxed::Box<crate::model::CreatePhraseSetRequest>),
1193 /// The UpdatePhraseSetRequest that spawned the Operation.
1194 UpdatePhraseSetRequest(std::boxed::Box<crate::model::UpdatePhraseSetRequest>),
1195 /// The DeletePhraseSetRequest that spawned the Operation.
1196 DeletePhraseSetRequest(std::boxed::Box<crate::model::DeletePhraseSetRequest>),
1197 /// The UndeletePhraseSetRequest that spawned the Operation.
1198 UndeletePhraseSetRequest(std::boxed::Box<crate::model::UndeletePhraseSetRequest>),
1199 /// The UpdateConfigRequest that spawned the Operation.
1200 #[deprecated]
1201 UpdateConfigRequest(std::boxed::Box<crate::model::UpdateConfigRequest>),
1202 }
1203
1204 /// Specific metadata per RPC.
1205 #[derive(Clone, Debug, PartialEq)]
1206 #[non_exhaustive]
1207 pub enum Metadata {
1208 /// Metadata specific to the BatchRecognize method.
1209 BatchRecognizeMetadata(std::boxed::Box<crate::model::BatchRecognizeMetadata>),
1210 }
1211}
1212
1213/// Request message for the
1214/// [ListRecognizers][google.cloud.speech.v2.Speech.ListRecognizers] method.
1215///
1216/// [google.cloud.speech.v2.Speech.ListRecognizers]: crate::client::Speech::list_recognizers
1217#[derive(Clone, Default, PartialEq)]
1218#[non_exhaustive]
1219pub struct ListRecognizersRequest {
1220 /// Required. The project and location of Recognizers to list. The expected
1221 /// format is `projects/{project}/locations/{location}`.
1222 pub parent: std::string::String,
1223
1224 /// The maximum number of Recognizers to return. The service may return fewer
1225 /// than this value. If unspecified, at most 5 Recognizers will be returned.
1226 /// The maximum value is 100; values above 100 will be coerced to 100.
1227 pub page_size: i32,
1228
1229 /// A page token, received from a previous
1230 /// [ListRecognizers][google.cloud.speech.v2.Speech.ListRecognizers] call.
1231 /// Provide this to retrieve the subsequent page.
1232 ///
1233 /// When paginating, all other parameters provided to
1234 /// [ListRecognizers][google.cloud.speech.v2.Speech.ListRecognizers] must match
1235 /// the call that provided the page token.
1236 ///
1237 /// [google.cloud.speech.v2.Speech.ListRecognizers]: crate::client::Speech::list_recognizers
1238 pub page_token: std::string::String,
1239
1240 /// Whether, or not, to show resources that have been deleted.
1241 pub show_deleted: bool,
1242
1243 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1244}
1245
1246impl ListRecognizersRequest {
1247 /// Creates a new default instance.
1248 pub fn new() -> Self {
1249 std::default::Default::default()
1250 }
1251
1252 /// Sets the value of [parent][crate::model::ListRecognizersRequest::parent].
1253 ///
1254 /// # Example
1255 /// ```ignore,no_run
1256 /// # use google_cloud_speech_v2::model::ListRecognizersRequest;
1257 /// let x = ListRecognizersRequest::new().set_parent("example");
1258 /// ```
1259 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1260 self.parent = v.into();
1261 self
1262 }
1263
1264 /// Sets the value of [page_size][crate::model::ListRecognizersRequest::page_size].
1265 ///
1266 /// # Example
1267 /// ```ignore,no_run
1268 /// # use google_cloud_speech_v2::model::ListRecognizersRequest;
1269 /// let x = ListRecognizersRequest::new().set_page_size(42);
1270 /// ```
1271 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1272 self.page_size = v.into();
1273 self
1274 }
1275
1276 /// Sets the value of [page_token][crate::model::ListRecognizersRequest::page_token].
1277 ///
1278 /// # Example
1279 /// ```ignore,no_run
1280 /// # use google_cloud_speech_v2::model::ListRecognizersRequest;
1281 /// let x = ListRecognizersRequest::new().set_page_token("example");
1282 /// ```
1283 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1284 self.page_token = v.into();
1285 self
1286 }
1287
1288 /// Sets the value of [show_deleted][crate::model::ListRecognizersRequest::show_deleted].
1289 ///
1290 /// # Example
1291 /// ```ignore,no_run
1292 /// # use google_cloud_speech_v2::model::ListRecognizersRequest;
1293 /// let x = ListRecognizersRequest::new().set_show_deleted(true);
1294 /// ```
1295 pub fn set_show_deleted<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1296 self.show_deleted = v.into();
1297 self
1298 }
1299}
1300
1301impl wkt::message::Message for ListRecognizersRequest {
1302 fn typename() -> &'static str {
1303 "type.googleapis.com/google.cloud.speech.v2.ListRecognizersRequest"
1304 }
1305}
1306
1307/// Response message for the
1308/// [ListRecognizers][google.cloud.speech.v2.Speech.ListRecognizers] method.
1309///
1310/// [google.cloud.speech.v2.Speech.ListRecognizers]: crate::client::Speech::list_recognizers
1311#[derive(Clone, Default, PartialEq)]
1312#[non_exhaustive]
1313pub struct ListRecognizersResponse {
1314 /// The list of requested Recognizers.
1315 pub recognizers: std::vec::Vec<crate::model::Recognizer>,
1316
1317 /// A token, which can be sent as
1318 /// [page_token][google.cloud.speech.v2.ListRecognizersRequest.page_token] to
1319 /// retrieve the next page. If this field is omitted, there are no subsequent
1320 /// pages. This token expires after 72 hours.
1321 ///
1322 /// [google.cloud.speech.v2.ListRecognizersRequest.page_token]: crate::model::ListRecognizersRequest::page_token
1323 pub next_page_token: std::string::String,
1324
1325 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1326}
1327
1328impl ListRecognizersResponse {
1329 /// Creates a new default instance.
1330 pub fn new() -> Self {
1331 std::default::Default::default()
1332 }
1333
1334 /// Sets the value of [recognizers][crate::model::ListRecognizersResponse::recognizers].
1335 ///
1336 /// # Example
1337 /// ```ignore,no_run
1338 /// # use google_cloud_speech_v2::model::ListRecognizersResponse;
1339 /// use google_cloud_speech_v2::model::Recognizer;
1340 /// let x = ListRecognizersResponse::new()
1341 /// .set_recognizers([
1342 /// Recognizer::default()/* use setters */,
1343 /// Recognizer::default()/* use (different) setters */,
1344 /// ]);
1345 /// ```
1346 pub fn set_recognizers<T, V>(mut self, v: T) -> Self
1347 where
1348 T: std::iter::IntoIterator<Item = V>,
1349 V: std::convert::Into<crate::model::Recognizer>,
1350 {
1351 use std::iter::Iterator;
1352 self.recognizers = v.into_iter().map(|i| i.into()).collect();
1353 self
1354 }
1355
1356 /// Sets the value of [next_page_token][crate::model::ListRecognizersResponse::next_page_token].
1357 ///
1358 /// # Example
1359 /// ```ignore,no_run
1360 /// # use google_cloud_speech_v2::model::ListRecognizersResponse;
1361 /// let x = ListRecognizersResponse::new().set_next_page_token("example");
1362 /// ```
1363 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1364 self.next_page_token = v.into();
1365 self
1366 }
1367}
1368
1369impl wkt::message::Message for ListRecognizersResponse {
1370 fn typename() -> &'static str {
1371 "type.googleapis.com/google.cloud.speech.v2.ListRecognizersResponse"
1372 }
1373}
1374
1375#[doc(hidden)]
1376impl google_cloud_gax::paginator::internal::PageableResponse for ListRecognizersResponse {
1377 type PageItem = crate::model::Recognizer;
1378
1379 fn items(self) -> std::vec::Vec<Self::PageItem> {
1380 self.recognizers
1381 }
1382
1383 fn next_page_token(&self) -> std::string::String {
1384 use std::clone::Clone;
1385 self.next_page_token.clone()
1386 }
1387}
1388
1389/// Request message for the
1390/// [GetRecognizer][google.cloud.speech.v2.Speech.GetRecognizer] method.
1391///
1392/// [google.cloud.speech.v2.Speech.GetRecognizer]: crate::client::Speech::get_recognizer
1393#[derive(Clone, Default, PartialEq)]
1394#[non_exhaustive]
1395pub struct GetRecognizerRequest {
1396 /// Required. The name of the Recognizer to retrieve. The expected format is
1397 /// `projects/{project}/locations/{location}/recognizers/{recognizer}`.
1398 pub name: std::string::String,
1399
1400 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1401}
1402
1403impl GetRecognizerRequest {
1404 /// Creates a new default instance.
1405 pub fn new() -> Self {
1406 std::default::Default::default()
1407 }
1408
1409 /// Sets the value of [name][crate::model::GetRecognizerRequest::name].
1410 ///
1411 /// # Example
1412 /// ```ignore,no_run
1413 /// # use google_cloud_speech_v2::model::GetRecognizerRequest;
1414 /// # let project_id = "project_id";
1415 /// # let location_id = "location_id";
1416 /// # let recognizer_id = "recognizer_id";
1417 /// let x = GetRecognizerRequest::new().set_name(format!("projects/{project_id}/locations/{location_id}/recognizers/{recognizer_id}"));
1418 /// ```
1419 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1420 self.name = v.into();
1421 self
1422 }
1423}
1424
1425impl wkt::message::Message for GetRecognizerRequest {
1426 fn typename() -> &'static str {
1427 "type.googleapis.com/google.cloud.speech.v2.GetRecognizerRequest"
1428 }
1429}
1430
1431/// Request message for the
1432/// [UpdateRecognizer][google.cloud.speech.v2.Speech.UpdateRecognizer] method.
1433///
1434/// [google.cloud.speech.v2.Speech.UpdateRecognizer]: crate::client::Speech::update_recognizer
1435#[derive(Clone, Default, PartialEq)]
1436#[non_exhaustive]
1437pub struct UpdateRecognizerRequest {
1438 /// Required. The Recognizer to update.
1439 ///
1440 /// The Recognizer's `name` field is used to identify the Recognizer to update.
1441 /// Format: `projects/{project}/locations/{location}/recognizers/{recognizer}`.
1442 pub recognizer: std::option::Option<crate::model::Recognizer>,
1443
1444 /// The list of fields to update. If empty, all non-default valued fields are
1445 /// considered for update. Use `*` to update the entire Recognizer resource.
1446 pub update_mask: std::option::Option<wkt::FieldMask>,
1447
1448 /// If set, validate the request and preview the updated Recognizer, but do not
1449 /// actually update it.
1450 pub validate_only: bool,
1451
1452 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1453}
1454
1455impl UpdateRecognizerRequest {
1456 /// Creates a new default instance.
1457 pub fn new() -> Self {
1458 std::default::Default::default()
1459 }
1460
1461 /// Sets the value of [recognizer][crate::model::UpdateRecognizerRequest::recognizer].
1462 ///
1463 /// # Example
1464 /// ```ignore,no_run
1465 /// # use google_cloud_speech_v2::model::UpdateRecognizerRequest;
1466 /// use google_cloud_speech_v2::model::Recognizer;
1467 /// let x = UpdateRecognizerRequest::new().set_recognizer(Recognizer::default()/* use setters */);
1468 /// ```
1469 pub fn set_recognizer<T>(mut self, v: T) -> Self
1470 where
1471 T: std::convert::Into<crate::model::Recognizer>,
1472 {
1473 self.recognizer = std::option::Option::Some(v.into());
1474 self
1475 }
1476
1477 /// Sets or clears the value of [recognizer][crate::model::UpdateRecognizerRequest::recognizer].
1478 ///
1479 /// # Example
1480 /// ```ignore,no_run
1481 /// # use google_cloud_speech_v2::model::UpdateRecognizerRequest;
1482 /// use google_cloud_speech_v2::model::Recognizer;
1483 /// let x = UpdateRecognizerRequest::new().set_or_clear_recognizer(Some(Recognizer::default()/* use setters */));
1484 /// let x = UpdateRecognizerRequest::new().set_or_clear_recognizer(None::<Recognizer>);
1485 /// ```
1486 pub fn set_or_clear_recognizer<T>(mut self, v: std::option::Option<T>) -> Self
1487 where
1488 T: std::convert::Into<crate::model::Recognizer>,
1489 {
1490 self.recognizer = v.map(|x| x.into());
1491 self
1492 }
1493
1494 /// Sets the value of [update_mask][crate::model::UpdateRecognizerRequest::update_mask].
1495 ///
1496 /// # Example
1497 /// ```ignore,no_run
1498 /// # use google_cloud_speech_v2::model::UpdateRecognizerRequest;
1499 /// use wkt::FieldMask;
1500 /// let x = UpdateRecognizerRequest::new().set_update_mask(FieldMask::default()/* use setters */);
1501 /// ```
1502 pub fn set_update_mask<T>(mut self, v: T) -> Self
1503 where
1504 T: std::convert::Into<wkt::FieldMask>,
1505 {
1506 self.update_mask = std::option::Option::Some(v.into());
1507 self
1508 }
1509
1510 /// Sets or clears the value of [update_mask][crate::model::UpdateRecognizerRequest::update_mask].
1511 ///
1512 /// # Example
1513 /// ```ignore,no_run
1514 /// # use google_cloud_speech_v2::model::UpdateRecognizerRequest;
1515 /// use wkt::FieldMask;
1516 /// let x = UpdateRecognizerRequest::new().set_or_clear_update_mask(Some(FieldMask::default()/* use setters */));
1517 /// let x = UpdateRecognizerRequest::new().set_or_clear_update_mask(None::<FieldMask>);
1518 /// ```
1519 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
1520 where
1521 T: std::convert::Into<wkt::FieldMask>,
1522 {
1523 self.update_mask = v.map(|x| x.into());
1524 self
1525 }
1526
1527 /// Sets the value of [validate_only][crate::model::UpdateRecognizerRequest::validate_only].
1528 ///
1529 /// # Example
1530 /// ```ignore,no_run
1531 /// # use google_cloud_speech_v2::model::UpdateRecognizerRequest;
1532 /// let x = UpdateRecognizerRequest::new().set_validate_only(true);
1533 /// ```
1534 pub fn set_validate_only<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1535 self.validate_only = v.into();
1536 self
1537 }
1538}
1539
1540impl wkt::message::Message for UpdateRecognizerRequest {
1541 fn typename() -> &'static str {
1542 "type.googleapis.com/google.cloud.speech.v2.UpdateRecognizerRequest"
1543 }
1544}
1545
1546/// Request message for the
1547/// [DeleteRecognizer][google.cloud.speech.v2.Speech.DeleteRecognizer] method.
1548///
1549/// [google.cloud.speech.v2.Speech.DeleteRecognizer]: crate::client::Speech::delete_recognizer
1550#[derive(Clone, Default, PartialEq)]
1551#[non_exhaustive]
1552pub struct DeleteRecognizerRequest {
1553 /// Required. The name of the Recognizer to delete.
1554 /// Format: `projects/{project}/locations/{location}/recognizers/{recognizer}`
1555 pub name: std::string::String,
1556
1557 /// If set, validate the request and preview the deleted Recognizer, but do not
1558 /// actually delete it.
1559 pub validate_only: bool,
1560
1561 /// If set to true, and the Recognizer is not found, the request will succeed
1562 /// and be a no-op (no Operation is recorded in this case).
1563 pub allow_missing: bool,
1564
1565 /// This checksum is computed by the server based on the value of other
1566 /// fields. This may be sent on update, undelete, and delete requests to ensure
1567 /// the client has an up-to-date value before proceeding.
1568 pub etag: std::string::String,
1569
1570 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1571}
1572
1573impl DeleteRecognizerRequest {
1574 /// Creates a new default instance.
1575 pub fn new() -> Self {
1576 std::default::Default::default()
1577 }
1578
1579 /// Sets the value of [name][crate::model::DeleteRecognizerRequest::name].
1580 ///
1581 /// # Example
1582 /// ```ignore,no_run
1583 /// # use google_cloud_speech_v2::model::DeleteRecognizerRequest;
1584 /// # let project_id = "project_id";
1585 /// # let location_id = "location_id";
1586 /// # let recognizer_id = "recognizer_id";
1587 /// let x = DeleteRecognizerRequest::new().set_name(format!("projects/{project_id}/locations/{location_id}/recognizers/{recognizer_id}"));
1588 /// ```
1589 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1590 self.name = v.into();
1591 self
1592 }
1593
1594 /// Sets the value of [validate_only][crate::model::DeleteRecognizerRequest::validate_only].
1595 ///
1596 /// # Example
1597 /// ```ignore,no_run
1598 /// # use google_cloud_speech_v2::model::DeleteRecognizerRequest;
1599 /// let x = DeleteRecognizerRequest::new().set_validate_only(true);
1600 /// ```
1601 pub fn set_validate_only<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1602 self.validate_only = v.into();
1603 self
1604 }
1605
1606 /// Sets the value of [allow_missing][crate::model::DeleteRecognizerRequest::allow_missing].
1607 ///
1608 /// # Example
1609 /// ```ignore,no_run
1610 /// # use google_cloud_speech_v2::model::DeleteRecognizerRequest;
1611 /// let x = DeleteRecognizerRequest::new().set_allow_missing(true);
1612 /// ```
1613 pub fn set_allow_missing<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1614 self.allow_missing = v.into();
1615 self
1616 }
1617
1618 /// Sets the value of [etag][crate::model::DeleteRecognizerRequest::etag].
1619 ///
1620 /// # Example
1621 /// ```ignore,no_run
1622 /// # use google_cloud_speech_v2::model::DeleteRecognizerRequest;
1623 /// let x = DeleteRecognizerRequest::new().set_etag("example");
1624 /// ```
1625 pub fn set_etag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1626 self.etag = v.into();
1627 self
1628 }
1629}
1630
1631impl wkt::message::Message for DeleteRecognizerRequest {
1632 fn typename() -> &'static str {
1633 "type.googleapis.com/google.cloud.speech.v2.DeleteRecognizerRequest"
1634 }
1635}
1636
1637/// Request message for the
1638/// [UndeleteRecognizer][google.cloud.speech.v2.Speech.UndeleteRecognizer]
1639/// method.
1640///
1641/// [google.cloud.speech.v2.Speech.UndeleteRecognizer]: crate::client::Speech::undelete_recognizer
1642#[derive(Clone, Default, PartialEq)]
1643#[non_exhaustive]
1644pub struct UndeleteRecognizerRequest {
1645 /// Required. The name of the Recognizer to undelete.
1646 /// Format: `projects/{project}/locations/{location}/recognizers/{recognizer}`
1647 pub name: std::string::String,
1648
1649 /// If set, validate the request and preview the undeleted Recognizer, but do
1650 /// not actually undelete it.
1651 pub validate_only: bool,
1652
1653 /// This checksum is computed by the server based on the value of other
1654 /// fields. This may be sent on update, undelete, and delete requests to ensure
1655 /// the client has an up-to-date value before proceeding.
1656 pub etag: std::string::String,
1657
1658 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1659}
1660
1661impl UndeleteRecognizerRequest {
1662 /// Creates a new default instance.
1663 pub fn new() -> Self {
1664 std::default::Default::default()
1665 }
1666
1667 /// Sets the value of [name][crate::model::UndeleteRecognizerRequest::name].
1668 ///
1669 /// # Example
1670 /// ```ignore,no_run
1671 /// # use google_cloud_speech_v2::model::UndeleteRecognizerRequest;
1672 /// # let project_id = "project_id";
1673 /// # let location_id = "location_id";
1674 /// # let recognizer_id = "recognizer_id";
1675 /// let x = UndeleteRecognizerRequest::new().set_name(format!("projects/{project_id}/locations/{location_id}/recognizers/{recognizer_id}"));
1676 /// ```
1677 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1678 self.name = v.into();
1679 self
1680 }
1681
1682 /// Sets the value of [validate_only][crate::model::UndeleteRecognizerRequest::validate_only].
1683 ///
1684 /// # Example
1685 /// ```ignore,no_run
1686 /// # use google_cloud_speech_v2::model::UndeleteRecognizerRequest;
1687 /// let x = UndeleteRecognizerRequest::new().set_validate_only(true);
1688 /// ```
1689 pub fn set_validate_only<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1690 self.validate_only = v.into();
1691 self
1692 }
1693
1694 /// Sets the value of [etag][crate::model::UndeleteRecognizerRequest::etag].
1695 ///
1696 /// # Example
1697 /// ```ignore,no_run
1698 /// # use google_cloud_speech_v2::model::UndeleteRecognizerRequest;
1699 /// let x = UndeleteRecognizerRequest::new().set_etag("example");
1700 /// ```
1701 pub fn set_etag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1702 self.etag = v.into();
1703 self
1704 }
1705}
1706
1707impl wkt::message::Message for UndeleteRecognizerRequest {
1708 fn typename() -> &'static str {
1709 "type.googleapis.com/google.cloud.speech.v2.UndeleteRecognizerRequest"
1710 }
1711}
1712
1713/// A Recognizer message. Stores recognition configuration and metadata.
1714#[derive(Clone, Default, PartialEq)]
1715#[non_exhaustive]
1716pub struct Recognizer {
1717 /// Output only. Identifier. The resource name of the Recognizer.
1718 /// Format: `projects/{project}/locations/{location}/recognizers/{recognizer}`.
1719 pub name: std::string::String,
1720
1721 /// Output only. System-assigned unique identifier for the Recognizer.
1722 pub uid: std::string::String,
1723
1724 /// User-settable, human-readable name for the Recognizer. Must be 63
1725 /// characters or less.
1726 pub display_name: std::string::String,
1727
1728 /// Optional. This field is now deprecated. Prefer the
1729 /// [`model`][google.cloud.speech.v2.RecognitionConfig.model] field in the
1730 /// [`RecognitionConfig`][google.cloud.speech.v2.RecognitionConfig] message.
1731 ///
1732 /// Which model to use for recognition requests. Select the model best suited
1733 /// to your domain to get best results.
1734 ///
1735 /// Guidance for choosing which model to use can be found in the [Transcription
1736 /// Models
1737 /// Documentation](https://cloud.google.com/speech-to-text/v2/docs/transcription-model)
1738 /// and the models supported in each region can be found in the [Table Of
1739 /// Supported
1740 /// Models](https://cloud.google.com/speech-to-text/v2/docs/speech-to-text-supported-languages).
1741 ///
1742 /// [google.cloud.speech.v2.RecognitionConfig]: crate::model::RecognitionConfig
1743 /// [google.cloud.speech.v2.RecognitionConfig.model]: crate::model::RecognitionConfig::model
1744 #[deprecated]
1745 pub model: std::string::String,
1746
1747 /// Optional. This field is now deprecated. Prefer the
1748 /// [`language_codes`][google.cloud.speech.v2.RecognitionConfig.language_codes]
1749 /// field in the
1750 /// [`RecognitionConfig`][google.cloud.speech.v2.RecognitionConfig] message.
1751 ///
1752 /// The language of the supplied audio as a
1753 /// [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag.
1754 ///
1755 /// Supported languages for each model are listed in the [Table of Supported
1756 /// Models](https://cloud.google.com/speech-to-text/v2/docs/speech-to-text-supported-languages).
1757 ///
1758 /// If additional languages are provided, recognition result will contain
1759 /// recognition in the most likely language detected. The recognition result
1760 /// will include the language tag of the language detected in the audio.
1761 /// When you create or update a Recognizer, these values are
1762 /// stored in normalized BCP-47 form. For example, "en-us" is stored as
1763 /// "en-US".
1764 ///
1765 /// [google.cloud.speech.v2.RecognitionConfig]: crate::model::RecognitionConfig
1766 /// [google.cloud.speech.v2.RecognitionConfig.language_codes]: crate::model::RecognitionConfig::language_codes
1767 #[deprecated]
1768 pub language_codes: std::vec::Vec<std::string::String>,
1769
1770 /// Default configuration to use for requests with this Recognizer.
1771 /// This can be overwritten by inline configuration in the
1772 /// [RecognizeRequest.config][google.cloud.speech.v2.RecognizeRequest.config]
1773 /// field.
1774 ///
1775 /// [google.cloud.speech.v2.RecognizeRequest.config]: crate::model::RecognizeRequest::config
1776 pub default_recognition_config: std::option::Option<crate::model::RecognitionConfig>,
1777
1778 /// Allows users to store small amounts of arbitrary data.
1779 /// Both the key and the value must be 63 characters or less each.
1780 /// At most 100 annotations.
1781 pub annotations: std::collections::HashMap<std::string::String, std::string::String>,
1782
1783 /// Output only. The Recognizer lifecycle state.
1784 pub state: crate::model::recognizer::State,
1785
1786 /// Output only. Creation time.
1787 pub create_time: std::option::Option<wkt::Timestamp>,
1788
1789 /// Output only. The most recent time this Recognizer was modified.
1790 pub update_time: std::option::Option<wkt::Timestamp>,
1791
1792 /// Output only. The time at which this Recognizer was requested for deletion.
1793 pub delete_time: std::option::Option<wkt::Timestamp>,
1794
1795 /// Output only. The time at which this Recognizer will be purged.
1796 pub expire_time: std::option::Option<wkt::Timestamp>,
1797
1798 /// Output only. This checksum is computed by the server based on the value of
1799 /// other fields. This may be sent on update, undelete, and delete requests to
1800 /// ensure the client has an up-to-date value before proceeding.
1801 pub etag: std::string::String,
1802
1803 /// Output only. Whether or not this Recognizer is in the process of being
1804 /// updated.
1805 pub reconciling: bool,
1806
1807 /// Output only. The [KMS key
1808 /// name](https://cloud.google.com/kms/docs/resource-hierarchy#keys) with which
1809 /// the Recognizer is encrypted. The expected format is
1810 /// `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
1811 pub kms_key_name: std::string::String,
1812
1813 /// Output only. The [KMS key version
1814 /// name](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions)
1815 /// with which the Recognizer is encrypted. The expected format is
1816 /// `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}`.
1817 pub kms_key_version_name: std::string::String,
1818
1819 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1820}
1821
1822impl Recognizer {
1823 /// Creates a new default instance.
1824 pub fn new() -> Self {
1825 std::default::Default::default()
1826 }
1827
1828 /// Sets the value of [name][crate::model::Recognizer::name].
1829 ///
1830 /// # Example
1831 /// ```ignore,no_run
1832 /// # use google_cloud_speech_v2::model::Recognizer;
1833 /// # let project_id = "project_id";
1834 /// # let location_id = "location_id";
1835 /// # let recognizer_id = "recognizer_id";
1836 /// let x = Recognizer::new().set_name(format!("projects/{project_id}/locations/{location_id}/recognizers/{recognizer_id}"));
1837 /// ```
1838 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1839 self.name = v.into();
1840 self
1841 }
1842
1843 /// Sets the value of [uid][crate::model::Recognizer::uid].
1844 ///
1845 /// # Example
1846 /// ```ignore,no_run
1847 /// # use google_cloud_speech_v2::model::Recognizer;
1848 /// let x = Recognizer::new().set_uid("example");
1849 /// ```
1850 pub fn set_uid<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1851 self.uid = v.into();
1852 self
1853 }
1854
1855 /// Sets the value of [display_name][crate::model::Recognizer::display_name].
1856 ///
1857 /// # Example
1858 /// ```ignore,no_run
1859 /// # use google_cloud_speech_v2::model::Recognizer;
1860 /// let x = Recognizer::new().set_display_name("example");
1861 /// ```
1862 pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1863 self.display_name = v.into();
1864 self
1865 }
1866
1867 /// Sets the value of [model][crate::model::Recognizer::model].
1868 ///
1869 /// # Example
1870 /// ```ignore,no_run
1871 /// # use google_cloud_speech_v2::model::Recognizer;
1872 /// let x = Recognizer::new().set_model("example");
1873 /// ```
1874 #[deprecated]
1875 pub fn set_model<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1876 self.model = v.into();
1877 self
1878 }
1879
1880 /// Sets the value of [language_codes][crate::model::Recognizer::language_codes].
1881 ///
1882 /// # Example
1883 /// ```ignore,no_run
1884 /// # use google_cloud_speech_v2::model::Recognizer;
1885 /// let x = Recognizer::new().set_language_codes(["a", "b", "c"]);
1886 /// ```
1887 #[deprecated]
1888 pub fn set_language_codes<T, V>(mut self, v: T) -> Self
1889 where
1890 T: std::iter::IntoIterator<Item = V>,
1891 V: std::convert::Into<std::string::String>,
1892 {
1893 use std::iter::Iterator;
1894 self.language_codes = v.into_iter().map(|i| i.into()).collect();
1895 self
1896 }
1897
1898 /// Sets the value of [default_recognition_config][crate::model::Recognizer::default_recognition_config].
1899 ///
1900 /// # Example
1901 /// ```ignore,no_run
1902 /// # use google_cloud_speech_v2::model::Recognizer;
1903 /// use google_cloud_speech_v2::model::RecognitionConfig;
1904 /// let x = Recognizer::new().set_default_recognition_config(RecognitionConfig::default()/* use setters */);
1905 /// ```
1906 pub fn set_default_recognition_config<T>(mut self, v: T) -> Self
1907 where
1908 T: std::convert::Into<crate::model::RecognitionConfig>,
1909 {
1910 self.default_recognition_config = std::option::Option::Some(v.into());
1911 self
1912 }
1913
1914 /// Sets or clears the value of [default_recognition_config][crate::model::Recognizer::default_recognition_config].
1915 ///
1916 /// # Example
1917 /// ```ignore,no_run
1918 /// # use google_cloud_speech_v2::model::Recognizer;
1919 /// use google_cloud_speech_v2::model::RecognitionConfig;
1920 /// let x = Recognizer::new().set_or_clear_default_recognition_config(Some(RecognitionConfig::default()/* use setters */));
1921 /// let x = Recognizer::new().set_or_clear_default_recognition_config(None::<RecognitionConfig>);
1922 /// ```
1923 pub fn set_or_clear_default_recognition_config<T>(mut self, v: std::option::Option<T>) -> Self
1924 where
1925 T: std::convert::Into<crate::model::RecognitionConfig>,
1926 {
1927 self.default_recognition_config = v.map(|x| x.into());
1928 self
1929 }
1930
1931 /// Sets the value of [annotations][crate::model::Recognizer::annotations].
1932 ///
1933 /// # Example
1934 /// ```ignore,no_run
1935 /// # use google_cloud_speech_v2::model::Recognizer;
1936 /// let x = Recognizer::new().set_annotations([
1937 /// ("key0", "abc"),
1938 /// ("key1", "xyz"),
1939 /// ]);
1940 /// ```
1941 pub fn set_annotations<T, K, V>(mut self, v: T) -> Self
1942 where
1943 T: std::iter::IntoIterator<Item = (K, V)>,
1944 K: std::convert::Into<std::string::String>,
1945 V: std::convert::Into<std::string::String>,
1946 {
1947 use std::iter::Iterator;
1948 self.annotations = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
1949 self
1950 }
1951
1952 /// Sets the value of [state][crate::model::Recognizer::state].
1953 ///
1954 /// # Example
1955 /// ```ignore,no_run
1956 /// # use google_cloud_speech_v2::model::Recognizer;
1957 /// use google_cloud_speech_v2::model::recognizer::State;
1958 /// let x0 = Recognizer::new().set_state(State::Active);
1959 /// let x1 = Recognizer::new().set_state(State::Deleted);
1960 /// ```
1961 pub fn set_state<T: std::convert::Into<crate::model::recognizer::State>>(
1962 mut self,
1963 v: T,
1964 ) -> Self {
1965 self.state = v.into();
1966 self
1967 }
1968
1969 /// Sets the value of [create_time][crate::model::Recognizer::create_time].
1970 ///
1971 /// # Example
1972 /// ```ignore,no_run
1973 /// # use google_cloud_speech_v2::model::Recognizer;
1974 /// use wkt::Timestamp;
1975 /// let x = Recognizer::new().set_create_time(Timestamp::default()/* use setters */);
1976 /// ```
1977 pub fn set_create_time<T>(mut self, v: T) -> Self
1978 where
1979 T: std::convert::Into<wkt::Timestamp>,
1980 {
1981 self.create_time = std::option::Option::Some(v.into());
1982 self
1983 }
1984
1985 /// Sets or clears the value of [create_time][crate::model::Recognizer::create_time].
1986 ///
1987 /// # Example
1988 /// ```ignore,no_run
1989 /// # use google_cloud_speech_v2::model::Recognizer;
1990 /// use wkt::Timestamp;
1991 /// let x = Recognizer::new().set_or_clear_create_time(Some(Timestamp::default()/* use setters */));
1992 /// let x = Recognizer::new().set_or_clear_create_time(None::<Timestamp>);
1993 /// ```
1994 pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
1995 where
1996 T: std::convert::Into<wkt::Timestamp>,
1997 {
1998 self.create_time = v.map(|x| x.into());
1999 self
2000 }
2001
2002 /// Sets the value of [update_time][crate::model::Recognizer::update_time].
2003 ///
2004 /// # Example
2005 /// ```ignore,no_run
2006 /// # use google_cloud_speech_v2::model::Recognizer;
2007 /// use wkt::Timestamp;
2008 /// let x = Recognizer::new().set_update_time(Timestamp::default()/* use setters */);
2009 /// ```
2010 pub fn set_update_time<T>(mut self, v: T) -> Self
2011 where
2012 T: std::convert::Into<wkt::Timestamp>,
2013 {
2014 self.update_time = std::option::Option::Some(v.into());
2015 self
2016 }
2017
2018 /// Sets or clears the value of [update_time][crate::model::Recognizer::update_time].
2019 ///
2020 /// # Example
2021 /// ```ignore,no_run
2022 /// # use google_cloud_speech_v2::model::Recognizer;
2023 /// use wkt::Timestamp;
2024 /// let x = Recognizer::new().set_or_clear_update_time(Some(Timestamp::default()/* use setters */));
2025 /// let x = Recognizer::new().set_or_clear_update_time(None::<Timestamp>);
2026 /// ```
2027 pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
2028 where
2029 T: std::convert::Into<wkt::Timestamp>,
2030 {
2031 self.update_time = v.map(|x| x.into());
2032 self
2033 }
2034
2035 /// Sets the value of [delete_time][crate::model::Recognizer::delete_time].
2036 ///
2037 /// # Example
2038 /// ```ignore,no_run
2039 /// # use google_cloud_speech_v2::model::Recognizer;
2040 /// use wkt::Timestamp;
2041 /// let x = Recognizer::new().set_delete_time(Timestamp::default()/* use setters */);
2042 /// ```
2043 pub fn set_delete_time<T>(mut self, v: T) -> Self
2044 where
2045 T: std::convert::Into<wkt::Timestamp>,
2046 {
2047 self.delete_time = std::option::Option::Some(v.into());
2048 self
2049 }
2050
2051 /// Sets or clears the value of [delete_time][crate::model::Recognizer::delete_time].
2052 ///
2053 /// # Example
2054 /// ```ignore,no_run
2055 /// # use google_cloud_speech_v2::model::Recognizer;
2056 /// use wkt::Timestamp;
2057 /// let x = Recognizer::new().set_or_clear_delete_time(Some(Timestamp::default()/* use setters */));
2058 /// let x = Recognizer::new().set_or_clear_delete_time(None::<Timestamp>);
2059 /// ```
2060 pub fn set_or_clear_delete_time<T>(mut self, v: std::option::Option<T>) -> Self
2061 where
2062 T: std::convert::Into<wkt::Timestamp>,
2063 {
2064 self.delete_time = v.map(|x| x.into());
2065 self
2066 }
2067
2068 /// Sets the value of [expire_time][crate::model::Recognizer::expire_time].
2069 ///
2070 /// # Example
2071 /// ```ignore,no_run
2072 /// # use google_cloud_speech_v2::model::Recognizer;
2073 /// use wkt::Timestamp;
2074 /// let x = Recognizer::new().set_expire_time(Timestamp::default()/* use setters */);
2075 /// ```
2076 pub fn set_expire_time<T>(mut self, v: T) -> Self
2077 where
2078 T: std::convert::Into<wkt::Timestamp>,
2079 {
2080 self.expire_time = std::option::Option::Some(v.into());
2081 self
2082 }
2083
2084 /// Sets or clears the value of [expire_time][crate::model::Recognizer::expire_time].
2085 ///
2086 /// # Example
2087 /// ```ignore,no_run
2088 /// # use google_cloud_speech_v2::model::Recognizer;
2089 /// use wkt::Timestamp;
2090 /// let x = Recognizer::new().set_or_clear_expire_time(Some(Timestamp::default()/* use setters */));
2091 /// let x = Recognizer::new().set_or_clear_expire_time(None::<Timestamp>);
2092 /// ```
2093 pub fn set_or_clear_expire_time<T>(mut self, v: std::option::Option<T>) -> Self
2094 where
2095 T: std::convert::Into<wkt::Timestamp>,
2096 {
2097 self.expire_time = v.map(|x| x.into());
2098 self
2099 }
2100
2101 /// Sets the value of [etag][crate::model::Recognizer::etag].
2102 ///
2103 /// # Example
2104 /// ```ignore,no_run
2105 /// # use google_cloud_speech_v2::model::Recognizer;
2106 /// let x = Recognizer::new().set_etag("example");
2107 /// ```
2108 pub fn set_etag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2109 self.etag = v.into();
2110 self
2111 }
2112
2113 /// Sets the value of [reconciling][crate::model::Recognizer::reconciling].
2114 ///
2115 /// # Example
2116 /// ```ignore,no_run
2117 /// # use google_cloud_speech_v2::model::Recognizer;
2118 /// let x = Recognizer::new().set_reconciling(true);
2119 /// ```
2120 pub fn set_reconciling<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2121 self.reconciling = v.into();
2122 self
2123 }
2124
2125 /// Sets the value of [kms_key_name][crate::model::Recognizer::kms_key_name].
2126 ///
2127 /// # Example
2128 /// ```ignore,no_run
2129 /// # use google_cloud_speech_v2::model::Recognizer;
2130 /// let x = Recognizer::new().set_kms_key_name("example");
2131 /// ```
2132 pub fn set_kms_key_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2133 self.kms_key_name = v.into();
2134 self
2135 }
2136
2137 /// Sets the value of [kms_key_version_name][crate::model::Recognizer::kms_key_version_name].
2138 ///
2139 /// # Example
2140 /// ```ignore,no_run
2141 /// # use google_cloud_speech_v2::model::Recognizer;
2142 /// let x = Recognizer::new().set_kms_key_version_name("example");
2143 /// ```
2144 pub fn set_kms_key_version_name<T: std::convert::Into<std::string::String>>(
2145 mut self,
2146 v: T,
2147 ) -> Self {
2148 self.kms_key_version_name = v.into();
2149 self
2150 }
2151}
2152
2153impl wkt::message::Message for Recognizer {
2154 fn typename() -> &'static str {
2155 "type.googleapis.com/google.cloud.speech.v2.Recognizer"
2156 }
2157}
2158
2159/// Defines additional types related to [Recognizer].
2160pub mod recognizer {
2161 #[allow(unused_imports)]
2162 use super::*;
2163
2164 /// Set of states that define the lifecycle of a Recognizer.
2165 ///
2166 /// # Working with unknown values
2167 ///
2168 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2169 /// additional enum variants at any time. Adding new variants is not considered
2170 /// a breaking change. Applications should write their code in anticipation of:
2171 ///
2172 /// - New values appearing in future releases of the client library, **and**
2173 /// - New values received dynamically, without application changes.
2174 ///
2175 /// Please consult the [Working with enums] section in the user guide for some
2176 /// guidelines.
2177 ///
2178 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
2179 #[derive(Clone, Debug, PartialEq)]
2180 #[non_exhaustive]
2181 pub enum State {
2182 /// The default value. This value is used if the state is omitted.
2183 Unspecified,
2184 /// The Recognizer is active and ready for use.
2185 Active,
2186 /// This Recognizer has been deleted.
2187 Deleted,
2188 /// If set, the enum was initialized with an unknown value.
2189 ///
2190 /// Applications can examine the value using [State::value] or
2191 /// [State::name].
2192 UnknownValue(state::UnknownValue),
2193 }
2194
2195 #[doc(hidden)]
2196 pub mod state {
2197 #[allow(unused_imports)]
2198 use super::*;
2199 #[derive(Clone, Debug, PartialEq)]
2200 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2201 }
2202
2203 impl State {
2204 /// Gets the enum value.
2205 ///
2206 /// Returns `None` if the enum contains an unknown value deserialized from
2207 /// the string representation of enums.
2208 pub fn value(&self) -> std::option::Option<i32> {
2209 match self {
2210 Self::Unspecified => std::option::Option::Some(0),
2211 Self::Active => std::option::Option::Some(2),
2212 Self::Deleted => std::option::Option::Some(4),
2213 Self::UnknownValue(u) => u.0.value(),
2214 }
2215 }
2216
2217 /// Gets the enum value as a string.
2218 ///
2219 /// Returns `None` if the enum contains an unknown value deserialized from
2220 /// the integer representation of enums.
2221 pub fn name(&self) -> std::option::Option<&str> {
2222 match self {
2223 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
2224 Self::Active => std::option::Option::Some("ACTIVE"),
2225 Self::Deleted => std::option::Option::Some("DELETED"),
2226 Self::UnknownValue(u) => u.0.name(),
2227 }
2228 }
2229 }
2230
2231 impl std::default::Default for State {
2232 fn default() -> Self {
2233 use std::convert::From;
2234 Self::from(0)
2235 }
2236 }
2237
2238 impl std::fmt::Display for State {
2239 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2240 wkt::internal::display_enum(f, self.name(), self.value())
2241 }
2242 }
2243
2244 impl std::convert::From<i32> for State {
2245 fn from(value: i32) -> Self {
2246 match value {
2247 0 => Self::Unspecified,
2248 2 => Self::Active,
2249 4 => Self::Deleted,
2250 _ => Self::UnknownValue(state::UnknownValue(
2251 wkt::internal::UnknownEnumValue::Integer(value),
2252 )),
2253 }
2254 }
2255 }
2256
2257 impl std::convert::From<&str> for State {
2258 fn from(value: &str) -> Self {
2259 use std::string::ToString;
2260 match value {
2261 "STATE_UNSPECIFIED" => Self::Unspecified,
2262 "ACTIVE" => Self::Active,
2263 "DELETED" => Self::Deleted,
2264 _ => Self::UnknownValue(state::UnknownValue(
2265 wkt::internal::UnknownEnumValue::String(value.to_string()),
2266 )),
2267 }
2268 }
2269 }
2270
2271 impl serde::ser::Serialize for State {
2272 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2273 where
2274 S: serde::Serializer,
2275 {
2276 match self {
2277 Self::Unspecified => serializer.serialize_i32(0),
2278 Self::Active => serializer.serialize_i32(2),
2279 Self::Deleted => serializer.serialize_i32(4),
2280 Self::UnknownValue(u) => u.0.serialize(serializer),
2281 }
2282 }
2283 }
2284
2285 impl<'de> serde::de::Deserialize<'de> for State {
2286 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2287 where
2288 D: serde::Deserializer<'de>,
2289 {
2290 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
2291 ".google.cloud.speech.v2.Recognizer.State",
2292 ))
2293 }
2294 }
2295}
2296
2297/// Automatically detected decoding parameters.
2298/// Supported for the following encodings:
2299///
2300/// * WAV_LINEAR16: 16-bit signed little-endian PCM samples in a WAV container.
2301///
2302/// * WAV_MULAW: 8-bit companded mulaw samples in a WAV container.
2303///
2304/// * WAV_ALAW: 8-bit companded alaw samples in a WAV container.
2305///
2306/// * RFC4867_5_AMR: AMR frames with an rfc4867.5 header.
2307///
2308/// * RFC4867_5_AMRWB: AMR-WB frames with an rfc4867.5 header.
2309///
2310/// * FLAC: FLAC frames in the "native FLAC" container format.
2311///
2312/// * MP3: MPEG audio frames with optional (ignored) ID3 metadata.
2313///
2314/// * OGG_OPUS: Opus audio frames in an Ogg container.
2315///
2316/// * WEBM_OPUS: Opus audio frames in a WebM container.
2317///
2318/// * MP4_AAC: AAC audio frames in an MP4 container.
2319///
2320/// * M4A_AAC: AAC audio frames in an M4A container.
2321///
2322/// * MOV_AAC: AAC audio frames in an MOV container.
2323///
2324#[derive(Clone, Default, PartialEq)]
2325#[non_exhaustive]
2326pub struct AutoDetectDecodingConfig {
2327 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2328}
2329
2330impl AutoDetectDecodingConfig {
2331 /// Creates a new default instance.
2332 pub fn new() -> Self {
2333 std::default::Default::default()
2334 }
2335}
2336
2337impl wkt::message::Message for AutoDetectDecodingConfig {
2338 fn typename() -> &'static str {
2339 "type.googleapis.com/google.cloud.speech.v2.AutoDetectDecodingConfig"
2340 }
2341}
2342
2343/// Explicitly specified decoding parameters.
2344#[derive(Clone, Default, PartialEq)]
2345#[non_exhaustive]
2346pub struct ExplicitDecodingConfig {
2347 /// Required. Encoding of the audio data sent for recognition.
2348 pub encoding: crate::model::explicit_decoding_config::AudioEncoding,
2349
2350 /// Optional. Sample rate in Hertz of the audio data sent for recognition.
2351 /// Valid values are: 8000-48000, and 16000 is optimal. For best results, set
2352 /// the sampling rate of the audio source to 16000 Hz. If that's not possible,
2353 /// use the native sample rate of the audio source (instead of resampling).
2354 /// Note that this field is marked as OPTIONAL for backward compatibility
2355 /// reasons. It is (and has always been) effectively REQUIRED.
2356 pub sample_rate_hertz: i32,
2357
2358 /// Optional. Number of channels present in the audio data sent for
2359 /// recognition. Note that this field is marked as OPTIONAL for backward
2360 /// compatibility reasons. It is (and has always been) effectively REQUIRED.
2361 ///
2362 /// The maximum allowed value is 8.
2363 pub audio_channel_count: i32,
2364
2365 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2366}
2367
2368impl ExplicitDecodingConfig {
2369 /// Creates a new default instance.
2370 pub fn new() -> Self {
2371 std::default::Default::default()
2372 }
2373
2374 /// Sets the value of [encoding][crate::model::ExplicitDecodingConfig::encoding].
2375 ///
2376 /// # Example
2377 /// ```ignore,no_run
2378 /// # use google_cloud_speech_v2::model::ExplicitDecodingConfig;
2379 /// use google_cloud_speech_v2::model::explicit_decoding_config::AudioEncoding;
2380 /// let x0 = ExplicitDecodingConfig::new().set_encoding(AudioEncoding::Linear16);
2381 /// let x1 = ExplicitDecodingConfig::new().set_encoding(AudioEncoding::Mulaw);
2382 /// let x2 = ExplicitDecodingConfig::new().set_encoding(AudioEncoding::Alaw);
2383 /// ```
2384 pub fn set_encoding<
2385 T: std::convert::Into<crate::model::explicit_decoding_config::AudioEncoding>,
2386 >(
2387 mut self,
2388 v: T,
2389 ) -> Self {
2390 self.encoding = v.into();
2391 self
2392 }
2393
2394 /// Sets the value of [sample_rate_hertz][crate::model::ExplicitDecodingConfig::sample_rate_hertz].
2395 ///
2396 /// # Example
2397 /// ```ignore,no_run
2398 /// # use google_cloud_speech_v2::model::ExplicitDecodingConfig;
2399 /// let x = ExplicitDecodingConfig::new().set_sample_rate_hertz(42);
2400 /// ```
2401 pub fn set_sample_rate_hertz<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
2402 self.sample_rate_hertz = v.into();
2403 self
2404 }
2405
2406 /// Sets the value of [audio_channel_count][crate::model::ExplicitDecodingConfig::audio_channel_count].
2407 ///
2408 /// # Example
2409 /// ```ignore,no_run
2410 /// # use google_cloud_speech_v2::model::ExplicitDecodingConfig;
2411 /// let x = ExplicitDecodingConfig::new().set_audio_channel_count(42);
2412 /// ```
2413 pub fn set_audio_channel_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
2414 self.audio_channel_count = v.into();
2415 self
2416 }
2417}
2418
2419impl wkt::message::Message for ExplicitDecodingConfig {
2420 fn typename() -> &'static str {
2421 "type.googleapis.com/google.cloud.speech.v2.ExplicitDecodingConfig"
2422 }
2423}
2424
2425/// Defines additional types related to [ExplicitDecodingConfig].
2426pub mod explicit_decoding_config {
2427 #[allow(unused_imports)]
2428 use super::*;
2429
2430 /// Supported audio data encodings.
2431 ///
2432 /// # Working with unknown values
2433 ///
2434 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2435 /// additional enum variants at any time. Adding new variants is not considered
2436 /// a breaking change. Applications should write their code in anticipation of:
2437 ///
2438 /// - New values appearing in future releases of the client library, **and**
2439 /// - New values received dynamically, without application changes.
2440 ///
2441 /// Please consult the [Working with enums] section in the user guide for some
2442 /// guidelines.
2443 ///
2444 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
2445 #[derive(Clone, Debug, PartialEq)]
2446 #[non_exhaustive]
2447 pub enum AudioEncoding {
2448 /// Default value. This value is unused.
2449 Unspecified,
2450 /// Headerless 16-bit signed little-endian PCM samples.
2451 Linear16,
2452 /// Headerless 8-bit companded mulaw samples.
2453 Mulaw,
2454 /// Headerless 8-bit companded alaw samples.
2455 Alaw,
2456 /// AMR frames with an rfc4867.5 header.
2457 Amr,
2458 /// AMR-WB frames with an rfc4867.5 header.
2459 AmrWb,
2460 /// FLAC frames in the "native FLAC" container format.
2461 Flac,
2462 /// MPEG audio frames with optional (ignored) ID3 metadata.
2463 Mp3,
2464 /// Opus audio frames in an Ogg container.
2465 OggOpus,
2466 /// Opus audio frames in a WebM container.
2467 WebmOpus,
2468 /// AAC audio frames in an MP4 container.
2469 Mp4Aac,
2470 /// AAC audio frames in an M4A container.
2471 M4AAac,
2472 /// AAC audio frames in an MOV container.
2473 MovAac,
2474 /// If set, the enum was initialized with an unknown value.
2475 ///
2476 /// Applications can examine the value using [AudioEncoding::value] or
2477 /// [AudioEncoding::name].
2478 UnknownValue(audio_encoding::UnknownValue),
2479 }
2480
2481 #[doc(hidden)]
2482 pub mod audio_encoding {
2483 #[allow(unused_imports)]
2484 use super::*;
2485 #[derive(Clone, Debug, PartialEq)]
2486 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2487 }
2488
2489 impl AudioEncoding {
2490 /// Gets the enum value.
2491 ///
2492 /// Returns `None` if the enum contains an unknown value deserialized from
2493 /// the string representation of enums.
2494 pub fn value(&self) -> std::option::Option<i32> {
2495 match self {
2496 Self::Unspecified => std::option::Option::Some(0),
2497 Self::Linear16 => std::option::Option::Some(1),
2498 Self::Mulaw => std::option::Option::Some(2),
2499 Self::Alaw => std::option::Option::Some(3),
2500 Self::Amr => std::option::Option::Some(4),
2501 Self::AmrWb => std::option::Option::Some(5),
2502 Self::Flac => std::option::Option::Some(6),
2503 Self::Mp3 => std::option::Option::Some(7),
2504 Self::OggOpus => std::option::Option::Some(8),
2505 Self::WebmOpus => std::option::Option::Some(9),
2506 Self::Mp4Aac => std::option::Option::Some(10),
2507 Self::M4AAac => std::option::Option::Some(11),
2508 Self::MovAac => std::option::Option::Some(12),
2509 Self::UnknownValue(u) => u.0.value(),
2510 }
2511 }
2512
2513 /// Gets the enum value as a string.
2514 ///
2515 /// Returns `None` if the enum contains an unknown value deserialized from
2516 /// the integer representation of enums.
2517 pub fn name(&self) -> std::option::Option<&str> {
2518 match self {
2519 Self::Unspecified => std::option::Option::Some("AUDIO_ENCODING_UNSPECIFIED"),
2520 Self::Linear16 => std::option::Option::Some("LINEAR16"),
2521 Self::Mulaw => std::option::Option::Some("MULAW"),
2522 Self::Alaw => std::option::Option::Some("ALAW"),
2523 Self::Amr => std::option::Option::Some("AMR"),
2524 Self::AmrWb => std::option::Option::Some("AMR_WB"),
2525 Self::Flac => std::option::Option::Some("FLAC"),
2526 Self::Mp3 => std::option::Option::Some("MP3"),
2527 Self::OggOpus => std::option::Option::Some("OGG_OPUS"),
2528 Self::WebmOpus => std::option::Option::Some("WEBM_OPUS"),
2529 Self::Mp4Aac => std::option::Option::Some("MP4_AAC"),
2530 Self::M4AAac => std::option::Option::Some("M4A_AAC"),
2531 Self::MovAac => std::option::Option::Some("MOV_AAC"),
2532 Self::UnknownValue(u) => u.0.name(),
2533 }
2534 }
2535 }
2536
2537 impl std::default::Default for AudioEncoding {
2538 fn default() -> Self {
2539 use std::convert::From;
2540 Self::from(0)
2541 }
2542 }
2543
2544 impl std::fmt::Display for AudioEncoding {
2545 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2546 wkt::internal::display_enum(f, self.name(), self.value())
2547 }
2548 }
2549
2550 impl std::convert::From<i32> for AudioEncoding {
2551 fn from(value: i32) -> Self {
2552 match value {
2553 0 => Self::Unspecified,
2554 1 => Self::Linear16,
2555 2 => Self::Mulaw,
2556 3 => Self::Alaw,
2557 4 => Self::Amr,
2558 5 => Self::AmrWb,
2559 6 => Self::Flac,
2560 7 => Self::Mp3,
2561 8 => Self::OggOpus,
2562 9 => Self::WebmOpus,
2563 10 => Self::Mp4Aac,
2564 11 => Self::M4AAac,
2565 12 => Self::MovAac,
2566 _ => Self::UnknownValue(audio_encoding::UnknownValue(
2567 wkt::internal::UnknownEnumValue::Integer(value),
2568 )),
2569 }
2570 }
2571 }
2572
2573 impl std::convert::From<&str> for AudioEncoding {
2574 fn from(value: &str) -> Self {
2575 use std::string::ToString;
2576 match value {
2577 "AUDIO_ENCODING_UNSPECIFIED" => Self::Unspecified,
2578 "LINEAR16" => Self::Linear16,
2579 "MULAW" => Self::Mulaw,
2580 "ALAW" => Self::Alaw,
2581 "AMR" => Self::Amr,
2582 "AMR_WB" => Self::AmrWb,
2583 "FLAC" => Self::Flac,
2584 "MP3" => Self::Mp3,
2585 "OGG_OPUS" => Self::OggOpus,
2586 "WEBM_OPUS" => Self::WebmOpus,
2587 "MP4_AAC" => Self::Mp4Aac,
2588 "M4A_AAC" => Self::M4AAac,
2589 "MOV_AAC" => Self::MovAac,
2590 _ => Self::UnknownValue(audio_encoding::UnknownValue(
2591 wkt::internal::UnknownEnumValue::String(value.to_string()),
2592 )),
2593 }
2594 }
2595 }
2596
2597 impl serde::ser::Serialize for AudioEncoding {
2598 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2599 where
2600 S: serde::Serializer,
2601 {
2602 match self {
2603 Self::Unspecified => serializer.serialize_i32(0),
2604 Self::Linear16 => serializer.serialize_i32(1),
2605 Self::Mulaw => serializer.serialize_i32(2),
2606 Self::Alaw => serializer.serialize_i32(3),
2607 Self::Amr => serializer.serialize_i32(4),
2608 Self::AmrWb => serializer.serialize_i32(5),
2609 Self::Flac => serializer.serialize_i32(6),
2610 Self::Mp3 => serializer.serialize_i32(7),
2611 Self::OggOpus => serializer.serialize_i32(8),
2612 Self::WebmOpus => serializer.serialize_i32(9),
2613 Self::Mp4Aac => serializer.serialize_i32(10),
2614 Self::M4AAac => serializer.serialize_i32(11),
2615 Self::MovAac => serializer.serialize_i32(12),
2616 Self::UnknownValue(u) => u.0.serialize(serializer),
2617 }
2618 }
2619 }
2620
2621 impl<'de> serde::de::Deserialize<'de> for AudioEncoding {
2622 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2623 where
2624 D: serde::Deserializer<'de>,
2625 {
2626 deserializer.deserialize_any(wkt::internal::EnumVisitor::<AudioEncoding>::new(
2627 ".google.cloud.speech.v2.ExplicitDecodingConfig.AudioEncoding",
2628 ))
2629 }
2630 }
2631}
2632
2633/// Configuration to enable speaker diarization.
2634#[derive(Clone, Default, PartialEq)]
2635#[non_exhaustive]
2636pub struct SpeakerDiarizationConfig {
2637 /// Optional. The system automatically determines the number of speakers. This
2638 /// value is not currently used.
2639 pub min_speaker_count: i32,
2640
2641 /// Optional. The system automatically determines the number of speakers. This
2642 /// value is not currently used.
2643 pub max_speaker_count: i32,
2644
2645 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2646}
2647
2648impl SpeakerDiarizationConfig {
2649 /// Creates a new default instance.
2650 pub fn new() -> Self {
2651 std::default::Default::default()
2652 }
2653
2654 /// Sets the value of [min_speaker_count][crate::model::SpeakerDiarizationConfig::min_speaker_count].
2655 ///
2656 /// # Example
2657 /// ```ignore,no_run
2658 /// # use google_cloud_speech_v2::model::SpeakerDiarizationConfig;
2659 /// let x = SpeakerDiarizationConfig::new().set_min_speaker_count(42);
2660 /// ```
2661 pub fn set_min_speaker_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
2662 self.min_speaker_count = v.into();
2663 self
2664 }
2665
2666 /// Sets the value of [max_speaker_count][crate::model::SpeakerDiarizationConfig::max_speaker_count].
2667 ///
2668 /// # Example
2669 /// ```ignore,no_run
2670 /// # use google_cloud_speech_v2::model::SpeakerDiarizationConfig;
2671 /// let x = SpeakerDiarizationConfig::new().set_max_speaker_count(42);
2672 /// ```
2673 pub fn set_max_speaker_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
2674 self.max_speaker_count = v.into();
2675 self
2676 }
2677}
2678
2679impl wkt::message::Message for SpeakerDiarizationConfig {
2680 fn typename() -> &'static str {
2681 "type.googleapis.com/google.cloud.speech.v2.SpeakerDiarizationConfig"
2682 }
2683}
2684
2685/// Configuration to enable custom prompt in chirp3.
2686#[derive(Clone, Default, PartialEq)]
2687#[non_exhaustive]
2688pub struct CustomPromptConfig {
2689 /// Optional. The custom instructions to override the existing instructions for
2690 /// chirp3.
2691 pub custom_prompt: std::string::String,
2692
2693 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2694}
2695
2696impl CustomPromptConfig {
2697 /// Creates a new default instance.
2698 pub fn new() -> Self {
2699 std::default::Default::default()
2700 }
2701
2702 /// Sets the value of [custom_prompt][crate::model::CustomPromptConfig::custom_prompt].
2703 ///
2704 /// # Example
2705 /// ```ignore,no_run
2706 /// # use google_cloud_speech_v2::model::CustomPromptConfig;
2707 /// let x = CustomPromptConfig::new().set_custom_prompt("example");
2708 /// ```
2709 pub fn set_custom_prompt<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2710 self.custom_prompt = v.into();
2711 self
2712 }
2713}
2714
2715impl wkt::message::Message for CustomPromptConfig {
2716 fn typename() -> &'static str {
2717 "type.googleapis.com/google.cloud.speech.v2.CustomPromptConfig"
2718 }
2719}
2720
2721/// Available recognition features.
2722#[derive(Clone, Default, PartialEq)]
2723#[non_exhaustive]
2724pub struct RecognitionFeatures {
2725 /// If set to `true`, the server will attempt to filter out profanities,
2726 /// replacing all but the initial character in each filtered word with
2727 /// asterisks, for instance, "f***". If set to `false` or omitted, profanities
2728 /// won't be filtered out.
2729 pub profanity_filter: bool,
2730
2731 /// If `true`, the top result includes a list of words and the start and end
2732 /// time offsets (timestamps) for those words. If `false`, no word-level time
2733 /// offset information is returned. The default is `false`.
2734 pub enable_word_time_offsets: bool,
2735
2736 /// If `true`, the top result includes a list of words and the confidence for
2737 /// those words. If `false`, no word-level confidence information is returned.
2738 /// The default is `false`.
2739 pub enable_word_confidence: bool,
2740
2741 /// If `true`, adds punctuation to recognition result hypotheses. This feature
2742 /// is only available in select languages. The default `false` value does not
2743 /// add punctuation to result hypotheses.
2744 pub enable_automatic_punctuation: bool,
2745
2746 /// The spoken punctuation behavior for the call. If `true`, replaces spoken
2747 /// punctuation with the corresponding symbols in the request. For example,
2748 /// "how are you question mark" becomes "how are you?". See
2749 /// <https://cloud.google.com/speech-to-text/docs/spoken-punctuation> for
2750 /// support. If `false`, spoken punctuation is not replaced.
2751 pub enable_spoken_punctuation: bool,
2752
2753 /// The spoken emoji behavior for the call. If `true`, adds spoken emoji
2754 /// formatting for the request. This will replace spoken emojis with the
2755 /// corresponding Unicode symbols in the final transcript. If `false`, spoken
2756 /// emojis are not replaced.
2757 pub enable_spoken_emojis: bool,
2758
2759 /// Mode for recognizing multi-channel audio.
2760 pub multi_channel_mode: crate::model::recognition_features::MultiChannelMode,
2761
2762 /// Configuration to enable speaker diarization. To enable diarization, set
2763 /// this field to an empty SpeakerDiarizationConfig message.
2764 pub diarization_config: std::option::Option<crate::model::SpeakerDiarizationConfig>,
2765
2766 /// Maximum number of recognition hypotheses to be returned.
2767 /// The server may return fewer than `max_alternatives`.
2768 /// Valid values are `0`-`30`. A value of `0` or `1` will return a maximum of
2769 /// one. If omitted, will return a maximum of one.
2770 pub max_alternatives: i32,
2771
2772 /// Optional. Configuration to enable custom prompt for chirp3.
2773 pub custom_prompt_config: std::option::Option<crate::model::CustomPromptConfig>,
2774
2775 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2776}
2777
2778impl RecognitionFeatures {
2779 /// Creates a new default instance.
2780 pub fn new() -> Self {
2781 std::default::Default::default()
2782 }
2783
2784 /// Sets the value of [profanity_filter][crate::model::RecognitionFeatures::profanity_filter].
2785 ///
2786 /// # Example
2787 /// ```ignore,no_run
2788 /// # use google_cloud_speech_v2::model::RecognitionFeatures;
2789 /// let x = RecognitionFeatures::new().set_profanity_filter(true);
2790 /// ```
2791 pub fn set_profanity_filter<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2792 self.profanity_filter = v.into();
2793 self
2794 }
2795
2796 /// Sets the value of [enable_word_time_offsets][crate::model::RecognitionFeatures::enable_word_time_offsets].
2797 ///
2798 /// # Example
2799 /// ```ignore,no_run
2800 /// # use google_cloud_speech_v2::model::RecognitionFeatures;
2801 /// let x = RecognitionFeatures::new().set_enable_word_time_offsets(true);
2802 /// ```
2803 pub fn set_enable_word_time_offsets<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2804 self.enable_word_time_offsets = v.into();
2805 self
2806 }
2807
2808 /// Sets the value of [enable_word_confidence][crate::model::RecognitionFeatures::enable_word_confidence].
2809 ///
2810 /// # Example
2811 /// ```ignore,no_run
2812 /// # use google_cloud_speech_v2::model::RecognitionFeatures;
2813 /// let x = RecognitionFeatures::new().set_enable_word_confidence(true);
2814 /// ```
2815 pub fn set_enable_word_confidence<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2816 self.enable_word_confidence = v.into();
2817 self
2818 }
2819
2820 /// Sets the value of [enable_automatic_punctuation][crate::model::RecognitionFeatures::enable_automatic_punctuation].
2821 ///
2822 /// # Example
2823 /// ```ignore,no_run
2824 /// # use google_cloud_speech_v2::model::RecognitionFeatures;
2825 /// let x = RecognitionFeatures::new().set_enable_automatic_punctuation(true);
2826 /// ```
2827 pub fn set_enable_automatic_punctuation<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2828 self.enable_automatic_punctuation = v.into();
2829 self
2830 }
2831
2832 /// Sets the value of [enable_spoken_punctuation][crate::model::RecognitionFeatures::enable_spoken_punctuation].
2833 ///
2834 /// # Example
2835 /// ```ignore,no_run
2836 /// # use google_cloud_speech_v2::model::RecognitionFeatures;
2837 /// let x = RecognitionFeatures::new().set_enable_spoken_punctuation(true);
2838 /// ```
2839 pub fn set_enable_spoken_punctuation<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2840 self.enable_spoken_punctuation = v.into();
2841 self
2842 }
2843
2844 /// Sets the value of [enable_spoken_emojis][crate::model::RecognitionFeatures::enable_spoken_emojis].
2845 ///
2846 /// # Example
2847 /// ```ignore,no_run
2848 /// # use google_cloud_speech_v2::model::RecognitionFeatures;
2849 /// let x = RecognitionFeatures::new().set_enable_spoken_emojis(true);
2850 /// ```
2851 pub fn set_enable_spoken_emojis<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2852 self.enable_spoken_emojis = v.into();
2853 self
2854 }
2855
2856 /// Sets the value of [multi_channel_mode][crate::model::RecognitionFeatures::multi_channel_mode].
2857 ///
2858 /// # Example
2859 /// ```ignore,no_run
2860 /// # use google_cloud_speech_v2::model::RecognitionFeatures;
2861 /// use google_cloud_speech_v2::model::recognition_features::MultiChannelMode;
2862 /// let x0 = RecognitionFeatures::new().set_multi_channel_mode(MultiChannelMode::SeparateRecognitionPerChannel);
2863 /// ```
2864 pub fn set_multi_channel_mode<
2865 T: std::convert::Into<crate::model::recognition_features::MultiChannelMode>,
2866 >(
2867 mut self,
2868 v: T,
2869 ) -> Self {
2870 self.multi_channel_mode = v.into();
2871 self
2872 }
2873
2874 /// Sets the value of [diarization_config][crate::model::RecognitionFeatures::diarization_config].
2875 ///
2876 /// # Example
2877 /// ```ignore,no_run
2878 /// # use google_cloud_speech_v2::model::RecognitionFeatures;
2879 /// use google_cloud_speech_v2::model::SpeakerDiarizationConfig;
2880 /// let x = RecognitionFeatures::new().set_diarization_config(SpeakerDiarizationConfig::default()/* use setters */);
2881 /// ```
2882 pub fn set_diarization_config<T>(mut self, v: T) -> Self
2883 where
2884 T: std::convert::Into<crate::model::SpeakerDiarizationConfig>,
2885 {
2886 self.diarization_config = std::option::Option::Some(v.into());
2887 self
2888 }
2889
2890 /// Sets or clears the value of [diarization_config][crate::model::RecognitionFeatures::diarization_config].
2891 ///
2892 /// # Example
2893 /// ```ignore,no_run
2894 /// # use google_cloud_speech_v2::model::RecognitionFeatures;
2895 /// use google_cloud_speech_v2::model::SpeakerDiarizationConfig;
2896 /// let x = RecognitionFeatures::new().set_or_clear_diarization_config(Some(SpeakerDiarizationConfig::default()/* use setters */));
2897 /// let x = RecognitionFeatures::new().set_or_clear_diarization_config(None::<SpeakerDiarizationConfig>);
2898 /// ```
2899 pub fn set_or_clear_diarization_config<T>(mut self, v: std::option::Option<T>) -> Self
2900 where
2901 T: std::convert::Into<crate::model::SpeakerDiarizationConfig>,
2902 {
2903 self.diarization_config = v.map(|x| x.into());
2904 self
2905 }
2906
2907 /// Sets the value of [max_alternatives][crate::model::RecognitionFeatures::max_alternatives].
2908 ///
2909 /// # Example
2910 /// ```ignore,no_run
2911 /// # use google_cloud_speech_v2::model::RecognitionFeatures;
2912 /// let x = RecognitionFeatures::new().set_max_alternatives(42);
2913 /// ```
2914 pub fn set_max_alternatives<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
2915 self.max_alternatives = v.into();
2916 self
2917 }
2918
2919 /// Sets the value of [custom_prompt_config][crate::model::RecognitionFeatures::custom_prompt_config].
2920 ///
2921 /// # Example
2922 /// ```ignore,no_run
2923 /// # use google_cloud_speech_v2::model::RecognitionFeatures;
2924 /// use google_cloud_speech_v2::model::CustomPromptConfig;
2925 /// let x = RecognitionFeatures::new().set_custom_prompt_config(CustomPromptConfig::default()/* use setters */);
2926 /// ```
2927 pub fn set_custom_prompt_config<T>(mut self, v: T) -> Self
2928 where
2929 T: std::convert::Into<crate::model::CustomPromptConfig>,
2930 {
2931 self.custom_prompt_config = std::option::Option::Some(v.into());
2932 self
2933 }
2934
2935 /// Sets or clears the value of [custom_prompt_config][crate::model::RecognitionFeatures::custom_prompt_config].
2936 ///
2937 /// # Example
2938 /// ```ignore,no_run
2939 /// # use google_cloud_speech_v2::model::RecognitionFeatures;
2940 /// use google_cloud_speech_v2::model::CustomPromptConfig;
2941 /// let x = RecognitionFeatures::new().set_or_clear_custom_prompt_config(Some(CustomPromptConfig::default()/* use setters */));
2942 /// let x = RecognitionFeatures::new().set_or_clear_custom_prompt_config(None::<CustomPromptConfig>);
2943 /// ```
2944 pub fn set_or_clear_custom_prompt_config<T>(mut self, v: std::option::Option<T>) -> Self
2945 where
2946 T: std::convert::Into<crate::model::CustomPromptConfig>,
2947 {
2948 self.custom_prompt_config = v.map(|x| x.into());
2949 self
2950 }
2951}
2952
2953impl wkt::message::Message for RecognitionFeatures {
2954 fn typename() -> &'static str {
2955 "type.googleapis.com/google.cloud.speech.v2.RecognitionFeatures"
2956 }
2957}
2958
2959/// Defines additional types related to [RecognitionFeatures].
2960pub mod recognition_features {
2961 #[allow(unused_imports)]
2962 use super::*;
2963
2964 /// Options for how to recognize multi-channel audio.
2965 ///
2966 /// # Working with unknown values
2967 ///
2968 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2969 /// additional enum variants at any time. Adding new variants is not considered
2970 /// a breaking change. Applications should write their code in anticipation of:
2971 ///
2972 /// - New values appearing in future releases of the client library, **and**
2973 /// - New values received dynamically, without application changes.
2974 ///
2975 /// Please consult the [Working with enums] section in the user guide for some
2976 /// guidelines.
2977 ///
2978 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
2979 #[derive(Clone, Debug, PartialEq)]
2980 #[non_exhaustive]
2981 pub enum MultiChannelMode {
2982 /// Default value for the multi-channel mode. If the audio contains
2983 /// multiple channels, only the first channel will be transcribed; other
2984 /// channels will be ignored.
2985 Unspecified,
2986 /// If selected, each channel in the provided audio is transcribed
2987 /// independently. This cannot be selected if the selected
2988 /// [model][google.cloud.speech.v2.Recognizer.model] is `latest_short`.
2989 ///
2990 /// [google.cloud.speech.v2.Recognizer.model]: crate::model::Recognizer::model
2991 SeparateRecognitionPerChannel,
2992 /// If set, the enum was initialized with an unknown value.
2993 ///
2994 /// Applications can examine the value using [MultiChannelMode::value] or
2995 /// [MultiChannelMode::name].
2996 UnknownValue(multi_channel_mode::UnknownValue),
2997 }
2998
2999 #[doc(hidden)]
3000 pub mod multi_channel_mode {
3001 #[allow(unused_imports)]
3002 use super::*;
3003 #[derive(Clone, Debug, PartialEq)]
3004 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
3005 }
3006
3007 impl MultiChannelMode {
3008 /// Gets the enum value.
3009 ///
3010 /// Returns `None` if the enum contains an unknown value deserialized from
3011 /// the string representation of enums.
3012 pub fn value(&self) -> std::option::Option<i32> {
3013 match self {
3014 Self::Unspecified => std::option::Option::Some(0),
3015 Self::SeparateRecognitionPerChannel => std::option::Option::Some(1),
3016 Self::UnknownValue(u) => u.0.value(),
3017 }
3018 }
3019
3020 /// Gets the enum value as a string.
3021 ///
3022 /// Returns `None` if the enum contains an unknown value deserialized from
3023 /// the integer representation of enums.
3024 pub fn name(&self) -> std::option::Option<&str> {
3025 match self {
3026 Self::Unspecified => std::option::Option::Some("MULTI_CHANNEL_MODE_UNSPECIFIED"),
3027 Self::SeparateRecognitionPerChannel => {
3028 std::option::Option::Some("SEPARATE_RECOGNITION_PER_CHANNEL")
3029 }
3030 Self::UnknownValue(u) => u.0.name(),
3031 }
3032 }
3033 }
3034
3035 impl std::default::Default for MultiChannelMode {
3036 fn default() -> Self {
3037 use std::convert::From;
3038 Self::from(0)
3039 }
3040 }
3041
3042 impl std::fmt::Display for MultiChannelMode {
3043 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
3044 wkt::internal::display_enum(f, self.name(), self.value())
3045 }
3046 }
3047
3048 impl std::convert::From<i32> for MultiChannelMode {
3049 fn from(value: i32) -> Self {
3050 match value {
3051 0 => Self::Unspecified,
3052 1 => Self::SeparateRecognitionPerChannel,
3053 _ => Self::UnknownValue(multi_channel_mode::UnknownValue(
3054 wkt::internal::UnknownEnumValue::Integer(value),
3055 )),
3056 }
3057 }
3058 }
3059
3060 impl std::convert::From<&str> for MultiChannelMode {
3061 fn from(value: &str) -> Self {
3062 use std::string::ToString;
3063 match value {
3064 "MULTI_CHANNEL_MODE_UNSPECIFIED" => Self::Unspecified,
3065 "SEPARATE_RECOGNITION_PER_CHANNEL" => Self::SeparateRecognitionPerChannel,
3066 _ => Self::UnknownValue(multi_channel_mode::UnknownValue(
3067 wkt::internal::UnknownEnumValue::String(value.to_string()),
3068 )),
3069 }
3070 }
3071 }
3072
3073 impl serde::ser::Serialize for MultiChannelMode {
3074 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3075 where
3076 S: serde::Serializer,
3077 {
3078 match self {
3079 Self::Unspecified => serializer.serialize_i32(0),
3080 Self::SeparateRecognitionPerChannel => serializer.serialize_i32(1),
3081 Self::UnknownValue(u) => u.0.serialize(serializer),
3082 }
3083 }
3084 }
3085
3086 impl<'de> serde::de::Deserialize<'de> for MultiChannelMode {
3087 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3088 where
3089 D: serde::Deserializer<'de>,
3090 {
3091 deserializer.deserialize_any(wkt::internal::EnumVisitor::<MultiChannelMode>::new(
3092 ".google.cloud.speech.v2.RecognitionFeatures.MultiChannelMode",
3093 ))
3094 }
3095 }
3096}
3097
3098/// Transcription normalization configuration. Use transcription normalization
3099/// to automatically replace parts of the transcript with phrases of your
3100/// choosing. For StreamingRecognize, this normalization only applies to stable
3101/// partial transcripts (stability > 0.8) and final transcripts.
3102#[derive(Clone, Default, PartialEq)]
3103#[non_exhaustive]
3104pub struct TranscriptNormalization {
3105 /// A list of replacement entries. We will perform replacement with one entry
3106 /// at a time. For example, the second entry in ["cat" => "dog", "mountain cat"
3107 /// => "mountain dog"] will never be applied because we will always process the
3108 /// first entry before it. At most 100 entries.
3109 pub entries: std::vec::Vec<crate::model::transcript_normalization::Entry>,
3110
3111 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3112}
3113
3114impl TranscriptNormalization {
3115 /// Creates a new default instance.
3116 pub fn new() -> Self {
3117 std::default::Default::default()
3118 }
3119
3120 /// Sets the value of [entries][crate::model::TranscriptNormalization::entries].
3121 ///
3122 /// # Example
3123 /// ```ignore,no_run
3124 /// # use google_cloud_speech_v2::model::TranscriptNormalization;
3125 /// use google_cloud_speech_v2::model::transcript_normalization::Entry;
3126 /// let x = TranscriptNormalization::new()
3127 /// .set_entries([
3128 /// Entry::default()/* use setters */,
3129 /// Entry::default()/* use (different) setters */,
3130 /// ]);
3131 /// ```
3132 pub fn set_entries<T, V>(mut self, v: T) -> Self
3133 where
3134 T: std::iter::IntoIterator<Item = V>,
3135 V: std::convert::Into<crate::model::transcript_normalization::Entry>,
3136 {
3137 use std::iter::Iterator;
3138 self.entries = v.into_iter().map(|i| i.into()).collect();
3139 self
3140 }
3141}
3142
3143impl wkt::message::Message for TranscriptNormalization {
3144 fn typename() -> &'static str {
3145 "type.googleapis.com/google.cloud.speech.v2.TranscriptNormalization"
3146 }
3147}
3148
3149/// Defines additional types related to [TranscriptNormalization].
3150pub mod transcript_normalization {
3151 #[allow(unused_imports)]
3152 use super::*;
3153
3154 /// A single replacement configuration.
3155 #[derive(Clone, Default, PartialEq)]
3156 #[non_exhaustive]
3157 pub struct Entry {
3158 /// What to replace. Max length is 100 characters.
3159 pub search: std::string::String,
3160
3161 /// What to replace with. Max length is 100 characters.
3162 pub replace: std::string::String,
3163
3164 /// Whether the search is case sensitive.
3165 pub case_sensitive: bool,
3166
3167 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3168 }
3169
3170 impl Entry {
3171 /// Creates a new default instance.
3172 pub fn new() -> Self {
3173 std::default::Default::default()
3174 }
3175
3176 /// Sets the value of [search][crate::model::transcript_normalization::Entry::search].
3177 ///
3178 /// # Example
3179 /// ```ignore,no_run
3180 /// # use google_cloud_speech_v2::model::transcript_normalization::Entry;
3181 /// let x = Entry::new().set_search("example");
3182 /// ```
3183 pub fn set_search<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3184 self.search = v.into();
3185 self
3186 }
3187
3188 /// Sets the value of [replace][crate::model::transcript_normalization::Entry::replace].
3189 ///
3190 /// # Example
3191 /// ```ignore,no_run
3192 /// # use google_cloud_speech_v2::model::transcript_normalization::Entry;
3193 /// let x = Entry::new().set_replace("example");
3194 /// ```
3195 pub fn set_replace<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3196 self.replace = v.into();
3197 self
3198 }
3199
3200 /// Sets the value of [case_sensitive][crate::model::transcript_normalization::Entry::case_sensitive].
3201 ///
3202 /// # Example
3203 /// ```ignore,no_run
3204 /// # use google_cloud_speech_v2::model::transcript_normalization::Entry;
3205 /// let x = Entry::new().set_case_sensitive(true);
3206 /// ```
3207 pub fn set_case_sensitive<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3208 self.case_sensitive = v.into();
3209 self
3210 }
3211 }
3212
3213 impl wkt::message::Message for Entry {
3214 fn typename() -> &'static str {
3215 "type.googleapis.com/google.cloud.speech.v2.TranscriptNormalization.Entry"
3216 }
3217 }
3218}
3219
3220/// Translation configuration. Use to translate the given audio into text for the
3221/// desired language.
3222#[derive(Clone, Default, PartialEq)]
3223#[non_exhaustive]
3224pub struct TranslationConfig {
3225 /// Required. The language code to translate to.
3226 pub target_language: std::string::String,
3227
3228 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3229}
3230
3231impl TranslationConfig {
3232 /// Creates a new default instance.
3233 pub fn new() -> Self {
3234 std::default::Default::default()
3235 }
3236
3237 /// Sets the value of [target_language][crate::model::TranslationConfig::target_language].
3238 ///
3239 /// # Example
3240 /// ```ignore,no_run
3241 /// # use google_cloud_speech_v2::model::TranslationConfig;
3242 /// let x = TranslationConfig::new().set_target_language("example");
3243 /// ```
3244 pub fn set_target_language<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3245 self.target_language = v.into();
3246 self
3247 }
3248}
3249
3250impl wkt::message::Message for TranslationConfig {
3251 fn typename() -> &'static str {
3252 "type.googleapis.com/google.cloud.speech.v2.TranslationConfig"
3253 }
3254}
3255
3256/// Provides "hints" to the speech recognizer to favor specific words and phrases
3257/// in the results. PhraseSets can be specified as an inline resource, or a
3258/// reference to an existing PhraseSet resource.
3259#[derive(Clone, Default, PartialEq)]
3260#[non_exhaustive]
3261pub struct SpeechAdaptation {
3262 /// A list of inline or referenced PhraseSets.
3263 pub phrase_sets: std::vec::Vec<crate::model::speech_adaptation::AdaptationPhraseSet>,
3264
3265 /// A list of inline CustomClasses. Existing CustomClass resources can be
3266 /// referenced directly in a PhraseSet.
3267 pub custom_classes: std::vec::Vec<crate::model::CustomClass>,
3268
3269 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3270}
3271
3272impl SpeechAdaptation {
3273 /// Creates a new default instance.
3274 pub fn new() -> Self {
3275 std::default::Default::default()
3276 }
3277
3278 /// Sets the value of [phrase_sets][crate::model::SpeechAdaptation::phrase_sets].
3279 ///
3280 /// # Example
3281 /// ```ignore,no_run
3282 /// # use google_cloud_speech_v2::model::SpeechAdaptation;
3283 /// use google_cloud_speech_v2::model::speech_adaptation::AdaptationPhraseSet;
3284 /// let x = SpeechAdaptation::new()
3285 /// .set_phrase_sets([
3286 /// AdaptationPhraseSet::default()/* use setters */,
3287 /// AdaptationPhraseSet::default()/* use (different) setters */,
3288 /// ]);
3289 /// ```
3290 pub fn set_phrase_sets<T, V>(mut self, v: T) -> Self
3291 where
3292 T: std::iter::IntoIterator<Item = V>,
3293 V: std::convert::Into<crate::model::speech_adaptation::AdaptationPhraseSet>,
3294 {
3295 use std::iter::Iterator;
3296 self.phrase_sets = v.into_iter().map(|i| i.into()).collect();
3297 self
3298 }
3299
3300 /// Sets the value of [custom_classes][crate::model::SpeechAdaptation::custom_classes].
3301 ///
3302 /// # Example
3303 /// ```ignore,no_run
3304 /// # use google_cloud_speech_v2::model::SpeechAdaptation;
3305 /// use google_cloud_speech_v2::model::CustomClass;
3306 /// let x = SpeechAdaptation::new()
3307 /// .set_custom_classes([
3308 /// CustomClass::default()/* use setters */,
3309 /// CustomClass::default()/* use (different) setters */,
3310 /// ]);
3311 /// ```
3312 pub fn set_custom_classes<T, V>(mut self, v: T) -> Self
3313 where
3314 T: std::iter::IntoIterator<Item = V>,
3315 V: std::convert::Into<crate::model::CustomClass>,
3316 {
3317 use std::iter::Iterator;
3318 self.custom_classes = v.into_iter().map(|i| i.into()).collect();
3319 self
3320 }
3321}
3322
3323impl wkt::message::Message for SpeechAdaptation {
3324 fn typename() -> &'static str {
3325 "type.googleapis.com/google.cloud.speech.v2.SpeechAdaptation"
3326 }
3327}
3328
3329/// Defines additional types related to [SpeechAdaptation].
3330pub mod speech_adaptation {
3331 #[allow(unused_imports)]
3332 use super::*;
3333
3334 /// A biasing PhraseSet, which can be either a string referencing the name of
3335 /// an existing PhraseSets resource, or an inline definition of a PhraseSet.
3336 #[derive(Clone, Default, PartialEq)]
3337 #[non_exhaustive]
3338 pub struct AdaptationPhraseSet {
3339 #[allow(missing_docs)]
3340 pub value:
3341 std::option::Option<crate::model::speech_adaptation::adaptation_phrase_set::Value>,
3342
3343 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3344 }
3345
3346 impl AdaptationPhraseSet {
3347 /// Creates a new default instance.
3348 pub fn new() -> Self {
3349 std::default::Default::default()
3350 }
3351
3352 /// Sets the value of [value][crate::model::speech_adaptation::AdaptationPhraseSet::value].
3353 ///
3354 /// Note that all the setters affecting `value` are mutually
3355 /// exclusive.
3356 ///
3357 /// # Example
3358 /// ```ignore,no_run
3359 /// # use google_cloud_speech_v2::model::speech_adaptation::AdaptationPhraseSet;
3360 /// use google_cloud_speech_v2::model::speech_adaptation::adaptation_phrase_set::Value;
3361 /// let x = AdaptationPhraseSet::new().set_value(Some(Value::PhraseSet("example".to_string())));
3362 /// ```
3363 pub fn set_value<
3364 T: std::convert::Into<
3365 std::option::Option<
3366 crate::model::speech_adaptation::adaptation_phrase_set::Value,
3367 >,
3368 >,
3369 >(
3370 mut self,
3371 v: T,
3372 ) -> Self {
3373 self.value = v.into();
3374 self
3375 }
3376
3377 /// The value of [value][crate::model::speech_adaptation::AdaptationPhraseSet::value]
3378 /// if it holds a `PhraseSet`, `None` if the field is not set or
3379 /// holds a different branch.
3380 pub fn phrase_set(&self) -> std::option::Option<&std::string::String> {
3381 #[allow(unreachable_patterns)]
3382 self.value.as_ref().and_then(|v| match v {
3383 crate::model::speech_adaptation::adaptation_phrase_set::Value::PhraseSet(v) => {
3384 std::option::Option::Some(v)
3385 }
3386 _ => std::option::Option::None,
3387 })
3388 }
3389
3390 /// Sets the value of [value][crate::model::speech_adaptation::AdaptationPhraseSet::value]
3391 /// to hold a `PhraseSet`.
3392 ///
3393 /// Note that all the setters affecting `value` are
3394 /// mutually exclusive.
3395 ///
3396 /// # Example
3397 /// ```ignore,no_run
3398 /// # use google_cloud_speech_v2::model::speech_adaptation::AdaptationPhraseSet;
3399 /// # let project_id = "project_id";
3400 /// # let location_id = "location_id";
3401 /// # let phrase_set_id = "phrase_set_id";
3402 /// let x = AdaptationPhraseSet::new().set_phrase_set(format!("projects/{project_id}/locations/{location_id}/phraseSets/{phrase_set_id}"));
3403 /// assert!(x.phrase_set().is_some());
3404 /// assert!(x.inline_phrase_set().is_none());
3405 /// ```
3406 pub fn set_phrase_set<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3407 self.value = std::option::Option::Some(
3408 crate::model::speech_adaptation::adaptation_phrase_set::Value::PhraseSet(v.into()),
3409 );
3410 self
3411 }
3412
3413 /// The value of [value][crate::model::speech_adaptation::AdaptationPhraseSet::value]
3414 /// if it holds a `InlinePhraseSet`, `None` if the field is not set or
3415 /// holds a different branch.
3416 pub fn inline_phrase_set(
3417 &self,
3418 ) -> std::option::Option<&std::boxed::Box<crate::model::PhraseSet>> {
3419 #[allow(unreachable_patterns)]
3420 self.value.as_ref().and_then(|v| match v {
3421 crate::model::speech_adaptation::adaptation_phrase_set::Value::InlinePhraseSet(
3422 v,
3423 ) => std::option::Option::Some(v),
3424 _ => std::option::Option::None,
3425 })
3426 }
3427
3428 /// Sets the value of [value][crate::model::speech_adaptation::AdaptationPhraseSet::value]
3429 /// to hold a `InlinePhraseSet`.
3430 ///
3431 /// Note that all the setters affecting `value` are
3432 /// mutually exclusive.
3433 ///
3434 /// # Example
3435 /// ```ignore,no_run
3436 /// # use google_cloud_speech_v2::model::speech_adaptation::AdaptationPhraseSet;
3437 /// use google_cloud_speech_v2::model::PhraseSet;
3438 /// let x = AdaptationPhraseSet::new().set_inline_phrase_set(PhraseSet::default()/* use setters */);
3439 /// assert!(x.inline_phrase_set().is_some());
3440 /// assert!(x.phrase_set().is_none());
3441 /// ```
3442 pub fn set_inline_phrase_set<
3443 T: std::convert::Into<std::boxed::Box<crate::model::PhraseSet>>,
3444 >(
3445 mut self,
3446 v: T,
3447 ) -> Self {
3448 self.value = std::option::Option::Some(
3449 crate::model::speech_adaptation::adaptation_phrase_set::Value::InlinePhraseSet(
3450 v.into(),
3451 ),
3452 );
3453 self
3454 }
3455 }
3456
3457 impl wkt::message::Message for AdaptationPhraseSet {
3458 fn typename() -> &'static str {
3459 "type.googleapis.com/google.cloud.speech.v2.SpeechAdaptation.AdaptationPhraseSet"
3460 }
3461 }
3462
3463 /// Defines additional types related to [AdaptationPhraseSet].
3464 pub mod adaptation_phrase_set {
3465 #[allow(unused_imports)]
3466 use super::*;
3467
3468 #[allow(missing_docs)]
3469 #[derive(Clone, Debug, PartialEq)]
3470 #[non_exhaustive]
3471 pub enum Value {
3472 /// The name of an existing PhraseSet resource. The user must have read
3473 /// access to the resource and it must not be deleted.
3474 PhraseSet(std::string::String),
3475 /// An inline defined PhraseSet.
3476 InlinePhraseSet(std::boxed::Box<crate::model::PhraseSet>),
3477 }
3478 }
3479}
3480
3481/// Denoiser config. May not be supported for all models and may
3482/// have no effect.
3483#[derive(Clone, Default, PartialEq)]
3484#[non_exhaustive]
3485pub struct DenoiserConfig {
3486 /// Denoise audio before sending to the transcription model.
3487 pub denoise_audio: bool,
3488
3489 /// Signal-to-Noise Ratio (SNR) threshold for the denoiser. Here SNR means the
3490 /// loudness of the speech signal. Audio with an SNR below this threshold,
3491 /// meaning the speech is too quiet, will be prevented from being sent to the
3492 /// transcription model.
3493 ///
3494 /// If snr_threshold=0, no filtering will be applied.
3495 pub snr_threshold: f32,
3496
3497 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3498}
3499
3500impl DenoiserConfig {
3501 /// Creates a new default instance.
3502 pub fn new() -> Self {
3503 std::default::Default::default()
3504 }
3505
3506 /// Sets the value of [denoise_audio][crate::model::DenoiserConfig::denoise_audio].
3507 ///
3508 /// # Example
3509 /// ```ignore,no_run
3510 /// # use google_cloud_speech_v2::model::DenoiserConfig;
3511 /// let x = DenoiserConfig::new().set_denoise_audio(true);
3512 /// ```
3513 pub fn set_denoise_audio<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3514 self.denoise_audio = v.into();
3515 self
3516 }
3517
3518 /// Sets the value of [snr_threshold][crate::model::DenoiserConfig::snr_threshold].
3519 ///
3520 /// # Example
3521 /// ```ignore,no_run
3522 /// # use google_cloud_speech_v2::model::DenoiserConfig;
3523 /// let x = DenoiserConfig::new().set_snr_threshold(42.0);
3524 /// ```
3525 pub fn set_snr_threshold<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
3526 self.snr_threshold = v.into();
3527 self
3528 }
3529}
3530
3531impl wkt::message::Message for DenoiserConfig {
3532 fn typename() -> &'static str {
3533 "type.googleapis.com/google.cloud.speech.v2.DenoiserConfig"
3534 }
3535}
3536
3537/// Provides information to the Recognizer that specifies how to process the
3538/// recognition request.
3539#[derive(Clone, Default, PartialEq)]
3540#[non_exhaustive]
3541pub struct RecognitionConfig {
3542 /// Optional. Which model to use for recognition requests. Select the model
3543 /// best suited to your domain to get best results.
3544 ///
3545 /// Guidance for choosing which model to use can be found in the [Transcription
3546 /// Models
3547 /// Documentation](https://cloud.google.com/speech-to-text/v2/docs/transcription-model)
3548 /// and the models supported in each region can be found in the [Table Of
3549 /// Supported
3550 /// Models](https://cloud.google.com/speech-to-text/v2/docs/speech-to-text-supported-languages).
3551 pub model: std::string::String,
3552
3553 /// Optional. The language of the supplied audio as a
3554 /// [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag.
3555 /// Language tags are normalized to BCP-47 before they are used eg "en-us"
3556 /// becomes "en-US".
3557 ///
3558 /// Supported languages for each model are listed in the [Table of Supported
3559 /// Models](https://cloud.google.com/speech-to-text/v2/docs/speech-to-text-supported-languages).
3560 ///
3561 /// If additional languages are provided, recognition result will contain
3562 /// recognition in the most likely language detected. The recognition result
3563 /// will include the language tag of the language detected in the audio.
3564 pub language_codes: std::vec::Vec<std::string::String>,
3565
3566 /// Speech recognition features to enable.
3567 pub features: std::option::Option<crate::model::RecognitionFeatures>,
3568
3569 /// Speech adaptation context that weights recognizer predictions for specific
3570 /// words and phrases.
3571 pub adaptation: std::option::Option<crate::model::SpeechAdaptation>,
3572
3573 /// Optional. Use transcription normalization to automatically replace parts of
3574 /// the transcript with phrases of your choosing. For StreamingRecognize, this
3575 /// normalization only applies to stable partial transcripts (stability > 0.8)
3576 /// and final transcripts.
3577 pub transcript_normalization: std::option::Option<crate::model::TranscriptNormalization>,
3578
3579 /// Optional. Optional configuration used to automatically run translation on
3580 /// the given audio to the desired language for supported models.
3581 pub translation_config: std::option::Option<crate::model::TranslationConfig>,
3582
3583 /// Optional. Optional denoiser config. May not be supported for all models
3584 /// and may have no effect.
3585 pub denoiser_config: std::option::Option<crate::model::DenoiserConfig>,
3586
3587 /// Decoding parameters for audio being sent for recognition.
3588 pub decoding_config: std::option::Option<crate::model::recognition_config::DecodingConfig>,
3589
3590 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3591}
3592
3593impl RecognitionConfig {
3594 /// Creates a new default instance.
3595 pub fn new() -> Self {
3596 std::default::Default::default()
3597 }
3598
3599 /// Sets the value of [model][crate::model::RecognitionConfig::model].
3600 ///
3601 /// # Example
3602 /// ```ignore,no_run
3603 /// # use google_cloud_speech_v2::model::RecognitionConfig;
3604 /// let x = RecognitionConfig::new().set_model("example");
3605 /// ```
3606 pub fn set_model<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3607 self.model = v.into();
3608 self
3609 }
3610
3611 /// Sets the value of [language_codes][crate::model::RecognitionConfig::language_codes].
3612 ///
3613 /// # Example
3614 /// ```ignore,no_run
3615 /// # use google_cloud_speech_v2::model::RecognitionConfig;
3616 /// let x = RecognitionConfig::new().set_language_codes(["a", "b", "c"]);
3617 /// ```
3618 pub fn set_language_codes<T, V>(mut self, v: T) -> Self
3619 where
3620 T: std::iter::IntoIterator<Item = V>,
3621 V: std::convert::Into<std::string::String>,
3622 {
3623 use std::iter::Iterator;
3624 self.language_codes = v.into_iter().map(|i| i.into()).collect();
3625 self
3626 }
3627
3628 /// Sets the value of [features][crate::model::RecognitionConfig::features].
3629 ///
3630 /// # Example
3631 /// ```ignore,no_run
3632 /// # use google_cloud_speech_v2::model::RecognitionConfig;
3633 /// use google_cloud_speech_v2::model::RecognitionFeatures;
3634 /// let x = RecognitionConfig::new().set_features(RecognitionFeatures::default()/* use setters */);
3635 /// ```
3636 pub fn set_features<T>(mut self, v: T) -> Self
3637 where
3638 T: std::convert::Into<crate::model::RecognitionFeatures>,
3639 {
3640 self.features = std::option::Option::Some(v.into());
3641 self
3642 }
3643
3644 /// Sets or clears the value of [features][crate::model::RecognitionConfig::features].
3645 ///
3646 /// # Example
3647 /// ```ignore,no_run
3648 /// # use google_cloud_speech_v2::model::RecognitionConfig;
3649 /// use google_cloud_speech_v2::model::RecognitionFeatures;
3650 /// let x = RecognitionConfig::new().set_or_clear_features(Some(RecognitionFeatures::default()/* use setters */));
3651 /// let x = RecognitionConfig::new().set_or_clear_features(None::<RecognitionFeatures>);
3652 /// ```
3653 pub fn set_or_clear_features<T>(mut self, v: std::option::Option<T>) -> Self
3654 where
3655 T: std::convert::Into<crate::model::RecognitionFeatures>,
3656 {
3657 self.features = v.map(|x| x.into());
3658 self
3659 }
3660
3661 /// Sets the value of [adaptation][crate::model::RecognitionConfig::adaptation].
3662 ///
3663 /// # Example
3664 /// ```ignore,no_run
3665 /// # use google_cloud_speech_v2::model::RecognitionConfig;
3666 /// use google_cloud_speech_v2::model::SpeechAdaptation;
3667 /// let x = RecognitionConfig::new().set_adaptation(SpeechAdaptation::default()/* use setters */);
3668 /// ```
3669 pub fn set_adaptation<T>(mut self, v: T) -> Self
3670 where
3671 T: std::convert::Into<crate::model::SpeechAdaptation>,
3672 {
3673 self.adaptation = std::option::Option::Some(v.into());
3674 self
3675 }
3676
3677 /// Sets or clears the value of [adaptation][crate::model::RecognitionConfig::adaptation].
3678 ///
3679 /// # Example
3680 /// ```ignore,no_run
3681 /// # use google_cloud_speech_v2::model::RecognitionConfig;
3682 /// use google_cloud_speech_v2::model::SpeechAdaptation;
3683 /// let x = RecognitionConfig::new().set_or_clear_adaptation(Some(SpeechAdaptation::default()/* use setters */));
3684 /// let x = RecognitionConfig::new().set_or_clear_adaptation(None::<SpeechAdaptation>);
3685 /// ```
3686 pub fn set_or_clear_adaptation<T>(mut self, v: std::option::Option<T>) -> Self
3687 where
3688 T: std::convert::Into<crate::model::SpeechAdaptation>,
3689 {
3690 self.adaptation = v.map(|x| x.into());
3691 self
3692 }
3693
3694 /// Sets the value of [transcript_normalization][crate::model::RecognitionConfig::transcript_normalization].
3695 ///
3696 /// # Example
3697 /// ```ignore,no_run
3698 /// # use google_cloud_speech_v2::model::RecognitionConfig;
3699 /// use google_cloud_speech_v2::model::TranscriptNormalization;
3700 /// let x = RecognitionConfig::new().set_transcript_normalization(TranscriptNormalization::default()/* use setters */);
3701 /// ```
3702 pub fn set_transcript_normalization<T>(mut self, v: T) -> Self
3703 where
3704 T: std::convert::Into<crate::model::TranscriptNormalization>,
3705 {
3706 self.transcript_normalization = std::option::Option::Some(v.into());
3707 self
3708 }
3709
3710 /// Sets or clears the value of [transcript_normalization][crate::model::RecognitionConfig::transcript_normalization].
3711 ///
3712 /// # Example
3713 /// ```ignore,no_run
3714 /// # use google_cloud_speech_v2::model::RecognitionConfig;
3715 /// use google_cloud_speech_v2::model::TranscriptNormalization;
3716 /// let x = RecognitionConfig::new().set_or_clear_transcript_normalization(Some(TranscriptNormalization::default()/* use setters */));
3717 /// let x = RecognitionConfig::new().set_or_clear_transcript_normalization(None::<TranscriptNormalization>);
3718 /// ```
3719 pub fn set_or_clear_transcript_normalization<T>(mut self, v: std::option::Option<T>) -> Self
3720 where
3721 T: std::convert::Into<crate::model::TranscriptNormalization>,
3722 {
3723 self.transcript_normalization = v.map(|x| x.into());
3724 self
3725 }
3726
3727 /// Sets the value of [translation_config][crate::model::RecognitionConfig::translation_config].
3728 ///
3729 /// # Example
3730 /// ```ignore,no_run
3731 /// # use google_cloud_speech_v2::model::RecognitionConfig;
3732 /// use google_cloud_speech_v2::model::TranslationConfig;
3733 /// let x = RecognitionConfig::new().set_translation_config(TranslationConfig::default()/* use setters */);
3734 /// ```
3735 pub fn set_translation_config<T>(mut self, v: T) -> Self
3736 where
3737 T: std::convert::Into<crate::model::TranslationConfig>,
3738 {
3739 self.translation_config = std::option::Option::Some(v.into());
3740 self
3741 }
3742
3743 /// Sets or clears the value of [translation_config][crate::model::RecognitionConfig::translation_config].
3744 ///
3745 /// # Example
3746 /// ```ignore,no_run
3747 /// # use google_cloud_speech_v2::model::RecognitionConfig;
3748 /// use google_cloud_speech_v2::model::TranslationConfig;
3749 /// let x = RecognitionConfig::new().set_or_clear_translation_config(Some(TranslationConfig::default()/* use setters */));
3750 /// let x = RecognitionConfig::new().set_or_clear_translation_config(None::<TranslationConfig>);
3751 /// ```
3752 pub fn set_or_clear_translation_config<T>(mut self, v: std::option::Option<T>) -> Self
3753 where
3754 T: std::convert::Into<crate::model::TranslationConfig>,
3755 {
3756 self.translation_config = v.map(|x| x.into());
3757 self
3758 }
3759
3760 /// Sets the value of [denoiser_config][crate::model::RecognitionConfig::denoiser_config].
3761 ///
3762 /// # Example
3763 /// ```ignore,no_run
3764 /// # use google_cloud_speech_v2::model::RecognitionConfig;
3765 /// use google_cloud_speech_v2::model::DenoiserConfig;
3766 /// let x = RecognitionConfig::new().set_denoiser_config(DenoiserConfig::default()/* use setters */);
3767 /// ```
3768 pub fn set_denoiser_config<T>(mut self, v: T) -> Self
3769 where
3770 T: std::convert::Into<crate::model::DenoiserConfig>,
3771 {
3772 self.denoiser_config = std::option::Option::Some(v.into());
3773 self
3774 }
3775
3776 /// Sets or clears the value of [denoiser_config][crate::model::RecognitionConfig::denoiser_config].
3777 ///
3778 /// # Example
3779 /// ```ignore,no_run
3780 /// # use google_cloud_speech_v2::model::RecognitionConfig;
3781 /// use google_cloud_speech_v2::model::DenoiserConfig;
3782 /// let x = RecognitionConfig::new().set_or_clear_denoiser_config(Some(DenoiserConfig::default()/* use setters */));
3783 /// let x = RecognitionConfig::new().set_or_clear_denoiser_config(None::<DenoiserConfig>);
3784 /// ```
3785 pub fn set_or_clear_denoiser_config<T>(mut self, v: std::option::Option<T>) -> Self
3786 where
3787 T: std::convert::Into<crate::model::DenoiserConfig>,
3788 {
3789 self.denoiser_config = v.map(|x| x.into());
3790 self
3791 }
3792
3793 /// Sets the value of [decoding_config][crate::model::RecognitionConfig::decoding_config].
3794 ///
3795 /// Note that all the setters affecting `decoding_config` are mutually
3796 /// exclusive.
3797 ///
3798 /// # Example
3799 /// ```ignore,no_run
3800 /// # use google_cloud_speech_v2::model::RecognitionConfig;
3801 /// use google_cloud_speech_v2::model::AutoDetectDecodingConfig;
3802 /// let x = RecognitionConfig::new().set_decoding_config(Some(
3803 /// google_cloud_speech_v2::model::recognition_config::DecodingConfig::AutoDecodingConfig(AutoDetectDecodingConfig::default().into())));
3804 /// ```
3805 pub fn set_decoding_config<
3806 T: std::convert::Into<std::option::Option<crate::model::recognition_config::DecodingConfig>>,
3807 >(
3808 mut self,
3809 v: T,
3810 ) -> Self {
3811 self.decoding_config = v.into();
3812 self
3813 }
3814
3815 /// The value of [decoding_config][crate::model::RecognitionConfig::decoding_config]
3816 /// if it holds a `AutoDecodingConfig`, `None` if the field is not set or
3817 /// holds a different branch.
3818 pub fn auto_decoding_config(
3819 &self,
3820 ) -> std::option::Option<&std::boxed::Box<crate::model::AutoDetectDecodingConfig>> {
3821 #[allow(unreachable_patterns)]
3822 self.decoding_config.as_ref().and_then(|v| match v {
3823 crate::model::recognition_config::DecodingConfig::AutoDecodingConfig(v) => {
3824 std::option::Option::Some(v)
3825 }
3826 _ => std::option::Option::None,
3827 })
3828 }
3829
3830 /// Sets the value of [decoding_config][crate::model::RecognitionConfig::decoding_config]
3831 /// to hold a `AutoDecodingConfig`.
3832 ///
3833 /// Note that all the setters affecting `decoding_config` are
3834 /// mutually exclusive.
3835 ///
3836 /// # Example
3837 /// ```ignore,no_run
3838 /// # use google_cloud_speech_v2::model::RecognitionConfig;
3839 /// use google_cloud_speech_v2::model::AutoDetectDecodingConfig;
3840 /// let x = RecognitionConfig::new().set_auto_decoding_config(AutoDetectDecodingConfig::default()/* use setters */);
3841 /// assert!(x.auto_decoding_config().is_some());
3842 /// assert!(x.explicit_decoding_config().is_none());
3843 /// ```
3844 pub fn set_auto_decoding_config<
3845 T: std::convert::Into<std::boxed::Box<crate::model::AutoDetectDecodingConfig>>,
3846 >(
3847 mut self,
3848 v: T,
3849 ) -> Self {
3850 self.decoding_config = std::option::Option::Some(
3851 crate::model::recognition_config::DecodingConfig::AutoDecodingConfig(v.into()),
3852 );
3853 self
3854 }
3855
3856 /// The value of [decoding_config][crate::model::RecognitionConfig::decoding_config]
3857 /// if it holds a `ExplicitDecodingConfig`, `None` if the field is not set or
3858 /// holds a different branch.
3859 pub fn explicit_decoding_config(
3860 &self,
3861 ) -> std::option::Option<&std::boxed::Box<crate::model::ExplicitDecodingConfig>> {
3862 #[allow(unreachable_patterns)]
3863 self.decoding_config.as_ref().and_then(|v| match v {
3864 crate::model::recognition_config::DecodingConfig::ExplicitDecodingConfig(v) => {
3865 std::option::Option::Some(v)
3866 }
3867 _ => std::option::Option::None,
3868 })
3869 }
3870
3871 /// Sets the value of [decoding_config][crate::model::RecognitionConfig::decoding_config]
3872 /// to hold a `ExplicitDecodingConfig`.
3873 ///
3874 /// Note that all the setters affecting `decoding_config` are
3875 /// mutually exclusive.
3876 ///
3877 /// # Example
3878 /// ```ignore,no_run
3879 /// # use google_cloud_speech_v2::model::RecognitionConfig;
3880 /// use google_cloud_speech_v2::model::ExplicitDecodingConfig;
3881 /// let x = RecognitionConfig::new().set_explicit_decoding_config(ExplicitDecodingConfig::default()/* use setters */);
3882 /// assert!(x.explicit_decoding_config().is_some());
3883 /// assert!(x.auto_decoding_config().is_none());
3884 /// ```
3885 pub fn set_explicit_decoding_config<
3886 T: std::convert::Into<std::boxed::Box<crate::model::ExplicitDecodingConfig>>,
3887 >(
3888 mut self,
3889 v: T,
3890 ) -> Self {
3891 self.decoding_config = std::option::Option::Some(
3892 crate::model::recognition_config::DecodingConfig::ExplicitDecodingConfig(v.into()),
3893 );
3894 self
3895 }
3896}
3897
3898impl wkt::message::Message for RecognitionConfig {
3899 fn typename() -> &'static str {
3900 "type.googleapis.com/google.cloud.speech.v2.RecognitionConfig"
3901 }
3902}
3903
3904/// Defines additional types related to [RecognitionConfig].
3905pub mod recognition_config {
3906 #[allow(unused_imports)]
3907 use super::*;
3908
3909 /// Decoding parameters for audio being sent for recognition.
3910 #[derive(Clone, Debug, PartialEq)]
3911 #[non_exhaustive]
3912 pub enum DecodingConfig {
3913 /// Automatically detect decoding parameters.
3914 /// Preferred for supported formats.
3915 AutoDecodingConfig(std::boxed::Box<crate::model::AutoDetectDecodingConfig>),
3916 /// Explicitly specified decoding parameters.
3917 /// Required if using headerless PCM audio (linear16, mulaw, alaw).
3918 ExplicitDecodingConfig(std::boxed::Box<crate::model::ExplicitDecodingConfig>),
3919 }
3920}
3921
3922/// Request message for the
3923/// [Recognize][google.cloud.speech.v2.Speech.Recognize] method. Either
3924/// `content` or `uri` must be supplied. Supplying both or neither returns
3925/// [INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]. See [content
3926/// limits](https://cloud.google.com/speech-to-text/quotas#content).
3927///
3928/// [google.cloud.speech.v2.Speech.Recognize]: crate::client::Speech::recognize
3929#[derive(Clone, Default, PartialEq)]
3930#[non_exhaustive]
3931pub struct RecognizeRequest {
3932 /// Required. The name of the Recognizer to use during recognition. The
3933 /// expected format is
3934 /// `projects/{project}/locations/{location}/recognizers/{recognizer}`. The
3935 /// {recognizer} segment may be set to `_` to use an empty implicit Recognizer.
3936 pub recognizer: std::string::String,
3937
3938 /// Features and audio metadata to use for the Automatic Speech Recognition.
3939 /// This field in combination with the
3940 /// [config_mask][google.cloud.speech.v2.RecognizeRequest.config_mask] field
3941 /// can be used to override parts of the
3942 /// [default_recognition_config][google.cloud.speech.v2.Recognizer.default_recognition_config]
3943 /// of the Recognizer resource.
3944 ///
3945 /// [google.cloud.speech.v2.RecognizeRequest.config_mask]: crate::model::RecognizeRequest::config_mask
3946 /// [google.cloud.speech.v2.Recognizer.default_recognition_config]: crate::model::Recognizer::default_recognition_config
3947 pub config: std::option::Option<crate::model::RecognitionConfig>,
3948
3949 /// The list of fields in
3950 /// [config][google.cloud.speech.v2.RecognizeRequest.config] that override the
3951 /// values in the
3952 /// [default_recognition_config][google.cloud.speech.v2.Recognizer.default_recognition_config]
3953 /// of the recognizer during this recognition request. If no mask is provided,
3954 /// all non-default valued fields in
3955 /// [config][google.cloud.speech.v2.RecognizeRequest.config] override the
3956 /// values in the recognizer for this recognition request. If a mask is
3957 /// provided, only the fields listed in the mask override the config in the
3958 /// recognizer for this recognition request. If a wildcard (`*`) is provided,
3959 /// [config][google.cloud.speech.v2.RecognizeRequest.config] completely
3960 /// overrides and replaces the config in the recognizer for this recognition
3961 /// request.
3962 ///
3963 /// [google.cloud.speech.v2.RecognizeRequest.config]: crate::model::RecognizeRequest::config
3964 /// [google.cloud.speech.v2.Recognizer.default_recognition_config]: crate::model::Recognizer::default_recognition_config
3965 pub config_mask: std::option::Option<wkt::FieldMask>,
3966
3967 /// The audio source, which is either inline content or a Google Cloud
3968 /// Storage URI.
3969 pub audio_source: std::option::Option<crate::model::recognize_request::AudioSource>,
3970
3971 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3972}
3973
3974impl RecognizeRequest {
3975 /// Creates a new default instance.
3976 pub fn new() -> Self {
3977 std::default::Default::default()
3978 }
3979
3980 /// Sets the value of [recognizer][crate::model::RecognizeRequest::recognizer].
3981 ///
3982 /// # Example
3983 /// ```ignore,no_run
3984 /// # use google_cloud_speech_v2::model::RecognizeRequest;
3985 /// # let project_id = "project_id";
3986 /// # let location_id = "location_id";
3987 /// # let recognizer_id = "recognizer_id";
3988 /// let x = RecognizeRequest::new().set_recognizer(format!("projects/{project_id}/locations/{location_id}/recognizers/{recognizer_id}"));
3989 /// ```
3990 pub fn set_recognizer<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3991 self.recognizer = v.into();
3992 self
3993 }
3994
3995 /// Sets the value of [config][crate::model::RecognizeRequest::config].
3996 ///
3997 /// # Example
3998 /// ```ignore,no_run
3999 /// # use google_cloud_speech_v2::model::RecognizeRequest;
4000 /// use google_cloud_speech_v2::model::RecognitionConfig;
4001 /// let x = RecognizeRequest::new().set_config(RecognitionConfig::default()/* use setters */);
4002 /// ```
4003 pub fn set_config<T>(mut self, v: T) -> Self
4004 where
4005 T: std::convert::Into<crate::model::RecognitionConfig>,
4006 {
4007 self.config = std::option::Option::Some(v.into());
4008 self
4009 }
4010
4011 /// Sets or clears the value of [config][crate::model::RecognizeRequest::config].
4012 ///
4013 /// # Example
4014 /// ```ignore,no_run
4015 /// # use google_cloud_speech_v2::model::RecognizeRequest;
4016 /// use google_cloud_speech_v2::model::RecognitionConfig;
4017 /// let x = RecognizeRequest::new().set_or_clear_config(Some(RecognitionConfig::default()/* use setters */));
4018 /// let x = RecognizeRequest::new().set_or_clear_config(None::<RecognitionConfig>);
4019 /// ```
4020 pub fn set_or_clear_config<T>(mut self, v: std::option::Option<T>) -> Self
4021 where
4022 T: std::convert::Into<crate::model::RecognitionConfig>,
4023 {
4024 self.config = v.map(|x| x.into());
4025 self
4026 }
4027
4028 /// Sets the value of [config_mask][crate::model::RecognizeRequest::config_mask].
4029 ///
4030 /// # Example
4031 /// ```ignore,no_run
4032 /// # use google_cloud_speech_v2::model::RecognizeRequest;
4033 /// use wkt::FieldMask;
4034 /// let x = RecognizeRequest::new().set_config_mask(FieldMask::default()/* use setters */);
4035 /// ```
4036 pub fn set_config_mask<T>(mut self, v: T) -> Self
4037 where
4038 T: std::convert::Into<wkt::FieldMask>,
4039 {
4040 self.config_mask = std::option::Option::Some(v.into());
4041 self
4042 }
4043
4044 /// Sets or clears the value of [config_mask][crate::model::RecognizeRequest::config_mask].
4045 ///
4046 /// # Example
4047 /// ```ignore,no_run
4048 /// # use google_cloud_speech_v2::model::RecognizeRequest;
4049 /// use wkt::FieldMask;
4050 /// let x = RecognizeRequest::new().set_or_clear_config_mask(Some(FieldMask::default()/* use setters */));
4051 /// let x = RecognizeRequest::new().set_or_clear_config_mask(None::<FieldMask>);
4052 /// ```
4053 pub fn set_or_clear_config_mask<T>(mut self, v: std::option::Option<T>) -> Self
4054 where
4055 T: std::convert::Into<wkt::FieldMask>,
4056 {
4057 self.config_mask = v.map(|x| x.into());
4058 self
4059 }
4060
4061 /// Sets the value of [audio_source][crate::model::RecognizeRequest::audio_source].
4062 ///
4063 /// Note that all the setters affecting `audio_source` are mutually
4064 /// exclusive.
4065 ///
4066 /// # Example
4067 /// ```ignore,no_run
4068 /// # use google_cloud_speech_v2::model::RecognizeRequest;
4069 /// use google_cloud_speech_v2::model::recognize_request::AudioSource;
4070 /// let x = RecognizeRequest::new().set_audio_source(Some(AudioSource::Content(bytes::Bytes::from_static(b"example"))));
4071 /// ```
4072 pub fn set_audio_source<
4073 T: std::convert::Into<std::option::Option<crate::model::recognize_request::AudioSource>>,
4074 >(
4075 mut self,
4076 v: T,
4077 ) -> Self {
4078 self.audio_source = v.into();
4079 self
4080 }
4081
4082 /// The value of [audio_source][crate::model::RecognizeRequest::audio_source]
4083 /// if it holds a `Content`, `None` if the field is not set or
4084 /// holds a different branch.
4085 pub fn content(&self) -> std::option::Option<&::bytes::Bytes> {
4086 #[allow(unreachable_patterns)]
4087 self.audio_source.as_ref().and_then(|v| match v {
4088 crate::model::recognize_request::AudioSource::Content(v) => {
4089 std::option::Option::Some(v)
4090 }
4091 _ => std::option::Option::None,
4092 })
4093 }
4094
4095 /// Sets the value of [audio_source][crate::model::RecognizeRequest::audio_source]
4096 /// to hold a `Content`.
4097 ///
4098 /// Note that all the setters affecting `audio_source` are
4099 /// mutually exclusive.
4100 ///
4101 /// # Example
4102 /// ```ignore,no_run
4103 /// # use google_cloud_speech_v2::model::RecognizeRequest;
4104 /// let x = RecognizeRequest::new().set_content(bytes::Bytes::from_static(b"example"));
4105 /// assert!(x.content().is_some());
4106 /// assert!(x.uri().is_none());
4107 /// ```
4108 pub fn set_content<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
4109 self.audio_source = std::option::Option::Some(
4110 crate::model::recognize_request::AudioSource::Content(v.into()),
4111 );
4112 self
4113 }
4114
4115 /// The value of [audio_source][crate::model::RecognizeRequest::audio_source]
4116 /// if it holds a `Uri`, `None` if the field is not set or
4117 /// holds a different branch.
4118 pub fn uri(&self) -> std::option::Option<&std::string::String> {
4119 #[allow(unreachable_patterns)]
4120 self.audio_source.as_ref().and_then(|v| match v {
4121 crate::model::recognize_request::AudioSource::Uri(v) => std::option::Option::Some(v),
4122 _ => std::option::Option::None,
4123 })
4124 }
4125
4126 /// Sets the value of [audio_source][crate::model::RecognizeRequest::audio_source]
4127 /// to hold a `Uri`.
4128 ///
4129 /// Note that all the setters affecting `audio_source` are
4130 /// mutually exclusive.
4131 ///
4132 /// # Example
4133 /// ```ignore,no_run
4134 /// # use google_cloud_speech_v2::model::RecognizeRequest;
4135 /// let x = RecognizeRequest::new().set_uri("example");
4136 /// assert!(x.uri().is_some());
4137 /// assert!(x.content().is_none());
4138 /// ```
4139 pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4140 self.audio_source =
4141 std::option::Option::Some(crate::model::recognize_request::AudioSource::Uri(v.into()));
4142 self
4143 }
4144}
4145
4146impl wkt::message::Message for RecognizeRequest {
4147 fn typename() -> &'static str {
4148 "type.googleapis.com/google.cloud.speech.v2.RecognizeRequest"
4149 }
4150}
4151
4152/// Defines additional types related to [RecognizeRequest].
4153pub mod recognize_request {
4154 #[allow(unused_imports)]
4155 use super::*;
4156
4157 /// The audio source, which is either inline content or a Google Cloud
4158 /// Storage URI.
4159 #[derive(Clone, Debug, PartialEq)]
4160 #[non_exhaustive]
4161 pub enum AudioSource {
4162 /// The audio data bytes encoded as specified in
4163 /// [RecognitionConfig][google.cloud.speech.v2.RecognitionConfig]. As
4164 /// with all bytes fields, proto buffers use a pure binary representation,
4165 /// whereas JSON representations use base64.
4166 ///
4167 /// [google.cloud.speech.v2.RecognitionConfig]: crate::model::RecognitionConfig
4168 Content(::bytes::Bytes),
4169 /// URI that points to a file that contains audio data bytes as specified in
4170 /// [RecognitionConfig][google.cloud.speech.v2.RecognitionConfig]. The file
4171 /// must not be compressed (for example, gzip). Currently, only Google Cloud
4172 /// Storage URIs are supported, which must be specified in the following
4173 /// format: `gs://bucket_name/object_name` (other URI formats return
4174 /// [INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]). For more
4175 /// information, see [Request
4176 /// URIs](https://cloud.google.com/storage/docs/reference-uris).
4177 ///
4178 /// [google.cloud.speech.v2.RecognitionConfig]: crate::model::RecognitionConfig
4179 Uri(std::string::String),
4180 }
4181}
4182
4183/// Metadata about the recognition request and response.
4184#[derive(Clone, Default, PartialEq)]
4185#[non_exhaustive]
4186pub struct RecognitionResponseMetadata {
4187 /// Global request identifier auto-generated by the API.
4188 pub request_id: std::string::String,
4189
4190 /// When available, billed audio seconds for the corresponding request.
4191 pub total_billed_duration: std::option::Option<wkt::Duration>,
4192
4193 /// Optional. Output only. Provides the prompt used for the recognition
4194 /// request.
4195 pub prompt: std::option::Option<std::string::String>,
4196
4197 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4198}
4199
4200impl RecognitionResponseMetadata {
4201 /// Creates a new default instance.
4202 pub fn new() -> Self {
4203 std::default::Default::default()
4204 }
4205
4206 /// Sets the value of [request_id][crate::model::RecognitionResponseMetadata::request_id].
4207 ///
4208 /// # Example
4209 /// ```ignore,no_run
4210 /// # use google_cloud_speech_v2::model::RecognitionResponseMetadata;
4211 /// let x = RecognitionResponseMetadata::new().set_request_id("example");
4212 /// ```
4213 pub fn set_request_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4214 self.request_id = v.into();
4215 self
4216 }
4217
4218 /// Sets the value of [total_billed_duration][crate::model::RecognitionResponseMetadata::total_billed_duration].
4219 ///
4220 /// # Example
4221 /// ```ignore,no_run
4222 /// # use google_cloud_speech_v2::model::RecognitionResponseMetadata;
4223 /// use wkt::Duration;
4224 /// let x = RecognitionResponseMetadata::new().set_total_billed_duration(Duration::default()/* use setters */);
4225 /// ```
4226 pub fn set_total_billed_duration<T>(mut self, v: T) -> Self
4227 where
4228 T: std::convert::Into<wkt::Duration>,
4229 {
4230 self.total_billed_duration = std::option::Option::Some(v.into());
4231 self
4232 }
4233
4234 /// Sets or clears the value of [total_billed_duration][crate::model::RecognitionResponseMetadata::total_billed_duration].
4235 ///
4236 /// # Example
4237 /// ```ignore,no_run
4238 /// # use google_cloud_speech_v2::model::RecognitionResponseMetadata;
4239 /// use wkt::Duration;
4240 /// let x = RecognitionResponseMetadata::new().set_or_clear_total_billed_duration(Some(Duration::default()/* use setters */));
4241 /// let x = RecognitionResponseMetadata::new().set_or_clear_total_billed_duration(None::<Duration>);
4242 /// ```
4243 pub fn set_or_clear_total_billed_duration<T>(mut self, v: std::option::Option<T>) -> Self
4244 where
4245 T: std::convert::Into<wkt::Duration>,
4246 {
4247 self.total_billed_duration = v.map(|x| x.into());
4248 self
4249 }
4250
4251 /// Sets the value of [prompt][crate::model::RecognitionResponseMetadata::prompt].
4252 ///
4253 /// # Example
4254 /// ```ignore,no_run
4255 /// # use google_cloud_speech_v2::model::RecognitionResponseMetadata;
4256 /// let x = RecognitionResponseMetadata::new().set_prompt("example");
4257 /// ```
4258 pub fn set_prompt<T>(mut self, v: T) -> Self
4259 where
4260 T: std::convert::Into<std::string::String>,
4261 {
4262 self.prompt = std::option::Option::Some(v.into());
4263 self
4264 }
4265
4266 /// Sets or clears the value of [prompt][crate::model::RecognitionResponseMetadata::prompt].
4267 ///
4268 /// # Example
4269 /// ```ignore,no_run
4270 /// # use google_cloud_speech_v2::model::RecognitionResponseMetadata;
4271 /// let x = RecognitionResponseMetadata::new().set_or_clear_prompt(Some("example"));
4272 /// let x = RecognitionResponseMetadata::new().set_or_clear_prompt(None::<String>);
4273 /// ```
4274 pub fn set_or_clear_prompt<T>(mut self, v: std::option::Option<T>) -> Self
4275 where
4276 T: std::convert::Into<std::string::String>,
4277 {
4278 self.prompt = v.map(|x| x.into());
4279 self
4280 }
4281}
4282
4283impl wkt::message::Message for RecognitionResponseMetadata {
4284 fn typename() -> &'static str {
4285 "type.googleapis.com/google.cloud.speech.v2.RecognitionResponseMetadata"
4286 }
4287}
4288
4289/// Alternative hypotheses (a.k.a. n-best list).
4290#[derive(Clone, Default, PartialEq)]
4291#[non_exhaustive]
4292pub struct SpeechRecognitionAlternative {
4293 /// Transcript text representing the words that the user spoke.
4294 pub transcript: std::string::String,
4295
4296 /// The confidence estimate between 0.0 and 1.0. A higher number
4297 /// indicates an estimated greater likelihood that the recognized words are
4298 /// correct. This field is set only for the top alternative of a non-streaming
4299 /// result or, of a streaming result where
4300 /// [is_final][google.cloud.speech.v2.StreamingRecognitionResult.is_final] is
4301 /// set to `true`. This field is not guaranteed to be accurate and users should
4302 /// not rely on it to be always provided. The default of 0.0 is a sentinel
4303 /// value indicating `confidence` was not set.
4304 ///
4305 /// [google.cloud.speech.v2.StreamingRecognitionResult.is_final]: crate::model::StreamingRecognitionResult::is_final
4306 pub confidence: f32,
4307
4308 /// A list of word-specific information for each recognized word.
4309 /// When the
4310 /// [SpeakerDiarizationConfig][google.cloud.speech.v2.SpeakerDiarizationConfig]
4311 /// is set, you will see all the words from the beginning of the audio.
4312 ///
4313 /// [google.cloud.speech.v2.SpeakerDiarizationConfig]: crate::model::SpeakerDiarizationConfig
4314 pub words: std::vec::Vec<crate::model::WordInfo>,
4315
4316 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4317}
4318
4319impl SpeechRecognitionAlternative {
4320 /// Creates a new default instance.
4321 pub fn new() -> Self {
4322 std::default::Default::default()
4323 }
4324
4325 /// Sets the value of [transcript][crate::model::SpeechRecognitionAlternative::transcript].
4326 ///
4327 /// # Example
4328 /// ```ignore,no_run
4329 /// # use google_cloud_speech_v2::model::SpeechRecognitionAlternative;
4330 /// let x = SpeechRecognitionAlternative::new().set_transcript("example");
4331 /// ```
4332 pub fn set_transcript<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4333 self.transcript = v.into();
4334 self
4335 }
4336
4337 /// Sets the value of [confidence][crate::model::SpeechRecognitionAlternative::confidence].
4338 ///
4339 /// # Example
4340 /// ```ignore,no_run
4341 /// # use google_cloud_speech_v2::model::SpeechRecognitionAlternative;
4342 /// let x = SpeechRecognitionAlternative::new().set_confidence(42.0);
4343 /// ```
4344 pub fn set_confidence<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
4345 self.confidence = v.into();
4346 self
4347 }
4348
4349 /// Sets the value of [words][crate::model::SpeechRecognitionAlternative::words].
4350 ///
4351 /// # Example
4352 /// ```ignore,no_run
4353 /// # use google_cloud_speech_v2::model::SpeechRecognitionAlternative;
4354 /// use google_cloud_speech_v2::model::WordInfo;
4355 /// let x = SpeechRecognitionAlternative::new()
4356 /// .set_words([
4357 /// WordInfo::default()/* use setters */,
4358 /// WordInfo::default()/* use (different) setters */,
4359 /// ]);
4360 /// ```
4361 pub fn set_words<T, V>(mut self, v: T) -> Self
4362 where
4363 T: std::iter::IntoIterator<Item = V>,
4364 V: std::convert::Into<crate::model::WordInfo>,
4365 {
4366 use std::iter::Iterator;
4367 self.words = v.into_iter().map(|i| i.into()).collect();
4368 self
4369 }
4370}
4371
4372impl wkt::message::Message for SpeechRecognitionAlternative {
4373 fn typename() -> &'static str {
4374 "type.googleapis.com/google.cloud.speech.v2.SpeechRecognitionAlternative"
4375 }
4376}
4377
4378/// Word-specific information for recognized words.
4379#[derive(Clone, Default, PartialEq)]
4380#[non_exhaustive]
4381pub struct WordInfo {
4382 /// Time offset relative to the beginning of the audio,
4383 /// and corresponding to the start of the spoken word.
4384 /// This field is only set if
4385 /// [enable_word_time_offsets][google.cloud.speech.v2.RecognitionFeatures.enable_word_time_offsets]
4386 /// is `true` and only in the top hypothesis. This is an experimental feature
4387 /// and the accuracy of the time offset can vary.
4388 ///
4389 /// [google.cloud.speech.v2.RecognitionFeatures.enable_word_time_offsets]: crate::model::RecognitionFeatures::enable_word_time_offsets
4390 pub start_offset: std::option::Option<wkt::Duration>,
4391
4392 /// Time offset relative to the beginning of the audio,
4393 /// and corresponding to the end of the spoken word.
4394 /// This field is only set if
4395 /// [enable_word_time_offsets][google.cloud.speech.v2.RecognitionFeatures.enable_word_time_offsets]
4396 /// is `true` and only in the top hypothesis. This is an experimental feature
4397 /// and the accuracy of the time offset can vary.
4398 ///
4399 /// [google.cloud.speech.v2.RecognitionFeatures.enable_word_time_offsets]: crate::model::RecognitionFeatures::enable_word_time_offsets
4400 pub end_offset: std::option::Option<wkt::Duration>,
4401
4402 /// The word corresponding to this set of information.
4403 pub word: std::string::String,
4404
4405 /// The confidence estimate between 0.0 and 1.0. A higher number
4406 /// indicates an estimated greater likelihood that the recognized words are
4407 /// correct. This field is set only for the top alternative of a non-streaming
4408 /// result or, of a streaming result where
4409 /// [is_final][google.cloud.speech.v2.StreamingRecognitionResult.is_final] is
4410 /// set to `true`. This field is not guaranteed to be accurate and users should
4411 /// not rely on it to be always provided. The default of 0.0 is a sentinel
4412 /// value indicating `confidence` was not set.
4413 ///
4414 /// [google.cloud.speech.v2.StreamingRecognitionResult.is_final]: crate::model::StreamingRecognitionResult::is_final
4415 pub confidence: f32,
4416
4417 /// A distinct label is assigned for every speaker within the audio. This field
4418 /// specifies which one of those speakers was detected to have spoken this
4419 /// word. `speaker_label` is set if
4420 /// [SpeakerDiarizationConfig][google.cloud.speech.v2.SpeakerDiarizationConfig]
4421 /// is given and only in the top alternative.
4422 ///
4423 /// [google.cloud.speech.v2.SpeakerDiarizationConfig]: crate::model::SpeakerDiarizationConfig
4424 pub speaker_label: std::string::String,
4425
4426 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4427}
4428
4429impl WordInfo {
4430 /// Creates a new default instance.
4431 pub fn new() -> Self {
4432 std::default::Default::default()
4433 }
4434
4435 /// Sets the value of [start_offset][crate::model::WordInfo::start_offset].
4436 ///
4437 /// # Example
4438 /// ```ignore,no_run
4439 /// # use google_cloud_speech_v2::model::WordInfo;
4440 /// use wkt::Duration;
4441 /// let x = WordInfo::new().set_start_offset(Duration::default()/* use setters */);
4442 /// ```
4443 pub fn set_start_offset<T>(mut self, v: T) -> Self
4444 where
4445 T: std::convert::Into<wkt::Duration>,
4446 {
4447 self.start_offset = std::option::Option::Some(v.into());
4448 self
4449 }
4450
4451 /// Sets or clears the value of [start_offset][crate::model::WordInfo::start_offset].
4452 ///
4453 /// # Example
4454 /// ```ignore,no_run
4455 /// # use google_cloud_speech_v2::model::WordInfo;
4456 /// use wkt::Duration;
4457 /// let x = WordInfo::new().set_or_clear_start_offset(Some(Duration::default()/* use setters */));
4458 /// let x = WordInfo::new().set_or_clear_start_offset(None::<Duration>);
4459 /// ```
4460 pub fn set_or_clear_start_offset<T>(mut self, v: std::option::Option<T>) -> Self
4461 where
4462 T: std::convert::Into<wkt::Duration>,
4463 {
4464 self.start_offset = v.map(|x| x.into());
4465 self
4466 }
4467
4468 /// Sets the value of [end_offset][crate::model::WordInfo::end_offset].
4469 ///
4470 /// # Example
4471 /// ```ignore,no_run
4472 /// # use google_cloud_speech_v2::model::WordInfo;
4473 /// use wkt::Duration;
4474 /// let x = WordInfo::new().set_end_offset(Duration::default()/* use setters */);
4475 /// ```
4476 pub fn set_end_offset<T>(mut self, v: T) -> Self
4477 where
4478 T: std::convert::Into<wkt::Duration>,
4479 {
4480 self.end_offset = std::option::Option::Some(v.into());
4481 self
4482 }
4483
4484 /// Sets or clears the value of [end_offset][crate::model::WordInfo::end_offset].
4485 ///
4486 /// # Example
4487 /// ```ignore,no_run
4488 /// # use google_cloud_speech_v2::model::WordInfo;
4489 /// use wkt::Duration;
4490 /// let x = WordInfo::new().set_or_clear_end_offset(Some(Duration::default()/* use setters */));
4491 /// let x = WordInfo::new().set_or_clear_end_offset(None::<Duration>);
4492 /// ```
4493 pub fn set_or_clear_end_offset<T>(mut self, v: std::option::Option<T>) -> Self
4494 where
4495 T: std::convert::Into<wkt::Duration>,
4496 {
4497 self.end_offset = v.map(|x| x.into());
4498 self
4499 }
4500
4501 /// Sets the value of [word][crate::model::WordInfo::word].
4502 ///
4503 /// # Example
4504 /// ```ignore,no_run
4505 /// # use google_cloud_speech_v2::model::WordInfo;
4506 /// let x = WordInfo::new().set_word("example");
4507 /// ```
4508 pub fn set_word<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4509 self.word = v.into();
4510 self
4511 }
4512
4513 /// Sets the value of [confidence][crate::model::WordInfo::confidence].
4514 ///
4515 /// # Example
4516 /// ```ignore,no_run
4517 /// # use google_cloud_speech_v2::model::WordInfo;
4518 /// let x = WordInfo::new().set_confidence(42.0);
4519 /// ```
4520 pub fn set_confidence<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
4521 self.confidence = v.into();
4522 self
4523 }
4524
4525 /// Sets the value of [speaker_label][crate::model::WordInfo::speaker_label].
4526 ///
4527 /// # Example
4528 /// ```ignore,no_run
4529 /// # use google_cloud_speech_v2::model::WordInfo;
4530 /// let x = WordInfo::new().set_speaker_label("example");
4531 /// ```
4532 pub fn set_speaker_label<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4533 self.speaker_label = v.into();
4534 self
4535 }
4536}
4537
4538impl wkt::message::Message for WordInfo {
4539 fn typename() -> &'static str {
4540 "type.googleapis.com/google.cloud.speech.v2.WordInfo"
4541 }
4542}
4543
4544/// A speech recognition result corresponding to a portion of the audio.
4545#[derive(Clone, Default, PartialEq)]
4546#[non_exhaustive]
4547pub struct SpeechRecognitionResult {
4548 /// May contain one or more recognition hypotheses. These alternatives are
4549 /// ordered in terms of accuracy, with the top (first) alternative being the
4550 /// most probable, as ranked by the recognizer.
4551 pub alternatives: std::vec::Vec<crate::model::SpeechRecognitionAlternative>,
4552
4553 /// For multi-channel audio, this is the channel number corresponding to the
4554 /// recognized result for the audio from that channel.
4555 /// For `audio_channel_count` = `N`, its output values can range from `1` to
4556 /// `N`.
4557 pub channel_tag: i32,
4558
4559 /// Time offset of the end of this result relative to the beginning of the
4560 /// audio.
4561 pub result_end_offset: std::option::Option<wkt::Duration>,
4562
4563 /// Output only. The [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt)
4564 /// language tag of the language in this result. This language code was
4565 /// detected to have the most likelihood of being spoken in the audio.
4566 pub language_code: std::string::String,
4567
4568 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4569}
4570
4571impl SpeechRecognitionResult {
4572 /// Creates a new default instance.
4573 pub fn new() -> Self {
4574 std::default::Default::default()
4575 }
4576
4577 /// Sets the value of [alternatives][crate::model::SpeechRecognitionResult::alternatives].
4578 ///
4579 /// # Example
4580 /// ```ignore,no_run
4581 /// # use google_cloud_speech_v2::model::SpeechRecognitionResult;
4582 /// use google_cloud_speech_v2::model::SpeechRecognitionAlternative;
4583 /// let x = SpeechRecognitionResult::new()
4584 /// .set_alternatives([
4585 /// SpeechRecognitionAlternative::default()/* use setters */,
4586 /// SpeechRecognitionAlternative::default()/* use (different) setters */,
4587 /// ]);
4588 /// ```
4589 pub fn set_alternatives<T, V>(mut self, v: T) -> Self
4590 where
4591 T: std::iter::IntoIterator<Item = V>,
4592 V: std::convert::Into<crate::model::SpeechRecognitionAlternative>,
4593 {
4594 use std::iter::Iterator;
4595 self.alternatives = v.into_iter().map(|i| i.into()).collect();
4596 self
4597 }
4598
4599 /// Sets the value of [channel_tag][crate::model::SpeechRecognitionResult::channel_tag].
4600 ///
4601 /// # Example
4602 /// ```ignore,no_run
4603 /// # use google_cloud_speech_v2::model::SpeechRecognitionResult;
4604 /// let x = SpeechRecognitionResult::new().set_channel_tag(42);
4605 /// ```
4606 pub fn set_channel_tag<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
4607 self.channel_tag = v.into();
4608 self
4609 }
4610
4611 /// Sets the value of [result_end_offset][crate::model::SpeechRecognitionResult::result_end_offset].
4612 ///
4613 /// # Example
4614 /// ```ignore,no_run
4615 /// # use google_cloud_speech_v2::model::SpeechRecognitionResult;
4616 /// use wkt::Duration;
4617 /// let x = SpeechRecognitionResult::new().set_result_end_offset(Duration::default()/* use setters */);
4618 /// ```
4619 pub fn set_result_end_offset<T>(mut self, v: T) -> Self
4620 where
4621 T: std::convert::Into<wkt::Duration>,
4622 {
4623 self.result_end_offset = std::option::Option::Some(v.into());
4624 self
4625 }
4626
4627 /// Sets or clears the value of [result_end_offset][crate::model::SpeechRecognitionResult::result_end_offset].
4628 ///
4629 /// # Example
4630 /// ```ignore,no_run
4631 /// # use google_cloud_speech_v2::model::SpeechRecognitionResult;
4632 /// use wkt::Duration;
4633 /// let x = SpeechRecognitionResult::new().set_or_clear_result_end_offset(Some(Duration::default()/* use setters */));
4634 /// let x = SpeechRecognitionResult::new().set_or_clear_result_end_offset(None::<Duration>);
4635 /// ```
4636 pub fn set_or_clear_result_end_offset<T>(mut self, v: std::option::Option<T>) -> Self
4637 where
4638 T: std::convert::Into<wkt::Duration>,
4639 {
4640 self.result_end_offset = v.map(|x| x.into());
4641 self
4642 }
4643
4644 /// Sets the value of [language_code][crate::model::SpeechRecognitionResult::language_code].
4645 ///
4646 /// # Example
4647 /// ```ignore,no_run
4648 /// # use google_cloud_speech_v2::model::SpeechRecognitionResult;
4649 /// let x = SpeechRecognitionResult::new().set_language_code("example");
4650 /// ```
4651 pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4652 self.language_code = v.into();
4653 self
4654 }
4655}
4656
4657impl wkt::message::Message for SpeechRecognitionResult {
4658 fn typename() -> &'static str {
4659 "type.googleapis.com/google.cloud.speech.v2.SpeechRecognitionResult"
4660 }
4661}
4662
4663/// Response message for the
4664/// [Recognize][google.cloud.speech.v2.Speech.Recognize] method.
4665///
4666/// [google.cloud.speech.v2.Speech.Recognize]: crate::client::Speech::recognize
4667#[derive(Clone, Default, PartialEq)]
4668#[non_exhaustive]
4669pub struct RecognizeResponse {
4670 /// Sequential list of transcription results corresponding to sequential
4671 /// portions of audio.
4672 pub results: std::vec::Vec<crate::model::SpeechRecognitionResult>,
4673
4674 /// Metadata about the recognition.
4675 pub metadata: std::option::Option<crate::model::RecognitionResponseMetadata>,
4676
4677 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4678}
4679
4680impl RecognizeResponse {
4681 /// Creates a new default instance.
4682 pub fn new() -> Self {
4683 std::default::Default::default()
4684 }
4685
4686 /// Sets the value of [results][crate::model::RecognizeResponse::results].
4687 ///
4688 /// # Example
4689 /// ```ignore,no_run
4690 /// # use google_cloud_speech_v2::model::RecognizeResponse;
4691 /// use google_cloud_speech_v2::model::SpeechRecognitionResult;
4692 /// let x = RecognizeResponse::new()
4693 /// .set_results([
4694 /// SpeechRecognitionResult::default()/* use setters */,
4695 /// SpeechRecognitionResult::default()/* use (different) setters */,
4696 /// ]);
4697 /// ```
4698 pub fn set_results<T, V>(mut self, v: T) -> Self
4699 where
4700 T: std::iter::IntoIterator<Item = V>,
4701 V: std::convert::Into<crate::model::SpeechRecognitionResult>,
4702 {
4703 use std::iter::Iterator;
4704 self.results = v.into_iter().map(|i| i.into()).collect();
4705 self
4706 }
4707
4708 /// Sets the value of [metadata][crate::model::RecognizeResponse::metadata].
4709 ///
4710 /// # Example
4711 /// ```ignore,no_run
4712 /// # use google_cloud_speech_v2::model::RecognizeResponse;
4713 /// use google_cloud_speech_v2::model::RecognitionResponseMetadata;
4714 /// let x = RecognizeResponse::new().set_metadata(RecognitionResponseMetadata::default()/* use setters */);
4715 /// ```
4716 pub fn set_metadata<T>(mut self, v: T) -> Self
4717 where
4718 T: std::convert::Into<crate::model::RecognitionResponseMetadata>,
4719 {
4720 self.metadata = std::option::Option::Some(v.into());
4721 self
4722 }
4723
4724 /// Sets or clears the value of [metadata][crate::model::RecognizeResponse::metadata].
4725 ///
4726 /// # Example
4727 /// ```ignore,no_run
4728 /// # use google_cloud_speech_v2::model::RecognizeResponse;
4729 /// use google_cloud_speech_v2::model::RecognitionResponseMetadata;
4730 /// let x = RecognizeResponse::new().set_or_clear_metadata(Some(RecognitionResponseMetadata::default()/* use setters */));
4731 /// let x = RecognizeResponse::new().set_or_clear_metadata(None::<RecognitionResponseMetadata>);
4732 /// ```
4733 pub fn set_or_clear_metadata<T>(mut self, v: std::option::Option<T>) -> Self
4734 where
4735 T: std::convert::Into<crate::model::RecognitionResponseMetadata>,
4736 {
4737 self.metadata = v.map(|x| x.into());
4738 self
4739 }
4740}
4741
4742impl wkt::message::Message for RecognizeResponse {
4743 fn typename() -> &'static str {
4744 "type.googleapis.com/google.cloud.speech.v2.RecognizeResponse"
4745 }
4746}
4747
4748/// Available recognition features specific to streaming recognition requests.
4749#[derive(Clone, Default, PartialEq)]
4750#[non_exhaustive]
4751pub struct StreamingRecognitionFeatures {
4752 /// If `true`, responses with voice activity speech events will be returned as
4753 /// they are detected.
4754 pub enable_voice_activity_events: bool,
4755
4756 /// Whether or not to stream interim results to the client. If set to true,
4757 /// interim results will be streamed to the client. Otherwise, only the final
4758 /// response will be streamed back.
4759 pub interim_results: bool,
4760
4761 /// If set, the server will automatically close the stream after the specified
4762 /// duration has elapsed after the last VOICE_ACTIVITY speech event has been
4763 /// sent. The field `voice_activity_events` must also be set to true.
4764 pub voice_activity_timeout:
4765 std::option::Option<crate::model::streaming_recognition_features::VoiceActivityTimeout>,
4766
4767 /// Optional. Endpointing sensitivity for this stream.
4768 pub endpointing_sensitivity:
4769 crate::model::streaming_recognition_features::EndpointingSensitivity,
4770
4771 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4772}
4773
4774impl StreamingRecognitionFeatures {
4775 /// Creates a new default instance.
4776 pub fn new() -> Self {
4777 std::default::Default::default()
4778 }
4779
4780 /// Sets the value of [enable_voice_activity_events][crate::model::StreamingRecognitionFeatures::enable_voice_activity_events].
4781 ///
4782 /// # Example
4783 /// ```ignore,no_run
4784 /// # use google_cloud_speech_v2::model::StreamingRecognitionFeatures;
4785 /// let x = StreamingRecognitionFeatures::new().set_enable_voice_activity_events(true);
4786 /// ```
4787 pub fn set_enable_voice_activity_events<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4788 self.enable_voice_activity_events = v.into();
4789 self
4790 }
4791
4792 /// Sets the value of [interim_results][crate::model::StreamingRecognitionFeatures::interim_results].
4793 ///
4794 /// # Example
4795 /// ```ignore,no_run
4796 /// # use google_cloud_speech_v2::model::StreamingRecognitionFeatures;
4797 /// let x = StreamingRecognitionFeatures::new().set_interim_results(true);
4798 /// ```
4799 pub fn set_interim_results<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4800 self.interim_results = v.into();
4801 self
4802 }
4803
4804 /// Sets the value of [voice_activity_timeout][crate::model::StreamingRecognitionFeatures::voice_activity_timeout].
4805 ///
4806 /// # Example
4807 /// ```ignore,no_run
4808 /// # use google_cloud_speech_v2::model::StreamingRecognitionFeatures;
4809 /// use google_cloud_speech_v2::model::streaming_recognition_features::VoiceActivityTimeout;
4810 /// let x = StreamingRecognitionFeatures::new().set_voice_activity_timeout(VoiceActivityTimeout::default()/* use setters */);
4811 /// ```
4812 pub fn set_voice_activity_timeout<T>(mut self, v: T) -> Self
4813 where
4814 T: std::convert::Into<crate::model::streaming_recognition_features::VoiceActivityTimeout>,
4815 {
4816 self.voice_activity_timeout = std::option::Option::Some(v.into());
4817 self
4818 }
4819
4820 /// Sets or clears the value of [voice_activity_timeout][crate::model::StreamingRecognitionFeatures::voice_activity_timeout].
4821 ///
4822 /// # Example
4823 /// ```ignore,no_run
4824 /// # use google_cloud_speech_v2::model::StreamingRecognitionFeatures;
4825 /// use google_cloud_speech_v2::model::streaming_recognition_features::VoiceActivityTimeout;
4826 /// let x = StreamingRecognitionFeatures::new().set_or_clear_voice_activity_timeout(Some(VoiceActivityTimeout::default()/* use setters */));
4827 /// let x = StreamingRecognitionFeatures::new().set_or_clear_voice_activity_timeout(None::<VoiceActivityTimeout>);
4828 /// ```
4829 pub fn set_or_clear_voice_activity_timeout<T>(mut self, v: std::option::Option<T>) -> Self
4830 where
4831 T: std::convert::Into<crate::model::streaming_recognition_features::VoiceActivityTimeout>,
4832 {
4833 self.voice_activity_timeout = v.map(|x| x.into());
4834 self
4835 }
4836
4837 /// Sets the value of [endpointing_sensitivity][crate::model::StreamingRecognitionFeatures::endpointing_sensitivity].
4838 ///
4839 /// # Example
4840 /// ```ignore,no_run
4841 /// # use google_cloud_speech_v2::model::StreamingRecognitionFeatures;
4842 /// use google_cloud_speech_v2::model::streaming_recognition_features::EndpointingSensitivity;
4843 /// let x0 = StreamingRecognitionFeatures::new().set_endpointing_sensitivity(EndpointingSensitivity::Standard);
4844 /// let x1 = StreamingRecognitionFeatures::new().set_endpointing_sensitivity(EndpointingSensitivity::Supershort);
4845 /// let x2 = StreamingRecognitionFeatures::new().set_endpointing_sensitivity(EndpointingSensitivity::Short);
4846 /// ```
4847 pub fn set_endpointing_sensitivity<
4848 T: std::convert::Into<crate::model::streaming_recognition_features::EndpointingSensitivity>,
4849 >(
4850 mut self,
4851 v: T,
4852 ) -> Self {
4853 self.endpointing_sensitivity = v.into();
4854 self
4855 }
4856}
4857
4858impl wkt::message::Message for StreamingRecognitionFeatures {
4859 fn typename() -> &'static str {
4860 "type.googleapis.com/google.cloud.speech.v2.StreamingRecognitionFeatures"
4861 }
4862}
4863
4864/// Defines additional types related to [StreamingRecognitionFeatures].
4865pub mod streaming_recognition_features {
4866 #[allow(unused_imports)]
4867 use super::*;
4868
4869 /// Events that a timeout can be set on for voice activity.
4870 #[derive(Clone, Default, PartialEq)]
4871 #[non_exhaustive]
4872 pub struct VoiceActivityTimeout {
4873 /// Duration to timeout the stream if no speech begins. If this is set and
4874 /// no speech is detected in this duration at the start of the stream, the
4875 /// server will close the stream.
4876 pub speech_start_timeout: std::option::Option<wkt::Duration>,
4877
4878 /// Duration to timeout the stream after speech ends. If this is set and no
4879 /// speech is detected in this duration after speech was detected, the server
4880 /// will close the stream.
4881 pub speech_end_timeout: std::option::Option<wkt::Duration>,
4882
4883 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4884 }
4885
4886 impl VoiceActivityTimeout {
4887 /// Creates a new default instance.
4888 pub fn new() -> Self {
4889 std::default::Default::default()
4890 }
4891
4892 /// Sets the value of [speech_start_timeout][crate::model::streaming_recognition_features::VoiceActivityTimeout::speech_start_timeout].
4893 ///
4894 /// # Example
4895 /// ```ignore,no_run
4896 /// # use google_cloud_speech_v2::model::streaming_recognition_features::VoiceActivityTimeout;
4897 /// use wkt::Duration;
4898 /// let x = VoiceActivityTimeout::new().set_speech_start_timeout(Duration::default()/* use setters */);
4899 /// ```
4900 pub fn set_speech_start_timeout<T>(mut self, v: T) -> Self
4901 where
4902 T: std::convert::Into<wkt::Duration>,
4903 {
4904 self.speech_start_timeout = std::option::Option::Some(v.into());
4905 self
4906 }
4907
4908 /// Sets or clears the value of [speech_start_timeout][crate::model::streaming_recognition_features::VoiceActivityTimeout::speech_start_timeout].
4909 ///
4910 /// # Example
4911 /// ```ignore,no_run
4912 /// # use google_cloud_speech_v2::model::streaming_recognition_features::VoiceActivityTimeout;
4913 /// use wkt::Duration;
4914 /// let x = VoiceActivityTimeout::new().set_or_clear_speech_start_timeout(Some(Duration::default()/* use setters */));
4915 /// let x = VoiceActivityTimeout::new().set_or_clear_speech_start_timeout(None::<Duration>);
4916 /// ```
4917 pub fn set_or_clear_speech_start_timeout<T>(mut self, v: std::option::Option<T>) -> Self
4918 where
4919 T: std::convert::Into<wkt::Duration>,
4920 {
4921 self.speech_start_timeout = v.map(|x| x.into());
4922 self
4923 }
4924
4925 /// Sets the value of [speech_end_timeout][crate::model::streaming_recognition_features::VoiceActivityTimeout::speech_end_timeout].
4926 ///
4927 /// # Example
4928 /// ```ignore,no_run
4929 /// # use google_cloud_speech_v2::model::streaming_recognition_features::VoiceActivityTimeout;
4930 /// use wkt::Duration;
4931 /// let x = VoiceActivityTimeout::new().set_speech_end_timeout(Duration::default()/* use setters */);
4932 /// ```
4933 pub fn set_speech_end_timeout<T>(mut self, v: T) -> Self
4934 where
4935 T: std::convert::Into<wkt::Duration>,
4936 {
4937 self.speech_end_timeout = std::option::Option::Some(v.into());
4938 self
4939 }
4940
4941 /// Sets or clears the value of [speech_end_timeout][crate::model::streaming_recognition_features::VoiceActivityTimeout::speech_end_timeout].
4942 ///
4943 /// # Example
4944 /// ```ignore,no_run
4945 /// # use google_cloud_speech_v2::model::streaming_recognition_features::VoiceActivityTimeout;
4946 /// use wkt::Duration;
4947 /// let x = VoiceActivityTimeout::new().set_or_clear_speech_end_timeout(Some(Duration::default()/* use setters */));
4948 /// let x = VoiceActivityTimeout::new().set_or_clear_speech_end_timeout(None::<Duration>);
4949 /// ```
4950 pub fn set_or_clear_speech_end_timeout<T>(mut self, v: std::option::Option<T>) -> Self
4951 where
4952 T: std::convert::Into<wkt::Duration>,
4953 {
4954 self.speech_end_timeout = v.map(|x| x.into());
4955 self
4956 }
4957 }
4958
4959 impl wkt::message::Message for VoiceActivityTimeout {
4960 fn typename() -> &'static str {
4961 "type.googleapis.com/google.cloud.speech.v2.StreamingRecognitionFeatures.VoiceActivityTimeout"
4962 }
4963 }
4964
4965 /// Endpointing sensitivity is intended for applications that want to minimize
4966 /// result latency, possibly at the expense of quality. Some utterances may be
4967 /// broken up into multiple fragments.
4968 ///
4969 /// # Working with unknown values
4970 ///
4971 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
4972 /// additional enum variants at any time. Adding new variants is not considered
4973 /// a breaking change. Applications should write their code in anticipation of:
4974 ///
4975 /// - New values appearing in future releases of the client library, **and**
4976 /// - New values received dynamically, without application changes.
4977 ///
4978 /// Please consult the [Working with enums] section in the user guide for some
4979 /// guidelines.
4980 ///
4981 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
4982 #[derive(Clone, Debug, PartialEq)]
4983 #[non_exhaustive]
4984 pub enum EndpointingSensitivity {
4985 /// If no value is specified, the values for
4986 /// ENDPOINTING_SENSITIVITY_STANDARD will be used.
4987 Unspecified,
4988 /// Standard sensitivity, no optimization for latency.
4989 Standard,
4990 /// Super short sensitivity, optimized for super short utterances like single
4991 /// words ("Yes", "No", "Hello", etc.) or a single phrase, command or short
4992 /// query (e.g. "check balance", "five dollars", "call Mom").
4993 Supershort,
4994 /// Short sensitivity, optimized for short utterances like single sentences.
4995 /// (e.g. "Remind me to call the dentist tomorrow morning at nine",
4996 /// "Navigate to the nearest coffee shop that is currently open")
4997 Short,
4998 /// If set, the enum was initialized with an unknown value.
4999 ///
5000 /// Applications can examine the value using [EndpointingSensitivity::value] or
5001 /// [EndpointingSensitivity::name].
5002 UnknownValue(endpointing_sensitivity::UnknownValue),
5003 }
5004
5005 #[doc(hidden)]
5006 pub mod endpointing_sensitivity {
5007 #[allow(unused_imports)]
5008 use super::*;
5009 #[derive(Clone, Debug, PartialEq)]
5010 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
5011 }
5012
5013 impl EndpointingSensitivity {
5014 /// Gets the enum value.
5015 ///
5016 /// Returns `None` if the enum contains an unknown value deserialized from
5017 /// the string representation of enums.
5018 pub fn value(&self) -> std::option::Option<i32> {
5019 match self {
5020 Self::Unspecified => std::option::Option::Some(0),
5021 Self::Standard => std::option::Option::Some(1),
5022 Self::Supershort => std::option::Option::Some(2),
5023 Self::Short => std::option::Option::Some(3),
5024 Self::UnknownValue(u) => u.0.value(),
5025 }
5026 }
5027
5028 /// Gets the enum value as a string.
5029 ///
5030 /// Returns `None` if the enum contains an unknown value deserialized from
5031 /// the integer representation of enums.
5032 pub fn name(&self) -> std::option::Option<&str> {
5033 match self {
5034 Self::Unspecified => {
5035 std::option::Option::Some("ENDPOINTING_SENSITIVITY_UNSPECIFIED")
5036 }
5037 Self::Standard => std::option::Option::Some("ENDPOINTING_SENSITIVITY_STANDARD"),
5038 Self::Supershort => std::option::Option::Some("ENDPOINTING_SENSITIVITY_SUPERSHORT"),
5039 Self::Short => std::option::Option::Some("ENDPOINTING_SENSITIVITY_SHORT"),
5040 Self::UnknownValue(u) => u.0.name(),
5041 }
5042 }
5043 }
5044
5045 impl std::default::Default for EndpointingSensitivity {
5046 fn default() -> Self {
5047 use std::convert::From;
5048 Self::from(0)
5049 }
5050 }
5051
5052 impl std::fmt::Display for EndpointingSensitivity {
5053 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
5054 wkt::internal::display_enum(f, self.name(), self.value())
5055 }
5056 }
5057
5058 impl std::convert::From<i32> for EndpointingSensitivity {
5059 fn from(value: i32) -> Self {
5060 match value {
5061 0 => Self::Unspecified,
5062 1 => Self::Standard,
5063 2 => Self::Supershort,
5064 3 => Self::Short,
5065 _ => Self::UnknownValue(endpointing_sensitivity::UnknownValue(
5066 wkt::internal::UnknownEnumValue::Integer(value),
5067 )),
5068 }
5069 }
5070 }
5071
5072 impl std::convert::From<&str> for EndpointingSensitivity {
5073 fn from(value: &str) -> Self {
5074 use std::string::ToString;
5075 match value {
5076 "ENDPOINTING_SENSITIVITY_UNSPECIFIED" => Self::Unspecified,
5077 "ENDPOINTING_SENSITIVITY_STANDARD" => Self::Standard,
5078 "ENDPOINTING_SENSITIVITY_SUPERSHORT" => Self::Supershort,
5079 "ENDPOINTING_SENSITIVITY_SHORT" => Self::Short,
5080 _ => Self::UnknownValue(endpointing_sensitivity::UnknownValue(
5081 wkt::internal::UnknownEnumValue::String(value.to_string()),
5082 )),
5083 }
5084 }
5085 }
5086
5087 impl serde::ser::Serialize for EndpointingSensitivity {
5088 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5089 where
5090 S: serde::Serializer,
5091 {
5092 match self {
5093 Self::Unspecified => serializer.serialize_i32(0),
5094 Self::Standard => serializer.serialize_i32(1),
5095 Self::Supershort => serializer.serialize_i32(2),
5096 Self::Short => serializer.serialize_i32(3),
5097 Self::UnknownValue(u) => u.0.serialize(serializer),
5098 }
5099 }
5100 }
5101
5102 impl<'de> serde::de::Deserialize<'de> for EndpointingSensitivity {
5103 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5104 where
5105 D: serde::Deserializer<'de>,
5106 {
5107 deserializer.deserialize_any(wkt::internal::EnumVisitor::<EndpointingSensitivity>::new(
5108 ".google.cloud.speech.v2.StreamingRecognitionFeatures.EndpointingSensitivity",
5109 ))
5110 }
5111 }
5112}
5113
5114/// Provides configuration information for the StreamingRecognize request.
5115#[derive(Clone, Default, PartialEq)]
5116#[non_exhaustive]
5117pub struct StreamingRecognitionConfig {
5118 /// Required. Features and audio metadata to use for the Automatic Speech
5119 /// Recognition. This field in combination with the
5120 /// [config_mask][google.cloud.speech.v2.StreamingRecognitionConfig.config_mask]
5121 /// field can be used to override parts of the
5122 /// [default_recognition_config][google.cloud.speech.v2.Recognizer.default_recognition_config]
5123 /// of the Recognizer resource.
5124 ///
5125 /// [google.cloud.speech.v2.Recognizer.default_recognition_config]: crate::model::Recognizer::default_recognition_config
5126 /// [google.cloud.speech.v2.StreamingRecognitionConfig.config_mask]: crate::model::StreamingRecognitionConfig::config_mask
5127 pub config: std::option::Option<crate::model::RecognitionConfig>,
5128
5129 /// The list of fields in
5130 /// [config][google.cloud.speech.v2.StreamingRecognitionConfig.config] that
5131 /// override the values in the
5132 /// [default_recognition_config][google.cloud.speech.v2.Recognizer.default_recognition_config]
5133 /// of the recognizer during this recognition request. If no mask is provided,
5134 /// all non-default valued fields in
5135 /// [config][google.cloud.speech.v2.StreamingRecognitionConfig.config] override
5136 /// the values in the Recognizer for this recognition request. If a mask is
5137 /// provided, only the fields listed in the mask override the config in the
5138 /// Recognizer for this recognition request. If a wildcard (`*`) is provided,
5139 /// [config][google.cloud.speech.v2.StreamingRecognitionConfig.config]
5140 /// completely overrides and replaces the config in the recognizer for this
5141 /// recognition request.
5142 ///
5143 /// [google.cloud.speech.v2.Recognizer.default_recognition_config]: crate::model::Recognizer::default_recognition_config
5144 /// [google.cloud.speech.v2.StreamingRecognitionConfig.config]: crate::model::StreamingRecognitionConfig::config
5145 pub config_mask: std::option::Option<wkt::FieldMask>,
5146
5147 /// Speech recognition features to enable specific to streaming audio
5148 /// recognition requests.
5149 pub streaming_features: std::option::Option<crate::model::StreamingRecognitionFeatures>,
5150
5151 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5152}
5153
5154impl StreamingRecognitionConfig {
5155 /// Creates a new default instance.
5156 pub fn new() -> Self {
5157 std::default::Default::default()
5158 }
5159
5160 /// Sets the value of [config][crate::model::StreamingRecognitionConfig::config].
5161 ///
5162 /// # Example
5163 /// ```ignore,no_run
5164 /// # use google_cloud_speech_v2::model::StreamingRecognitionConfig;
5165 /// use google_cloud_speech_v2::model::RecognitionConfig;
5166 /// let x = StreamingRecognitionConfig::new().set_config(RecognitionConfig::default()/* use setters */);
5167 /// ```
5168 pub fn set_config<T>(mut self, v: T) -> Self
5169 where
5170 T: std::convert::Into<crate::model::RecognitionConfig>,
5171 {
5172 self.config = std::option::Option::Some(v.into());
5173 self
5174 }
5175
5176 /// Sets or clears the value of [config][crate::model::StreamingRecognitionConfig::config].
5177 ///
5178 /// # Example
5179 /// ```ignore,no_run
5180 /// # use google_cloud_speech_v2::model::StreamingRecognitionConfig;
5181 /// use google_cloud_speech_v2::model::RecognitionConfig;
5182 /// let x = StreamingRecognitionConfig::new().set_or_clear_config(Some(RecognitionConfig::default()/* use setters */));
5183 /// let x = StreamingRecognitionConfig::new().set_or_clear_config(None::<RecognitionConfig>);
5184 /// ```
5185 pub fn set_or_clear_config<T>(mut self, v: std::option::Option<T>) -> Self
5186 where
5187 T: std::convert::Into<crate::model::RecognitionConfig>,
5188 {
5189 self.config = v.map(|x| x.into());
5190 self
5191 }
5192
5193 /// Sets the value of [config_mask][crate::model::StreamingRecognitionConfig::config_mask].
5194 ///
5195 /// # Example
5196 /// ```ignore,no_run
5197 /// # use google_cloud_speech_v2::model::StreamingRecognitionConfig;
5198 /// use wkt::FieldMask;
5199 /// let x = StreamingRecognitionConfig::new().set_config_mask(FieldMask::default()/* use setters */);
5200 /// ```
5201 pub fn set_config_mask<T>(mut self, v: T) -> Self
5202 where
5203 T: std::convert::Into<wkt::FieldMask>,
5204 {
5205 self.config_mask = std::option::Option::Some(v.into());
5206 self
5207 }
5208
5209 /// Sets or clears the value of [config_mask][crate::model::StreamingRecognitionConfig::config_mask].
5210 ///
5211 /// # Example
5212 /// ```ignore,no_run
5213 /// # use google_cloud_speech_v2::model::StreamingRecognitionConfig;
5214 /// use wkt::FieldMask;
5215 /// let x = StreamingRecognitionConfig::new().set_or_clear_config_mask(Some(FieldMask::default()/* use setters */));
5216 /// let x = StreamingRecognitionConfig::new().set_or_clear_config_mask(None::<FieldMask>);
5217 /// ```
5218 pub fn set_or_clear_config_mask<T>(mut self, v: std::option::Option<T>) -> Self
5219 where
5220 T: std::convert::Into<wkt::FieldMask>,
5221 {
5222 self.config_mask = v.map(|x| x.into());
5223 self
5224 }
5225
5226 /// Sets the value of [streaming_features][crate::model::StreamingRecognitionConfig::streaming_features].
5227 ///
5228 /// # Example
5229 /// ```ignore,no_run
5230 /// # use google_cloud_speech_v2::model::StreamingRecognitionConfig;
5231 /// use google_cloud_speech_v2::model::StreamingRecognitionFeatures;
5232 /// let x = StreamingRecognitionConfig::new().set_streaming_features(StreamingRecognitionFeatures::default()/* use setters */);
5233 /// ```
5234 pub fn set_streaming_features<T>(mut self, v: T) -> Self
5235 where
5236 T: std::convert::Into<crate::model::StreamingRecognitionFeatures>,
5237 {
5238 self.streaming_features = std::option::Option::Some(v.into());
5239 self
5240 }
5241
5242 /// Sets or clears the value of [streaming_features][crate::model::StreamingRecognitionConfig::streaming_features].
5243 ///
5244 /// # Example
5245 /// ```ignore,no_run
5246 /// # use google_cloud_speech_v2::model::StreamingRecognitionConfig;
5247 /// use google_cloud_speech_v2::model::StreamingRecognitionFeatures;
5248 /// let x = StreamingRecognitionConfig::new().set_or_clear_streaming_features(Some(StreamingRecognitionFeatures::default()/* use setters */));
5249 /// let x = StreamingRecognitionConfig::new().set_or_clear_streaming_features(None::<StreamingRecognitionFeatures>);
5250 /// ```
5251 pub fn set_or_clear_streaming_features<T>(mut self, v: std::option::Option<T>) -> Self
5252 where
5253 T: std::convert::Into<crate::model::StreamingRecognitionFeatures>,
5254 {
5255 self.streaming_features = v.map(|x| x.into());
5256 self
5257 }
5258}
5259
5260impl wkt::message::Message for StreamingRecognitionConfig {
5261 fn typename() -> &'static str {
5262 "type.googleapis.com/google.cloud.speech.v2.StreamingRecognitionConfig"
5263 }
5264}
5265
5266/// Request message for the
5267/// [StreamingRecognize][google.cloud.speech.v2.Speech.StreamingRecognize]
5268/// method. Multiple
5269/// [StreamingRecognizeRequest][google.cloud.speech.v2.StreamingRecognizeRequest]
5270/// messages are sent in one call.
5271///
5272/// If the [Recognizer][google.cloud.speech.v2.Recognizer] referenced by
5273/// [recognizer][google.cloud.speech.v2.StreamingRecognizeRequest.recognizer]
5274/// contains a fully specified request configuration then the stream may only
5275/// contain messages with only
5276/// [audio][google.cloud.speech.v2.StreamingRecognizeRequest.audio] set.
5277///
5278/// Otherwise the first message must contain a
5279/// [recognizer][google.cloud.speech.v2.StreamingRecognizeRequest.recognizer] and
5280/// a
5281/// [streaming_config][google.cloud.speech.v2.StreamingRecognizeRequest.streaming_config]
5282/// message that together fully specify the request configuration and must not
5283/// contain [audio][google.cloud.speech.v2.StreamingRecognizeRequest.audio]. All
5284/// subsequent messages must only have
5285/// [audio][google.cloud.speech.v2.StreamingRecognizeRequest.audio] set.
5286///
5287/// [google.cloud.speech.v2.Recognizer]: crate::model::Recognizer
5288/// [google.cloud.speech.v2.StreamingRecognizeRequest]: crate::model::StreamingRecognizeRequest
5289/// [google.cloud.speech.v2.StreamingRecognizeRequest.audio]: crate::model::StreamingRecognizeRequest::streaming_request
5290/// [google.cloud.speech.v2.StreamingRecognizeRequest.recognizer]: crate::model::StreamingRecognizeRequest::recognizer
5291/// [google.cloud.speech.v2.StreamingRecognizeRequest.streaming_config]: crate::model::StreamingRecognizeRequest::streaming_request
5292#[derive(Clone, Default, PartialEq)]
5293#[non_exhaustive]
5294pub struct StreamingRecognizeRequest {
5295 /// Required. The name of the Recognizer to use during recognition. The
5296 /// expected format is
5297 /// `projects/{project}/locations/{location}/recognizers/{recognizer}`. The
5298 /// {recognizer} segment may be set to `_` to use an empty implicit Recognizer.
5299 pub recognizer: std::string::String,
5300
5301 #[allow(missing_docs)]
5302 pub streaming_request:
5303 std::option::Option<crate::model::streaming_recognize_request::StreamingRequest>,
5304
5305 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5306}
5307
5308impl StreamingRecognizeRequest {
5309 /// Creates a new default instance.
5310 pub fn new() -> Self {
5311 std::default::Default::default()
5312 }
5313
5314 /// Sets the value of [recognizer][crate::model::StreamingRecognizeRequest::recognizer].
5315 ///
5316 /// # Example
5317 /// ```ignore,no_run
5318 /// # use google_cloud_speech_v2::model::StreamingRecognizeRequest;
5319 /// # let project_id = "project_id";
5320 /// # let location_id = "location_id";
5321 /// # let recognizer_id = "recognizer_id";
5322 /// let x = StreamingRecognizeRequest::new().set_recognizer(format!("projects/{project_id}/locations/{location_id}/recognizers/{recognizer_id}"));
5323 /// ```
5324 pub fn set_recognizer<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5325 self.recognizer = v.into();
5326 self
5327 }
5328
5329 /// Sets the value of [streaming_request][crate::model::StreamingRecognizeRequest::streaming_request].
5330 ///
5331 /// Note that all the setters affecting `streaming_request` are mutually
5332 /// exclusive.
5333 ///
5334 /// # Example
5335 /// ```ignore,no_run
5336 /// # use google_cloud_speech_v2::model::StreamingRecognizeRequest;
5337 /// use google_cloud_speech_v2::model::streaming_recognize_request::StreamingRequest;
5338 /// let x = StreamingRecognizeRequest::new().set_streaming_request(Some(StreamingRequest::Audio(bytes::Bytes::from_static(b"example"))));
5339 /// ```
5340 pub fn set_streaming_request<
5341 T: std::convert::Into<
5342 std::option::Option<crate::model::streaming_recognize_request::StreamingRequest>,
5343 >,
5344 >(
5345 mut self,
5346 v: T,
5347 ) -> Self {
5348 self.streaming_request = v.into();
5349 self
5350 }
5351
5352 /// The value of [streaming_request][crate::model::StreamingRecognizeRequest::streaming_request]
5353 /// if it holds a `StreamingConfig`, `None` if the field is not set or
5354 /// holds a different branch.
5355 pub fn streaming_config(
5356 &self,
5357 ) -> std::option::Option<&std::boxed::Box<crate::model::StreamingRecognitionConfig>> {
5358 #[allow(unreachable_patterns)]
5359 self.streaming_request.as_ref().and_then(|v| match v {
5360 crate::model::streaming_recognize_request::StreamingRequest::StreamingConfig(v) => {
5361 std::option::Option::Some(v)
5362 }
5363 _ => std::option::Option::None,
5364 })
5365 }
5366
5367 /// Sets the value of [streaming_request][crate::model::StreamingRecognizeRequest::streaming_request]
5368 /// to hold a `StreamingConfig`.
5369 ///
5370 /// Note that all the setters affecting `streaming_request` are
5371 /// mutually exclusive.
5372 ///
5373 /// # Example
5374 /// ```ignore,no_run
5375 /// # use google_cloud_speech_v2::model::StreamingRecognizeRequest;
5376 /// use google_cloud_speech_v2::model::StreamingRecognitionConfig;
5377 /// let x = StreamingRecognizeRequest::new().set_streaming_config(StreamingRecognitionConfig::default()/* use setters */);
5378 /// assert!(x.streaming_config().is_some());
5379 /// assert!(x.audio().is_none());
5380 /// ```
5381 pub fn set_streaming_config<
5382 T: std::convert::Into<std::boxed::Box<crate::model::StreamingRecognitionConfig>>,
5383 >(
5384 mut self,
5385 v: T,
5386 ) -> Self {
5387 self.streaming_request = std::option::Option::Some(
5388 crate::model::streaming_recognize_request::StreamingRequest::StreamingConfig(v.into()),
5389 );
5390 self
5391 }
5392
5393 /// The value of [streaming_request][crate::model::StreamingRecognizeRequest::streaming_request]
5394 /// if it holds a `Audio`, `None` if the field is not set or
5395 /// holds a different branch.
5396 pub fn audio(&self) -> std::option::Option<&::bytes::Bytes> {
5397 #[allow(unreachable_patterns)]
5398 self.streaming_request.as_ref().and_then(|v| match v {
5399 crate::model::streaming_recognize_request::StreamingRequest::Audio(v) => {
5400 std::option::Option::Some(v)
5401 }
5402 _ => std::option::Option::None,
5403 })
5404 }
5405
5406 /// Sets the value of [streaming_request][crate::model::StreamingRecognizeRequest::streaming_request]
5407 /// to hold a `Audio`.
5408 ///
5409 /// Note that all the setters affecting `streaming_request` are
5410 /// mutually exclusive.
5411 ///
5412 /// # Example
5413 /// ```ignore,no_run
5414 /// # use google_cloud_speech_v2::model::StreamingRecognizeRequest;
5415 /// let x = StreamingRecognizeRequest::new().set_audio(bytes::Bytes::from_static(b"example"));
5416 /// assert!(x.audio().is_some());
5417 /// assert!(x.streaming_config().is_none());
5418 /// ```
5419 pub fn set_audio<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
5420 self.streaming_request = std::option::Option::Some(
5421 crate::model::streaming_recognize_request::StreamingRequest::Audio(v.into()),
5422 );
5423 self
5424 }
5425}
5426
5427impl wkt::message::Message for StreamingRecognizeRequest {
5428 fn typename() -> &'static str {
5429 "type.googleapis.com/google.cloud.speech.v2.StreamingRecognizeRequest"
5430 }
5431}
5432
5433/// Defines additional types related to [StreamingRecognizeRequest].
5434pub mod streaming_recognize_request {
5435 #[allow(unused_imports)]
5436 use super::*;
5437
5438 #[allow(missing_docs)]
5439 #[derive(Clone, Debug, PartialEq)]
5440 #[non_exhaustive]
5441 pub enum StreamingRequest {
5442 /// StreamingRecognitionConfig to be used in this recognition attempt.
5443 /// If provided, it will override the default RecognitionConfig stored in the
5444 /// Recognizer.
5445 StreamingConfig(std::boxed::Box<crate::model::StreamingRecognitionConfig>),
5446 /// Inline audio bytes to be Recognized.
5447 /// Maximum size for this field is 15 KB per request.
5448 Audio(::bytes::Bytes),
5449 }
5450}
5451
5452/// Request message for the
5453/// [BatchRecognize][google.cloud.speech.v2.Speech.BatchRecognize]
5454/// method.
5455///
5456/// [google.cloud.speech.v2.Speech.BatchRecognize]: crate::client::Speech::batch_recognize
5457#[derive(Clone, Default, PartialEq)]
5458#[non_exhaustive]
5459pub struct BatchRecognizeRequest {
5460 /// Required. The name of the Recognizer to use during recognition. The
5461 /// expected format is
5462 /// `projects/{project}/locations/{location}/recognizers/{recognizer}`. The
5463 /// {recognizer} segment may be set to `_` to use an empty implicit Recognizer.
5464 pub recognizer: std::string::String,
5465
5466 /// Features and audio metadata to use for the Automatic Speech Recognition.
5467 /// This field in combination with the
5468 /// [config_mask][google.cloud.speech.v2.BatchRecognizeRequest.config_mask]
5469 /// field can be used to override parts of the
5470 /// [default_recognition_config][google.cloud.speech.v2.Recognizer.default_recognition_config]
5471 /// of the Recognizer resource.
5472 ///
5473 /// [google.cloud.speech.v2.BatchRecognizeRequest.config_mask]: crate::model::BatchRecognizeRequest::config_mask
5474 /// [google.cloud.speech.v2.Recognizer.default_recognition_config]: crate::model::Recognizer::default_recognition_config
5475 pub config: std::option::Option<crate::model::RecognitionConfig>,
5476
5477 /// The list of fields in
5478 /// [config][google.cloud.speech.v2.BatchRecognizeRequest.config] that override
5479 /// the values in the
5480 /// [default_recognition_config][google.cloud.speech.v2.Recognizer.default_recognition_config]
5481 /// of the recognizer during this recognition request. If no mask is provided,
5482 /// all given fields in
5483 /// [config][google.cloud.speech.v2.BatchRecognizeRequest.config] override the
5484 /// values in the recognizer for this recognition request. If a mask is
5485 /// provided, only the fields listed in the mask override the config in the
5486 /// recognizer for this recognition request. If a wildcard (`*`) is provided,
5487 /// [config][google.cloud.speech.v2.BatchRecognizeRequest.config] completely
5488 /// overrides and replaces the config in the recognizer for this recognition
5489 /// request.
5490 ///
5491 /// [google.cloud.speech.v2.BatchRecognizeRequest.config]: crate::model::BatchRecognizeRequest::config
5492 /// [google.cloud.speech.v2.Recognizer.default_recognition_config]: crate::model::Recognizer::default_recognition_config
5493 pub config_mask: std::option::Option<wkt::FieldMask>,
5494
5495 /// Audio files with file metadata for ASR.
5496 /// The maximum number of files allowed to be specified is 15.
5497 pub files: std::vec::Vec<crate::model::BatchRecognizeFileMetadata>,
5498
5499 /// Configuration options for where to output the transcripts of each file.
5500 pub recognition_output_config: std::option::Option<crate::model::RecognitionOutputConfig>,
5501
5502 /// Processing strategy to use for this request.
5503 pub processing_strategy: crate::model::batch_recognize_request::ProcessingStrategy,
5504
5505 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5506}
5507
5508impl BatchRecognizeRequest {
5509 /// Creates a new default instance.
5510 pub fn new() -> Self {
5511 std::default::Default::default()
5512 }
5513
5514 /// Sets the value of [recognizer][crate::model::BatchRecognizeRequest::recognizer].
5515 ///
5516 /// # Example
5517 /// ```ignore,no_run
5518 /// # use google_cloud_speech_v2::model::BatchRecognizeRequest;
5519 /// # let project_id = "project_id";
5520 /// # let location_id = "location_id";
5521 /// # let recognizer_id = "recognizer_id";
5522 /// let x = BatchRecognizeRequest::new().set_recognizer(format!("projects/{project_id}/locations/{location_id}/recognizers/{recognizer_id}"));
5523 /// ```
5524 pub fn set_recognizer<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5525 self.recognizer = v.into();
5526 self
5527 }
5528
5529 /// Sets the value of [config][crate::model::BatchRecognizeRequest::config].
5530 ///
5531 /// # Example
5532 /// ```ignore,no_run
5533 /// # use google_cloud_speech_v2::model::BatchRecognizeRequest;
5534 /// use google_cloud_speech_v2::model::RecognitionConfig;
5535 /// let x = BatchRecognizeRequest::new().set_config(RecognitionConfig::default()/* use setters */);
5536 /// ```
5537 pub fn set_config<T>(mut self, v: T) -> Self
5538 where
5539 T: std::convert::Into<crate::model::RecognitionConfig>,
5540 {
5541 self.config = std::option::Option::Some(v.into());
5542 self
5543 }
5544
5545 /// Sets or clears the value of [config][crate::model::BatchRecognizeRequest::config].
5546 ///
5547 /// # Example
5548 /// ```ignore,no_run
5549 /// # use google_cloud_speech_v2::model::BatchRecognizeRequest;
5550 /// use google_cloud_speech_v2::model::RecognitionConfig;
5551 /// let x = BatchRecognizeRequest::new().set_or_clear_config(Some(RecognitionConfig::default()/* use setters */));
5552 /// let x = BatchRecognizeRequest::new().set_or_clear_config(None::<RecognitionConfig>);
5553 /// ```
5554 pub fn set_or_clear_config<T>(mut self, v: std::option::Option<T>) -> Self
5555 where
5556 T: std::convert::Into<crate::model::RecognitionConfig>,
5557 {
5558 self.config = v.map(|x| x.into());
5559 self
5560 }
5561
5562 /// Sets the value of [config_mask][crate::model::BatchRecognizeRequest::config_mask].
5563 ///
5564 /// # Example
5565 /// ```ignore,no_run
5566 /// # use google_cloud_speech_v2::model::BatchRecognizeRequest;
5567 /// use wkt::FieldMask;
5568 /// let x = BatchRecognizeRequest::new().set_config_mask(FieldMask::default()/* use setters */);
5569 /// ```
5570 pub fn set_config_mask<T>(mut self, v: T) -> Self
5571 where
5572 T: std::convert::Into<wkt::FieldMask>,
5573 {
5574 self.config_mask = std::option::Option::Some(v.into());
5575 self
5576 }
5577
5578 /// Sets or clears the value of [config_mask][crate::model::BatchRecognizeRequest::config_mask].
5579 ///
5580 /// # Example
5581 /// ```ignore,no_run
5582 /// # use google_cloud_speech_v2::model::BatchRecognizeRequest;
5583 /// use wkt::FieldMask;
5584 /// let x = BatchRecognizeRequest::new().set_or_clear_config_mask(Some(FieldMask::default()/* use setters */));
5585 /// let x = BatchRecognizeRequest::new().set_or_clear_config_mask(None::<FieldMask>);
5586 /// ```
5587 pub fn set_or_clear_config_mask<T>(mut self, v: std::option::Option<T>) -> Self
5588 where
5589 T: std::convert::Into<wkt::FieldMask>,
5590 {
5591 self.config_mask = v.map(|x| x.into());
5592 self
5593 }
5594
5595 /// Sets the value of [files][crate::model::BatchRecognizeRequest::files].
5596 ///
5597 /// # Example
5598 /// ```ignore,no_run
5599 /// # use google_cloud_speech_v2::model::BatchRecognizeRequest;
5600 /// use google_cloud_speech_v2::model::BatchRecognizeFileMetadata;
5601 /// let x = BatchRecognizeRequest::new()
5602 /// .set_files([
5603 /// BatchRecognizeFileMetadata::default()/* use setters */,
5604 /// BatchRecognizeFileMetadata::default()/* use (different) setters */,
5605 /// ]);
5606 /// ```
5607 pub fn set_files<T, V>(mut self, v: T) -> Self
5608 where
5609 T: std::iter::IntoIterator<Item = V>,
5610 V: std::convert::Into<crate::model::BatchRecognizeFileMetadata>,
5611 {
5612 use std::iter::Iterator;
5613 self.files = v.into_iter().map(|i| i.into()).collect();
5614 self
5615 }
5616
5617 /// Sets the value of [recognition_output_config][crate::model::BatchRecognizeRequest::recognition_output_config].
5618 ///
5619 /// # Example
5620 /// ```ignore,no_run
5621 /// # use google_cloud_speech_v2::model::BatchRecognizeRequest;
5622 /// use google_cloud_speech_v2::model::RecognitionOutputConfig;
5623 /// let x = BatchRecognizeRequest::new().set_recognition_output_config(RecognitionOutputConfig::default()/* use setters */);
5624 /// ```
5625 pub fn set_recognition_output_config<T>(mut self, v: T) -> Self
5626 where
5627 T: std::convert::Into<crate::model::RecognitionOutputConfig>,
5628 {
5629 self.recognition_output_config = std::option::Option::Some(v.into());
5630 self
5631 }
5632
5633 /// Sets or clears the value of [recognition_output_config][crate::model::BatchRecognizeRequest::recognition_output_config].
5634 ///
5635 /// # Example
5636 /// ```ignore,no_run
5637 /// # use google_cloud_speech_v2::model::BatchRecognizeRequest;
5638 /// use google_cloud_speech_v2::model::RecognitionOutputConfig;
5639 /// let x = BatchRecognizeRequest::new().set_or_clear_recognition_output_config(Some(RecognitionOutputConfig::default()/* use setters */));
5640 /// let x = BatchRecognizeRequest::new().set_or_clear_recognition_output_config(None::<RecognitionOutputConfig>);
5641 /// ```
5642 pub fn set_or_clear_recognition_output_config<T>(mut self, v: std::option::Option<T>) -> Self
5643 where
5644 T: std::convert::Into<crate::model::RecognitionOutputConfig>,
5645 {
5646 self.recognition_output_config = v.map(|x| x.into());
5647 self
5648 }
5649
5650 /// Sets the value of [processing_strategy][crate::model::BatchRecognizeRequest::processing_strategy].
5651 ///
5652 /// # Example
5653 /// ```ignore,no_run
5654 /// # use google_cloud_speech_v2::model::BatchRecognizeRequest;
5655 /// use google_cloud_speech_v2::model::batch_recognize_request::ProcessingStrategy;
5656 /// let x0 = BatchRecognizeRequest::new().set_processing_strategy(ProcessingStrategy::DynamicBatching);
5657 /// ```
5658 pub fn set_processing_strategy<
5659 T: std::convert::Into<crate::model::batch_recognize_request::ProcessingStrategy>,
5660 >(
5661 mut self,
5662 v: T,
5663 ) -> Self {
5664 self.processing_strategy = v.into();
5665 self
5666 }
5667}
5668
5669impl wkt::message::Message for BatchRecognizeRequest {
5670 fn typename() -> &'static str {
5671 "type.googleapis.com/google.cloud.speech.v2.BatchRecognizeRequest"
5672 }
5673}
5674
5675/// Defines additional types related to [BatchRecognizeRequest].
5676pub mod batch_recognize_request {
5677 #[allow(unused_imports)]
5678 use super::*;
5679
5680 /// Possible processing strategies for batch requests.
5681 ///
5682 /// # Working with unknown values
5683 ///
5684 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
5685 /// additional enum variants at any time. Adding new variants is not considered
5686 /// a breaking change. Applications should write their code in anticipation of:
5687 ///
5688 /// - New values appearing in future releases of the client library, **and**
5689 /// - New values received dynamically, without application changes.
5690 ///
5691 /// Please consult the [Working with enums] section in the user guide for some
5692 /// guidelines.
5693 ///
5694 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
5695 #[derive(Clone, Debug, PartialEq)]
5696 #[non_exhaustive]
5697 pub enum ProcessingStrategy {
5698 /// Default value for the processing strategy. The request is processed as
5699 /// soon as its received.
5700 Unspecified,
5701 /// If selected, processes the request during lower utilization periods for a
5702 /// price discount. The request is fulfilled within 24 hours.
5703 DynamicBatching,
5704 /// If set, the enum was initialized with an unknown value.
5705 ///
5706 /// Applications can examine the value using [ProcessingStrategy::value] or
5707 /// [ProcessingStrategy::name].
5708 UnknownValue(processing_strategy::UnknownValue),
5709 }
5710
5711 #[doc(hidden)]
5712 pub mod processing_strategy {
5713 #[allow(unused_imports)]
5714 use super::*;
5715 #[derive(Clone, Debug, PartialEq)]
5716 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
5717 }
5718
5719 impl ProcessingStrategy {
5720 /// Gets the enum value.
5721 ///
5722 /// Returns `None` if the enum contains an unknown value deserialized from
5723 /// the string representation of enums.
5724 pub fn value(&self) -> std::option::Option<i32> {
5725 match self {
5726 Self::Unspecified => std::option::Option::Some(0),
5727 Self::DynamicBatching => std::option::Option::Some(1),
5728 Self::UnknownValue(u) => u.0.value(),
5729 }
5730 }
5731
5732 /// Gets the enum value as a string.
5733 ///
5734 /// Returns `None` if the enum contains an unknown value deserialized from
5735 /// the integer representation of enums.
5736 pub fn name(&self) -> std::option::Option<&str> {
5737 match self {
5738 Self::Unspecified => std::option::Option::Some("PROCESSING_STRATEGY_UNSPECIFIED"),
5739 Self::DynamicBatching => std::option::Option::Some("DYNAMIC_BATCHING"),
5740 Self::UnknownValue(u) => u.0.name(),
5741 }
5742 }
5743 }
5744
5745 impl std::default::Default for ProcessingStrategy {
5746 fn default() -> Self {
5747 use std::convert::From;
5748 Self::from(0)
5749 }
5750 }
5751
5752 impl std::fmt::Display for ProcessingStrategy {
5753 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
5754 wkt::internal::display_enum(f, self.name(), self.value())
5755 }
5756 }
5757
5758 impl std::convert::From<i32> for ProcessingStrategy {
5759 fn from(value: i32) -> Self {
5760 match value {
5761 0 => Self::Unspecified,
5762 1 => Self::DynamicBatching,
5763 _ => Self::UnknownValue(processing_strategy::UnknownValue(
5764 wkt::internal::UnknownEnumValue::Integer(value),
5765 )),
5766 }
5767 }
5768 }
5769
5770 impl std::convert::From<&str> for ProcessingStrategy {
5771 fn from(value: &str) -> Self {
5772 use std::string::ToString;
5773 match value {
5774 "PROCESSING_STRATEGY_UNSPECIFIED" => Self::Unspecified,
5775 "DYNAMIC_BATCHING" => Self::DynamicBatching,
5776 _ => Self::UnknownValue(processing_strategy::UnknownValue(
5777 wkt::internal::UnknownEnumValue::String(value.to_string()),
5778 )),
5779 }
5780 }
5781 }
5782
5783 impl serde::ser::Serialize for ProcessingStrategy {
5784 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5785 where
5786 S: serde::Serializer,
5787 {
5788 match self {
5789 Self::Unspecified => serializer.serialize_i32(0),
5790 Self::DynamicBatching => serializer.serialize_i32(1),
5791 Self::UnknownValue(u) => u.0.serialize(serializer),
5792 }
5793 }
5794 }
5795
5796 impl<'de> serde::de::Deserialize<'de> for ProcessingStrategy {
5797 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5798 where
5799 D: serde::Deserializer<'de>,
5800 {
5801 deserializer.deserialize_any(wkt::internal::EnumVisitor::<ProcessingStrategy>::new(
5802 ".google.cloud.speech.v2.BatchRecognizeRequest.ProcessingStrategy",
5803 ))
5804 }
5805 }
5806}
5807
5808/// Output configurations for Cloud Storage.
5809#[derive(Clone, Default, PartialEq)]
5810#[non_exhaustive]
5811pub struct GcsOutputConfig {
5812 /// The Cloud Storage URI prefix with which recognition results will be
5813 /// written.
5814 pub uri: std::string::String,
5815
5816 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5817}
5818
5819impl GcsOutputConfig {
5820 /// Creates a new default instance.
5821 pub fn new() -> Self {
5822 std::default::Default::default()
5823 }
5824
5825 /// Sets the value of [uri][crate::model::GcsOutputConfig::uri].
5826 ///
5827 /// # Example
5828 /// ```ignore,no_run
5829 /// # use google_cloud_speech_v2::model::GcsOutputConfig;
5830 /// let x = GcsOutputConfig::new().set_uri("example");
5831 /// ```
5832 pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5833 self.uri = v.into();
5834 self
5835 }
5836}
5837
5838impl wkt::message::Message for GcsOutputConfig {
5839 fn typename() -> &'static str {
5840 "type.googleapis.com/google.cloud.speech.v2.GcsOutputConfig"
5841 }
5842}
5843
5844/// Output configurations for inline response.
5845#[derive(Clone, Default, PartialEq)]
5846#[non_exhaustive]
5847pub struct InlineOutputConfig {
5848 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5849}
5850
5851impl InlineOutputConfig {
5852 /// Creates a new default instance.
5853 pub fn new() -> Self {
5854 std::default::Default::default()
5855 }
5856}
5857
5858impl wkt::message::Message for InlineOutputConfig {
5859 fn typename() -> &'static str {
5860 "type.googleapis.com/google.cloud.speech.v2.InlineOutputConfig"
5861 }
5862}
5863
5864/// Output configurations for serialized `BatchRecognizeResults` protos.
5865#[derive(Clone, Default, PartialEq)]
5866#[non_exhaustive]
5867pub struct NativeOutputFileFormatConfig {
5868 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5869}
5870
5871impl NativeOutputFileFormatConfig {
5872 /// Creates a new default instance.
5873 pub fn new() -> Self {
5874 std::default::Default::default()
5875 }
5876}
5877
5878impl wkt::message::Message for NativeOutputFileFormatConfig {
5879 fn typename() -> &'static str {
5880 "type.googleapis.com/google.cloud.speech.v2.NativeOutputFileFormatConfig"
5881 }
5882}
5883
5884/// Output configurations for [WebVTT](https://www.w3.org/TR/webvtt1/) formatted
5885/// subtitle file.
5886#[derive(Clone, Default, PartialEq)]
5887#[non_exhaustive]
5888pub struct VttOutputFileFormatConfig {
5889 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5890}
5891
5892impl VttOutputFileFormatConfig {
5893 /// Creates a new default instance.
5894 pub fn new() -> Self {
5895 std::default::Default::default()
5896 }
5897}
5898
5899impl wkt::message::Message for VttOutputFileFormatConfig {
5900 fn typename() -> &'static str {
5901 "type.googleapis.com/google.cloud.speech.v2.VttOutputFileFormatConfig"
5902 }
5903}
5904
5905/// Output configurations [SubRip
5906/// Text](https://www.matroska.org/technical/subtitles.html#srt-subtitles)
5907/// formatted subtitle file.
5908#[derive(Clone, Default, PartialEq)]
5909#[non_exhaustive]
5910pub struct SrtOutputFileFormatConfig {
5911 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5912}
5913
5914impl SrtOutputFileFormatConfig {
5915 /// Creates a new default instance.
5916 pub fn new() -> Self {
5917 std::default::Default::default()
5918 }
5919}
5920
5921impl wkt::message::Message for SrtOutputFileFormatConfig {
5922 fn typename() -> &'static str {
5923 "type.googleapis.com/google.cloud.speech.v2.SrtOutputFileFormatConfig"
5924 }
5925}
5926
5927/// Configuration for the format of the results stored to `output`.
5928#[derive(Clone, Default, PartialEq)]
5929#[non_exhaustive]
5930pub struct OutputFormatConfig {
5931 /// Configuration for the native output format. If this field is set or if no
5932 /// other output format field is set, then transcripts will be written to the
5933 /// sink in the native format.
5934 pub native: std::option::Option<crate::model::NativeOutputFileFormatConfig>,
5935
5936 /// Configuration for the VTT output format. If this field is set, then
5937 /// transcripts will be written to the sink in the VTT format.
5938 pub vtt: std::option::Option<crate::model::VttOutputFileFormatConfig>,
5939
5940 /// Configuration for the SRT output format. If this field is set, then
5941 /// transcripts will be written to the sink in the SRT format.
5942 pub srt: std::option::Option<crate::model::SrtOutputFileFormatConfig>,
5943
5944 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5945}
5946
5947impl OutputFormatConfig {
5948 /// Creates a new default instance.
5949 pub fn new() -> Self {
5950 std::default::Default::default()
5951 }
5952
5953 /// Sets the value of [native][crate::model::OutputFormatConfig::native].
5954 ///
5955 /// # Example
5956 /// ```ignore,no_run
5957 /// # use google_cloud_speech_v2::model::OutputFormatConfig;
5958 /// use google_cloud_speech_v2::model::NativeOutputFileFormatConfig;
5959 /// let x = OutputFormatConfig::new().set_native(NativeOutputFileFormatConfig::default()/* use setters */);
5960 /// ```
5961 pub fn set_native<T>(mut self, v: T) -> Self
5962 where
5963 T: std::convert::Into<crate::model::NativeOutputFileFormatConfig>,
5964 {
5965 self.native = std::option::Option::Some(v.into());
5966 self
5967 }
5968
5969 /// Sets or clears the value of [native][crate::model::OutputFormatConfig::native].
5970 ///
5971 /// # Example
5972 /// ```ignore,no_run
5973 /// # use google_cloud_speech_v2::model::OutputFormatConfig;
5974 /// use google_cloud_speech_v2::model::NativeOutputFileFormatConfig;
5975 /// let x = OutputFormatConfig::new().set_or_clear_native(Some(NativeOutputFileFormatConfig::default()/* use setters */));
5976 /// let x = OutputFormatConfig::new().set_or_clear_native(None::<NativeOutputFileFormatConfig>);
5977 /// ```
5978 pub fn set_or_clear_native<T>(mut self, v: std::option::Option<T>) -> Self
5979 where
5980 T: std::convert::Into<crate::model::NativeOutputFileFormatConfig>,
5981 {
5982 self.native = v.map(|x| x.into());
5983 self
5984 }
5985
5986 /// Sets the value of [vtt][crate::model::OutputFormatConfig::vtt].
5987 ///
5988 /// # Example
5989 /// ```ignore,no_run
5990 /// # use google_cloud_speech_v2::model::OutputFormatConfig;
5991 /// use google_cloud_speech_v2::model::VttOutputFileFormatConfig;
5992 /// let x = OutputFormatConfig::new().set_vtt(VttOutputFileFormatConfig::default()/* use setters */);
5993 /// ```
5994 pub fn set_vtt<T>(mut self, v: T) -> Self
5995 where
5996 T: std::convert::Into<crate::model::VttOutputFileFormatConfig>,
5997 {
5998 self.vtt = std::option::Option::Some(v.into());
5999 self
6000 }
6001
6002 /// Sets or clears the value of [vtt][crate::model::OutputFormatConfig::vtt].
6003 ///
6004 /// # Example
6005 /// ```ignore,no_run
6006 /// # use google_cloud_speech_v2::model::OutputFormatConfig;
6007 /// use google_cloud_speech_v2::model::VttOutputFileFormatConfig;
6008 /// let x = OutputFormatConfig::new().set_or_clear_vtt(Some(VttOutputFileFormatConfig::default()/* use setters */));
6009 /// let x = OutputFormatConfig::new().set_or_clear_vtt(None::<VttOutputFileFormatConfig>);
6010 /// ```
6011 pub fn set_or_clear_vtt<T>(mut self, v: std::option::Option<T>) -> Self
6012 where
6013 T: std::convert::Into<crate::model::VttOutputFileFormatConfig>,
6014 {
6015 self.vtt = v.map(|x| x.into());
6016 self
6017 }
6018
6019 /// Sets the value of [srt][crate::model::OutputFormatConfig::srt].
6020 ///
6021 /// # Example
6022 /// ```ignore,no_run
6023 /// # use google_cloud_speech_v2::model::OutputFormatConfig;
6024 /// use google_cloud_speech_v2::model::SrtOutputFileFormatConfig;
6025 /// let x = OutputFormatConfig::new().set_srt(SrtOutputFileFormatConfig::default()/* use setters */);
6026 /// ```
6027 pub fn set_srt<T>(mut self, v: T) -> Self
6028 where
6029 T: std::convert::Into<crate::model::SrtOutputFileFormatConfig>,
6030 {
6031 self.srt = std::option::Option::Some(v.into());
6032 self
6033 }
6034
6035 /// Sets or clears the value of [srt][crate::model::OutputFormatConfig::srt].
6036 ///
6037 /// # Example
6038 /// ```ignore,no_run
6039 /// # use google_cloud_speech_v2::model::OutputFormatConfig;
6040 /// use google_cloud_speech_v2::model::SrtOutputFileFormatConfig;
6041 /// let x = OutputFormatConfig::new().set_or_clear_srt(Some(SrtOutputFileFormatConfig::default()/* use setters */));
6042 /// let x = OutputFormatConfig::new().set_or_clear_srt(None::<SrtOutputFileFormatConfig>);
6043 /// ```
6044 pub fn set_or_clear_srt<T>(mut self, v: std::option::Option<T>) -> Self
6045 where
6046 T: std::convert::Into<crate::model::SrtOutputFileFormatConfig>,
6047 {
6048 self.srt = v.map(|x| x.into());
6049 self
6050 }
6051}
6052
6053impl wkt::message::Message for OutputFormatConfig {
6054 fn typename() -> &'static str {
6055 "type.googleapis.com/google.cloud.speech.v2.OutputFormatConfig"
6056 }
6057}
6058
6059/// Configuration options for the output(s) of recognition.
6060#[derive(Clone, Default, PartialEq)]
6061#[non_exhaustive]
6062pub struct RecognitionOutputConfig {
6063 /// Optional. Configuration for the format of the results stored to `output`.
6064 /// If unspecified transcripts will be written in the `NATIVE` format only.
6065 pub output_format_config: std::option::Option<crate::model::OutputFormatConfig>,
6066
6067 #[allow(missing_docs)]
6068 pub output: std::option::Option<crate::model::recognition_output_config::Output>,
6069
6070 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6071}
6072
6073impl RecognitionOutputConfig {
6074 /// Creates a new default instance.
6075 pub fn new() -> Self {
6076 std::default::Default::default()
6077 }
6078
6079 /// Sets the value of [output_format_config][crate::model::RecognitionOutputConfig::output_format_config].
6080 ///
6081 /// # Example
6082 /// ```ignore,no_run
6083 /// # use google_cloud_speech_v2::model::RecognitionOutputConfig;
6084 /// use google_cloud_speech_v2::model::OutputFormatConfig;
6085 /// let x = RecognitionOutputConfig::new().set_output_format_config(OutputFormatConfig::default()/* use setters */);
6086 /// ```
6087 pub fn set_output_format_config<T>(mut self, v: T) -> Self
6088 where
6089 T: std::convert::Into<crate::model::OutputFormatConfig>,
6090 {
6091 self.output_format_config = std::option::Option::Some(v.into());
6092 self
6093 }
6094
6095 /// Sets or clears the value of [output_format_config][crate::model::RecognitionOutputConfig::output_format_config].
6096 ///
6097 /// # Example
6098 /// ```ignore,no_run
6099 /// # use google_cloud_speech_v2::model::RecognitionOutputConfig;
6100 /// use google_cloud_speech_v2::model::OutputFormatConfig;
6101 /// let x = RecognitionOutputConfig::new().set_or_clear_output_format_config(Some(OutputFormatConfig::default()/* use setters */));
6102 /// let x = RecognitionOutputConfig::new().set_or_clear_output_format_config(None::<OutputFormatConfig>);
6103 /// ```
6104 pub fn set_or_clear_output_format_config<T>(mut self, v: std::option::Option<T>) -> Self
6105 where
6106 T: std::convert::Into<crate::model::OutputFormatConfig>,
6107 {
6108 self.output_format_config = v.map(|x| x.into());
6109 self
6110 }
6111
6112 /// Sets the value of [output][crate::model::RecognitionOutputConfig::output].
6113 ///
6114 /// Note that all the setters affecting `output` are mutually
6115 /// exclusive.
6116 ///
6117 /// # Example
6118 /// ```ignore,no_run
6119 /// # use google_cloud_speech_v2::model::RecognitionOutputConfig;
6120 /// use google_cloud_speech_v2::model::GcsOutputConfig;
6121 /// let x = RecognitionOutputConfig::new().set_output(Some(
6122 /// google_cloud_speech_v2::model::recognition_output_config::Output::GcsOutputConfig(GcsOutputConfig::default().into())));
6123 /// ```
6124 pub fn set_output<
6125 T: std::convert::Into<std::option::Option<crate::model::recognition_output_config::Output>>,
6126 >(
6127 mut self,
6128 v: T,
6129 ) -> Self {
6130 self.output = v.into();
6131 self
6132 }
6133
6134 /// The value of [output][crate::model::RecognitionOutputConfig::output]
6135 /// if it holds a `GcsOutputConfig`, `None` if the field is not set or
6136 /// holds a different branch.
6137 pub fn gcs_output_config(
6138 &self,
6139 ) -> std::option::Option<&std::boxed::Box<crate::model::GcsOutputConfig>> {
6140 #[allow(unreachable_patterns)]
6141 self.output.as_ref().and_then(|v| match v {
6142 crate::model::recognition_output_config::Output::GcsOutputConfig(v) => {
6143 std::option::Option::Some(v)
6144 }
6145 _ => std::option::Option::None,
6146 })
6147 }
6148
6149 /// Sets the value of [output][crate::model::RecognitionOutputConfig::output]
6150 /// to hold a `GcsOutputConfig`.
6151 ///
6152 /// Note that all the setters affecting `output` are
6153 /// mutually exclusive.
6154 ///
6155 /// # Example
6156 /// ```ignore,no_run
6157 /// # use google_cloud_speech_v2::model::RecognitionOutputConfig;
6158 /// use google_cloud_speech_v2::model::GcsOutputConfig;
6159 /// let x = RecognitionOutputConfig::new().set_gcs_output_config(GcsOutputConfig::default()/* use setters */);
6160 /// assert!(x.gcs_output_config().is_some());
6161 /// assert!(x.inline_response_config().is_none());
6162 /// ```
6163 pub fn set_gcs_output_config<
6164 T: std::convert::Into<std::boxed::Box<crate::model::GcsOutputConfig>>,
6165 >(
6166 mut self,
6167 v: T,
6168 ) -> Self {
6169 self.output = std::option::Option::Some(
6170 crate::model::recognition_output_config::Output::GcsOutputConfig(v.into()),
6171 );
6172 self
6173 }
6174
6175 /// The value of [output][crate::model::RecognitionOutputConfig::output]
6176 /// if it holds a `InlineResponseConfig`, `None` if the field is not set or
6177 /// holds a different branch.
6178 pub fn inline_response_config(
6179 &self,
6180 ) -> std::option::Option<&std::boxed::Box<crate::model::InlineOutputConfig>> {
6181 #[allow(unreachable_patterns)]
6182 self.output.as_ref().and_then(|v| match v {
6183 crate::model::recognition_output_config::Output::InlineResponseConfig(v) => {
6184 std::option::Option::Some(v)
6185 }
6186 _ => std::option::Option::None,
6187 })
6188 }
6189
6190 /// Sets the value of [output][crate::model::RecognitionOutputConfig::output]
6191 /// to hold a `InlineResponseConfig`.
6192 ///
6193 /// Note that all the setters affecting `output` are
6194 /// mutually exclusive.
6195 ///
6196 /// # Example
6197 /// ```ignore,no_run
6198 /// # use google_cloud_speech_v2::model::RecognitionOutputConfig;
6199 /// use google_cloud_speech_v2::model::InlineOutputConfig;
6200 /// let x = RecognitionOutputConfig::new().set_inline_response_config(InlineOutputConfig::default()/* use setters */);
6201 /// assert!(x.inline_response_config().is_some());
6202 /// assert!(x.gcs_output_config().is_none());
6203 /// ```
6204 pub fn set_inline_response_config<
6205 T: std::convert::Into<std::boxed::Box<crate::model::InlineOutputConfig>>,
6206 >(
6207 mut self,
6208 v: T,
6209 ) -> Self {
6210 self.output = std::option::Option::Some(
6211 crate::model::recognition_output_config::Output::InlineResponseConfig(v.into()),
6212 );
6213 self
6214 }
6215}
6216
6217impl wkt::message::Message for RecognitionOutputConfig {
6218 fn typename() -> &'static str {
6219 "type.googleapis.com/google.cloud.speech.v2.RecognitionOutputConfig"
6220 }
6221}
6222
6223/// Defines additional types related to [RecognitionOutputConfig].
6224pub mod recognition_output_config {
6225 #[allow(unused_imports)]
6226 use super::*;
6227
6228 #[allow(missing_docs)]
6229 #[derive(Clone, Debug, PartialEq)]
6230 #[non_exhaustive]
6231 pub enum Output {
6232 /// If this message is populated, recognition results are written to the
6233 /// provided Google Cloud Storage URI.
6234 GcsOutputConfig(std::boxed::Box<crate::model::GcsOutputConfig>),
6235 /// If this message is populated, recognition results are provided in the
6236 /// [BatchRecognizeResponse][google.cloud.speech.v2.BatchRecognizeResponse]
6237 /// message of the Operation when completed. This is only supported when
6238 /// calling [BatchRecognize][google.cloud.speech.v2.Speech.BatchRecognize]
6239 /// with just one audio file.
6240 ///
6241 /// [google.cloud.speech.v2.BatchRecognizeResponse]: crate::model::BatchRecognizeResponse
6242 /// [google.cloud.speech.v2.Speech.BatchRecognize]: crate::client::Speech::batch_recognize
6243 InlineResponseConfig(std::boxed::Box<crate::model::InlineOutputConfig>),
6244 }
6245}
6246
6247/// Response message for
6248/// [BatchRecognize][google.cloud.speech.v2.Speech.BatchRecognize] that is
6249/// packaged into a longrunning [Operation][google.longrunning.Operation].
6250///
6251/// [google.cloud.speech.v2.Speech.BatchRecognize]: crate::client::Speech::batch_recognize
6252/// [google.longrunning.Operation]: google_cloud_longrunning::model::Operation
6253#[derive(Clone, Default, PartialEq)]
6254#[non_exhaustive]
6255pub struct BatchRecognizeResponse {
6256 /// Map from filename to the final result for that file.
6257 pub results:
6258 std::collections::HashMap<std::string::String, crate::model::BatchRecognizeFileResult>,
6259
6260 /// When available, billed audio seconds for the corresponding request.
6261 pub total_billed_duration: std::option::Option<wkt::Duration>,
6262
6263 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6264}
6265
6266impl BatchRecognizeResponse {
6267 /// Creates a new default instance.
6268 pub fn new() -> Self {
6269 std::default::Default::default()
6270 }
6271
6272 /// Sets the value of [results][crate::model::BatchRecognizeResponse::results].
6273 ///
6274 /// # Example
6275 /// ```ignore,no_run
6276 /// # use google_cloud_speech_v2::model::BatchRecognizeResponse;
6277 /// use google_cloud_speech_v2::model::BatchRecognizeFileResult;
6278 /// let x = BatchRecognizeResponse::new().set_results([
6279 /// ("key0", BatchRecognizeFileResult::default()/* use setters */),
6280 /// ("key1", BatchRecognizeFileResult::default()/* use (different) setters */),
6281 /// ]);
6282 /// ```
6283 pub fn set_results<T, K, V>(mut self, v: T) -> Self
6284 where
6285 T: std::iter::IntoIterator<Item = (K, V)>,
6286 K: std::convert::Into<std::string::String>,
6287 V: std::convert::Into<crate::model::BatchRecognizeFileResult>,
6288 {
6289 use std::iter::Iterator;
6290 self.results = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
6291 self
6292 }
6293
6294 /// Sets the value of [total_billed_duration][crate::model::BatchRecognizeResponse::total_billed_duration].
6295 ///
6296 /// # Example
6297 /// ```ignore,no_run
6298 /// # use google_cloud_speech_v2::model::BatchRecognizeResponse;
6299 /// use wkt::Duration;
6300 /// let x = BatchRecognizeResponse::new().set_total_billed_duration(Duration::default()/* use setters */);
6301 /// ```
6302 pub fn set_total_billed_duration<T>(mut self, v: T) -> Self
6303 where
6304 T: std::convert::Into<wkt::Duration>,
6305 {
6306 self.total_billed_duration = std::option::Option::Some(v.into());
6307 self
6308 }
6309
6310 /// Sets or clears the value of [total_billed_duration][crate::model::BatchRecognizeResponse::total_billed_duration].
6311 ///
6312 /// # Example
6313 /// ```ignore,no_run
6314 /// # use google_cloud_speech_v2::model::BatchRecognizeResponse;
6315 /// use wkt::Duration;
6316 /// let x = BatchRecognizeResponse::new().set_or_clear_total_billed_duration(Some(Duration::default()/* use setters */));
6317 /// let x = BatchRecognizeResponse::new().set_or_clear_total_billed_duration(None::<Duration>);
6318 /// ```
6319 pub fn set_or_clear_total_billed_duration<T>(mut self, v: std::option::Option<T>) -> Self
6320 where
6321 T: std::convert::Into<wkt::Duration>,
6322 {
6323 self.total_billed_duration = v.map(|x| x.into());
6324 self
6325 }
6326}
6327
6328impl wkt::message::Message for BatchRecognizeResponse {
6329 fn typename() -> &'static str {
6330 "type.googleapis.com/google.cloud.speech.v2.BatchRecognizeResponse"
6331 }
6332}
6333
6334/// Output type for Cloud Storage of BatchRecognize transcripts. Though this
6335/// proto isn't returned in this API anywhere, the Cloud Storage transcripts will
6336/// be this proto serialized and should be parsed as such.
6337#[derive(Clone, Default, PartialEq)]
6338#[non_exhaustive]
6339pub struct BatchRecognizeResults {
6340 /// Sequential list of transcription results corresponding to sequential
6341 /// portions of audio.
6342 pub results: std::vec::Vec<crate::model::SpeechRecognitionResult>,
6343
6344 /// Metadata about the recognition.
6345 pub metadata: std::option::Option<crate::model::RecognitionResponseMetadata>,
6346
6347 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6348}
6349
6350impl BatchRecognizeResults {
6351 /// Creates a new default instance.
6352 pub fn new() -> Self {
6353 std::default::Default::default()
6354 }
6355
6356 /// Sets the value of [results][crate::model::BatchRecognizeResults::results].
6357 ///
6358 /// # Example
6359 /// ```ignore,no_run
6360 /// # use google_cloud_speech_v2::model::BatchRecognizeResults;
6361 /// use google_cloud_speech_v2::model::SpeechRecognitionResult;
6362 /// let x = BatchRecognizeResults::new()
6363 /// .set_results([
6364 /// SpeechRecognitionResult::default()/* use setters */,
6365 /// SpeechRecognitionResult::default()/* use (different) setters */,
6366 /// ]);
6367 /// ```
6368 pub fn set_results<T, V>(mut self, v: T) -> Self
6369 where
6370 T: std::iter::IntoIterator<Item = V>,
6371 V: std::convert::Into<crate::model::SpeechRecognitionResult>,
6372 {
6373 use std::iter::Iterator;
6374 self.results = v.into_iter().map(|i| i.into()).collect();
6375 self
6376 }
6377
6378 /// Sets the value of [metadata][crate::model::BatchRecognizeResults::metadata].
6379 ///
6380 /// # Example
6381 /// ```ignore,no_run
6382 /// # use google_cloud_speech_v2::model::BatchRecognizeResults;
6383 /// use google_cloud_speech_v2::model::RecognitionResponseMetadata;
6384 /// let x = BatchRecognizeResults::new().set_metadata(RecognitionResponseMetadata::default()/* use setters */);
6385 /// ```
6386 pub fn set_metadata<T>(mut self, v: T) -> Self
6387 where
6388 T: std::convert::Into<crate::model::RecognitionResponseMetadata>,
6389 {
6390 self.metadata = std::option::Option::Some(v.into());
6391 self
6392 }
6393
6394 /// Sets or clears the value of [metadata][crate::model::BatchRecognizeResults::metadata].
6395 ///
6396 /// # Example
6397 /// ```ignore,no_run
6398 /// # use google_cloud_speech_v2::model::BatchRecognizeResults;
6399 /// use google_cloud_speech_v2::model::RecognitionResponseMetadata;
6400 /// let x = BatchRecognizeResults::new().set_or_clear_metadata(Some(RecognitionResponseMetadata::default()/* use setters */));
6401 /// let x = BatchRecognizeResults::new().set_or_clear_metadata(None::<RecognitionResponseMetadata>);
6402 /// ```
6403 pub fn set_or_clear_metadata<T>(mut self, v: std::option::Option<T>) -> Self
6404 where
6405 T: std::convert::Into<crate::model::RecognitionResponseMetadata>,
6406 {
6407 self.metadata = v.map(|x| x.into());
6408 self
6409 }
6410}
6411
6412impl wkt::message::Message for BatchRecognizeResults {
6413 fn typename() -> &'static str {
6414 "type.googleapis.com/google.cloud.speech.v2.BatchRecognizeResults"
6415 }
6416}
6417
6418/// Final results written to Cloud Storage.
6419#[derive(Clone, Default, PartialEq)]
6420#[non_exhaustive]
6421pub struct CloudStorageResult {
6422 /// The Cloud Storage URI to which recognition results were written.
6423 pub uri: std::string::String,
6424
6425 /// The Cloud Storage URI to which recognition results were written as VTT
6426 /// formatted captions. This is populated only when `VTT` output is requested.
6427 pub vtt_format_uri: std::string::String,
6428
6429 /// The Cloud Storage URI to which recognition results were written as SRT
6430 /// formatted captions. This is populated only when `SRT` output is requested.
6431 pub srt_format_uri: std::string::String,
6432
6433 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6434}
6435
6436impl CloudStorageResult {
6437 /// Creates a new default instance.
6438 pub fn new() -> Self {
6439 std::default::Default::default()
6440 }
6441
6442 /// Sets the value of [uri][crate::model::CloudStorageResult::uri].
6443 ///
6444 /// # Example
6445 /// ```ignore,no_run
6446 /// # use google_cloud_speech_v2::model::CloudStorageResult;
6447 /// let x = CloudStorageResult::new().set_uri("example");
6448 /// ```
6449 pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6450 self.uri = v.into();
6451 self
6452 }
6453
6454 /// Sets the value of [vtt_format_uri][crate::model::CloudStorageResult::vtt_format_uri].
6455 ///
6456 /// # Example
6457 /// ```ignore,no_run
6458 /// # use google_cloud_speech_v2::model::CloudStorageResult;
6459 /// let x = CloudStorageResult::new().set_vtt_format_uri("example");
6460 /// ```
6461 pub fn set_vtt_format_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6462 self.vtt_format_uri = v.into();
6463 self
6464 }
6465
6466 /// Sets the value of [srt_format_uri][crate::model::CloudStorageResult::srt_format_uri].
6467 ///
6468 /// # Example
6469 /// ```ignore,no_run
6470 /// # use google_cloud_speech_v2::model::CloudStorageResult;
6471 /// let x = CloudStorageResult::new().set_srt_format_uri("example");
6472 /// ```
6473 pub fn set_srt_format_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6474 self.srt_format_uri = v.into();
6475 self
6476 }
6477}
6478
6479impl wkt::message::Message for CloudStorageResult {
6480 fn typename() -> &'static str {
6481 "type.googleapis.com/google.cloud.speech.v2.CloudStorageResult"
6482 }
6483}
6484
6485/// Final results returned inline in the recognition response.
6486#[derive(Clone, Default, PartialEq)]
6487#[non_exhaustive]
6488pub struct InlineResult {
6489 /// The transcript for the audio file.
6490 pub transcript: std::option::Option<crate::model::BatchRecognizeResults>,
6491
6492 /// The transcript for the audio file as VTT formatted captions. This is
6493 /// populated only when `VTT` output is requested.
6494 pub vtt_captions: std::string::String,
6495
6496 /// The transcript for the audio file as SRT formatted captions. This is
6497 /// populated only when `SRT` output is requested.
6498 pub srt_captions: std::string::String,
6499
6500 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6501}
6502
6503impl InlineResult {
6504 /// Creates a new default instance.
6505 pub fn new() -> Self {
6506 std::default::Default::default()
6507 }
6508
6509 /// Sets the value of [transcript][crate::model::InlineResult::transcript].
6510 ///
6511 /// # Example
6512 /// ```ignore,no_run
6513 /// # use google_cloud_speech_v2::model::InlineResult;
6514 /// use google_cloud_speech_v2::model::BatchRecognizeResults;
6515 /// let x = InlineResult::new().set_transcript(BatchRecognizeResults::default()/* use setters */);
6516 /// ```
6517 pub fn set_transcript<T>(mut self, v: T) -> Self
6518 where
6519 T: std::convert::Into<crate::model::BatchRecognizeResults>,
6520 {
6521 self.transcript = std::option::Option::Some(v.into());
6522 self
6523 }
6524
6525 /// Sets or clears the value of [transcript][crate::model::InlineResult::transcript].
6526 ///
6527 /// # Example
6528 /// ```ignore,no_run
6529 /// # use google_cloud_speech_v2::model::InlineResult;
6530 /// use google_cloud_speech_v2::model::BatchRecognizeResults;
6531 /// let x = InlineResult::new().set_or_clear_transcript(Some(BatchRecognizeResults::default()/* use setters */));
6532 /// let x = InlineResult::new().set_or_clear_transcript(None::<BatchRecognizeResults>);
6533 /// ```
6534 pub fn set_or_clear_transcript<T>(mut self, v: std::option::Option<T>) -> Self
6535 where
6536 T: std::convert::Into<crate::model::BatchRecognizeResults>,
6537 {
6538 self.transcript = v.map(|x| x.into());
6539 self
6540 }
6541
6542 /// Sets the value of [vtt_captions][crate::model::InlineResult::vtt_captions].
6543 ///
6544 /// # Example
6545 /// ```ignore,no_run
6546 /// # use google_cloud_speech_v2::model::InlineResult;
6547 /// let x = InlineResult::new().set_vtt_captions("example");
6548 /// ```
6549 pub fn set_vtt_captions<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6550 self.vtt_captions = v.into();
6551 self
6552 }
6553
6554 /// Sets the value of [srt_captions][crate::model::InlineResult::srt_captions].
6555 ///
6556 /// # Example
6557 /// ```ignore,no_run
6558 /// # use google_cloud_speech_v2::model::InlineResult;
6559 /// let x = InlineResult::new().set_srt_captions("example");
6560 /// ```
6561 pub fn set_srt_captions<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6562 self.srt_captions = v.into();
6563 self
6564 }
6565}
6566
6567impl wkt::message::Message for InlineResult {
6568 fn typename() -> &'static str {
6569 "type.googleapis.com/google.cloud.speech.v2.InlineResult"
6570 }
6571}
6572
6573/// Final results for a single file.
6574#[derive(Clone, Default, PartialEq)]
6575#[non_exhaustive]
6576pub struct BatchRecognizeFileResult {
6577 /// Error if one was encountered.
6578 pub error: std::option::Option<google_cloud_rpc::model::Status>,
6579
6580 #[allow(missing_docs)]
6581 pub metadata: std::option::Option<crate::model::RecognitionResponseMetadata>,
6582
6583 /// Deprecated. Use `cloud_storage_result.native_format_uri` instead.
6584 #[deprecated]
6585 pub uri: std::string::String,
6586
6587 /// Deprecated. Use `inline_result.transcript` instead.
6588 #[deprecated]
6589 pub transcript: std::option::Option<crate::model::BatchRecognizeResults>,
6590
6591 #[allow(missing_docs)]
6592 pub result: std::option::Option<crate::model::batch_recognize_file_result::Result>,
6593
6594 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6595}
6596
6597impl BatchRecognizeFileResult {
6598 /// Creates a new default instance.
6599 pub fn new() -> Self {
6600 std::default::Default::default()
6601 }
6602
6603 /// Sets the value of [error][crate::model::BatchRecognizeFileResult::error].
6604 ///
6605 /// # Example
6606 /// ```ignore,no_run
6607 /// # use google_cloud_speech_v2::model::BatchRecognizeFileResult;
6608 /// use google_cloud_rpc::model::Status;
6609 /// let x = BatchRecognizeFileResult::new().set_error(Status::default()/* use setters */);
6610 /// ```
6611 pub fn set_error<T>(mut self, v: T) -> Self
6612 where
6613 T: std::convert::Into<google_cloud_rpc::model::Status>,
6614 {
6615 self.error = std::option::Option::Some(v.into());
6616 self
6617 }
6618
6619 /// Sets or clears the value of [error][crate::model::BatchRecognizeFileResult::error].
6620 ///
6621 /// # Example
6622 /// ```ignore,no_run
6623 /// # use google_cloud_speech_v2::model::BatchRecognizeFileResult;
6624 /// use google_cloud_rpc::model::Status;
6625 /// let x = BatchRecognizeFileResult::new().set_or_clear_error(Some(Status::default()/* use setters */));
6626 /// let x = BatchRecognizeFileResult::new().set_or_clear_error(None::<Status>);
6627 /// ```
6628 pub fn set_or_clear_error<T>(mut self, v: std::option::Option<T>) -> Self
6629 where
6630 T: std::convert::Into<google_cloud_rpc::model::Status>,
6631 {
6632 self.error = v.map(|x| x.into());
6633 self
6634 }
6635
6636 /// Sets the value of [metadata][crate::model::BatchRecognizeFileResult::metadata].
6637 ///
6638 /// # Example
6639 /// ```ignore,no_run
6640 /// # use google_cloud_speech_v2::model::BatchRecognizeFileResult;
6641 /// use google_cloud_speech_v2::model::RecognitionResponseMetadata;
6642 /// let x = BatchRecognizeFileResult::new().set_metadata(RecognitionResponseMetadata::default()/* use setters */);
6643 /// ```
6644 pub fn set_metadata<T>(mut self, v: T) -> Self
6645 where
6646 T: std::convert::Into<crate::model::RecognitionResponseMetadata>,
6647 {
6648 self.metadata = std::option::Option::Some(v.into());
6649 self
6650 }
6651
6652 /// Sets or clears the value of [metadata][crate::model::BatchRecognizeFileResult::metadata].
6653 ///
6654 /// # Example
6655 /// ```ignore,no_run
6656 /// # use google_cloud_speech_v2::model::BatchRecognizeFileResult;
6657 /// use google_cloud_speech_v2::model::RecognitionResponseMetadata;
6658 /// let x = BatchRecognizeFileResult::new().set_or_clear_metadata(Some(RecognitionResponseMetadata::default()/* use setters */));
6659 /// let x = BatchRecognizeFileResult::new().set_or_clear_metadata(None::<RecognitionResponseMetadata>);
6660 /// ```
6661 pub fn set_or_clear_metadata<T>(mut self, v: std::option::Option<T>) -> Self
6662 where
6663 T: std::convert::Into<crate::model::RecognitionResponseMetadata>,
6664 {
6665 self.metadata = v.map(|x| x.into());
6666 self
6667 }
6668
6669 /// Sets the value of [uri][crate::model::BatchRecognizeFileResult::uri].
6670 ///
6671 /// # Example
6672 /// ```ignore,no_run
6673 /// # use google_cloud_speech_v2::model::BatchRecognizeFileResult;
6674 /// let x = BatchRecognizeFileResult::new().set_uri("example");
6675 /// ```
6676 #[deprecated]
6677 pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6678 self.uri = v.into();
6679 self
6680 }
6681
6682 /// Sets the value of [transcript][crate::model::BatchRecognizeFileResult::transcript].
6683 ///
6684 /// # Example
6685 /// ```ignore,no_run
6686 /// # use google_cloud_speech_v2::model::BatchRecognizeFileResult;
6687 /// use google_cloud_speech_v2::model::BatchRecognizeResults;
6688 /// let x = BatchRecognizeFileResult::new().set_transcript(BatchRecognizeResults::default()/* use setters */);
6689 /// ```
6690 #[deprecated]
6691 pub fn set_transcript<T>(mut self, v: T) -> Self
6692 where
6693 T: std::convert::Into<crate::model::BatchRecognizeResults>,
6694 {
6695 self.transcript = std::option::Option::Some(v.into());
6696 self
6697 }
6698
6699 /// Sets or clears the value of [transcript][crate::model::BatchRecognizeFileResult::transcript].
6700 ///
6701 /// # Example
6702 /// ```ignore,no_run
6703 /// # use google_cloud_speech_v2::model::BatchRecognizeFileResult;
6704 /// use google_cloud_speech_v2::model::BatchRecognizeResults;
6705 /// let x = BatchRecognizeFileResult::new().set_or_clear_transcript(Some(BatchRecognizeResults::default()/* use setters */));
6706 /// let x = BatchRecognizeFileResult::new().set_or_clear_transcript(None::<BatchRecognizeResults>);
6707 /// ```
6708 #[deprecated]
6709 pub fn set_or_clear_transcript<T>(mut self, v: std::option::Option<T>) -> Self
6710 where
6711 T: std::convert::Into<crate::model::BatchRecognizeResults>,
6712 {
6713 self.transcript = v.map(|x| x.into());
6714 self
6715 }
6716
6717 /// Sets the value of [result][crate::model::BatchRecognizeFileResult::result].
6718 ///
6719 /// Note that all the setters affecting `result` are mutually
6720 /// exclusive.
6721 ///
6722 /// # Example
6723 /// ```ignore,no_run
6724 /// # use google_cloud_speech_v2::model::BatchRecognizeFileResult;
6725 /// use google_cloud_speech_v2::model::CloudStorageResult;
6726 /// let x = BatchRecognizeFileResult::new().set_result(Some(
6727 /// google_cloud_speech_v2::model::batch_recognize_file_result::Result::CloudStorageResult(CloudStorageResult::default().into())));
6728 /// ```
6729 pub fn set_result<
6730 T: std::convert::Into<std::option::Option<crate::model::batch_recognize_file_result::Result>>,
6731 >(
6732 mut self,
6733 v: T,
6734 ) -> Self {
6735 self.result = v.into();
6736 self
6737 }
6738
6739 /// The value of [result][crate::model::BatchRecognizeFileResult::result]
6740 /// if it holds a `CloudStorageResult`, `None` if the field is not set or
6741 /// holds a different branch.
6742 pub fn cloud_storage_result(
6743 &self,
6744 ) -> std::option::Option<&std::boxed::Box<crate::model::CloudStorageResult>> {
6745 #[allow(unreachable_patterns)]
6746 self.result.as_ref().and_then(|v| match v {
6747 crate::model::batch_recognize_file_result::Result::CloudStorageResult(v) => {
6748 std::option::Option::Some(v)
6749 }
6750 _ => std::option::Option::None,
6751 })
6752 }
6753
6754 /// Sets the value of [result][crate::model::BatchRecognizeFileResult::result]
6755 /// to hold a `CloudStorageResult`.
6756 ///
6757 /// Note that all the setters affecting `result` are
6758 /// mutually exclusive.
6759 ///
6760 /// # Example
6761 /// ```ignore,no_run
6762 /// # use google_cloud_speech_v2::model::BatchRecognizeFileResult;
6763 /// use google_cloud_speech_v2::model::CloudStorageResult;
6764 /// let x = BatchRecognizeFileResult::new().set_cloud_storage_result(CloudStorageResult::default()/* use setters */);
6765 /// assert!(x.cloud_storage_result().is_some());
6766 /// assert!(x.inline_result().is_none());
6767 /// ```
6768 pub fn set_cloud_storage_result<
6769 T: std::convert::Into<std::boxed::Box<crate::model::CloudStorageResult>>,
6770 >(
6771 mut self,
6772 v: T,
6773 ) -> Self {
6774 self.result = std::option::Option::Some(
6775 crate::model::batch_recognize_file_result::Result::CloudStorageResult(v.into()),
6776 );
6777 self
6778 }
6779
6780 /// The value of [result][crate::model::BatchRecognizeFileResult::result]
6781 /// if it holds a `InlineResult`, `None` if the field is not set or
6782 /// holds a different branch.
6783 pub fn inline_result(
6784 &self,
6785 ) -> std::option::Option<&std::boxed::Box<crate::model::InlineResult>> {
6786 #[allow(unreachable_patterns)]
6787 self.result.as_ref().and_then(|v| match v {
6788 crate::model::batch_recognize_file_result::Result::InlineResult(v) => {
6789 std::option::Option::Some(v)
6790 }
6791 _ => std::option::Option::None,
6792 })
6793 }
6794
6795 /// Sets the value of [result][crate::model::BatchRecognizeFileResult::result]
6796 /// to hold a `InlineResult`.
6797 ///
6798 /// Note that all the setters affecting `result` are
6799 /// mutually exclusive.
6800 ///
6801 /// # Example
6802 /// ```ignore,no_run
6803 /// # use google_cloud_speech_v2::model::BatchRecognizeFileResult;
6804 /// use google_cloud_speech_v2::model::InlineResult;
6805 /// let x = BatchRecognizeFileResult::new().set_inline_result(InlineResult::default()/* use setters */);
6806 /// assert!(x.inline_result().is_some());
6807 /// assert!(x.cloud_storage_result().is_none());
6808 /// ```
6809 pub fn set_inline_result<T: std::convert::Into<std::boxed::Box<crate::model::InlineResult>>>(
6810 mut self,
6811 v: T,
6812 ) -> Self {
6813 self.result = std::option::Option::Some(
6814 crate::model::batch_recognize_file_result::Result::InlineResult(v.into()),
6815 );
6816 self
6817 }
6818}
6819
6820impl wkt::message::Message for BatchRecognizeFileResult {
6821 fn typename() -> &'static str {
6822 "type.googleapis.com/google.cloud.speech.v2.BatchRecognizeFileResult"
6823 }
6824}
6825
6826/// Defines additional types related to [BatchRecognizeFileResult].
6827pub mod batch_recognize_file_result {
6828 #[allow(unused_imports)]
6829 use super::*;
6830
6831 #[allow(missing_docs)]
6832 #[derive(Clone, Debug, PartialEq)]
6833 #[non_exhaustive]
6834 pub enum Result {
6835 /// Recognition results written to Cloud Storage. This is
6836 /// populated only when
6837 /// [GcsOutputConfig][google.cloud.speech.v2.GcsOutputConfig] is set in
6838 /// the
6839 /// [RecognitionOutputConfig][[google.cloud.speech.v2.RecognitionOutputConfig].
6840 ///
6841 /// [google.cloud.speech.v2.GcsOutputConfig]: crate::model::GcsOutputConfig
6842 CloudStorageResult(std::boxed::Box<crate::model::CloudStorageResult>),
6843 /// Recognition results. This is populated only when
6844 /// [InlineOutputConfig][google.cloud.speech.v2.InlineOutputConfig] is set in
6845 /// the
6846 /// [RecognitionOutputConfig][[google.cloud.speech.v2.RecognitionOutputConfig].
6847 ///
6848 /// [google.cloud.speech.v2.InlineOutputConfig]: crate::model::InlineOutputConfig
6849 InlineResult(std::boxed::Box<crate::model::InlineResult>),
6850 }
6851}
6852
6853/// Metadata about transcription for a single file (for example, progress
6854/// percent).
6855#[derive(Clone, Default, PartialEq)]
6856#[non_exhaustive]
6857pub struct BatchRecognizeTranscriptionMetadata {
6858 /// How much of the file has been transcribed so far.
6859 pub progress_percent: i32,
6860
6861 /// Error if one was encountered.
6862 pub error: std::option::Option<google_cloud_rpc::model::Status>,
6863
6864 /// The Cloud Storage URI to which recognition results will be written.
6865 pub uri: std::string::String,
6866
6867 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6868}
6869
6870impl BatchRecognizeTranscriptionMetadata {
6871 /// Creates a new default instance.
6872 pub fn new() -> Self {
6873 std::default::Default::default()
6874 }
6875
6876 /// Sets the value of [progress_percent][crate::model::BatchRecognizeTranscriptionMetadata::progress_percent].
6877 ///
6878 /// # Example
6879 /// ```ignore,no_run
6880 /// # use google_cloud_speech_v2::model::BatchRecognizeTranscriptionMetadata;
6881 /// let x = BatchRecognizeTranscriptionMetadata::new().set_progress_percent(42);
6882 /// ```
6883 pub fn set_progress_percent<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
6884 self.progress_percent = v.into();
6885 self
6886 }
6887
6888 /// Sets the value of [error][crate::model::BatchRecognizeTranscriptionMetadata::error].
6889 ///
6890 /// # Example
6891 /// ```ignore,no_run
6892 /// # use google_cloud_speech_v2::model::BatchRecognizeTranscriptionMetadata;
6893 /// use google_cloud_rpc::model::Status;
6894 /// let x = BatchRecognizeTranscriptionMetadata::new().set_error(Status::default()/* use setters */);
6895 /// ```
6896 pub fn set_error<T>(mut self, v: T) -> Self
6897 where
6898 T: std::convert::Into<google_cloud_rpc::model::Status>,
6899 {
6900 self.error = std::option::Option::Some(v.into());
6901 self
6902 }
6903
6904 /// Sets or clears the value of [error][crate::model::BatchRecognizeTranscriptionMetadata::error].
6905 ///
6906 /// # Example
6907 /// ```ignore,no_run
6908 /// # use google_cloud_speech_v2::model::BatchRecognizeTranscriptionMetadata;
6909 /// use google_cloud_rpc::model::Status;
6910 /// let x = BatchRecognizeTranscriptionMetadata::new().set_or_clear_error(Some(Status::default()/* use setters */));
6911 /// let x = BatchRecognizeTranscriptionMetadata::new().set_or_clear_error(None::<Status>);
6912 /// ```
6913 pub fn set_or_clear_error<T>(mut self, v: std::option::Option<T>) -> Self
6914 where
6915 T: std::convert::Into<google_cloud_rpc::model::Status>,
6916 {
6917 self.error = v.map(|x| x.into());
6918 self
6919 }
6920
6921 /// Sets the value of [uri][crate::model::BatchRecognizeTranscriptionMetadata::uri].
6922 ///
6923 /// # Example
6924 /// ```ignore,no_run
6925 /// # use google_cloud_speech_v2::model::BatchRecognizeTranscriptionMetadata;
6926 /// let x = BatchRecognizeTranscriptionMetadata::new().set_uri("example");
6927 /// ```
6928 pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6929 self.uri = v.into();
6930 self
6931 }
6932}
6933
6934impl wkt::message::Message for BatchRecognizeTranscriptionMetadata {
6935 fn typename() -> &'static str {
6936 "type.googleapis.com/google.cloud.speech.v2.BatchRecognizeTranscriptionMetadata"
6937 }
6938}
6939
6940/// Operation metadata for
6941/// [BatchRecognize][google.cloud.speech.v2.Speech.BatchRecognize].
6942///
6943/// [google.cloud.speech.v2.Speech.BatchRecognize]: crate::client::Speech::batch_recognize
6944#[derive(Clone, Default, PartialEq)]
6945#[non_exhaustive]
6946pub struct BatchRecognizeMetadata {
6947 /// Map from provided filename to the transcription metadata for that file.
6948 pub transcription_metadata: std::collections::HashMap<
6949 std::string::String,
6950 crate::model::BatchRecognizeTranscriptionMetadata,
6951 >,
6952
6953 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6954}
6955
6956impl BatchRecognizeMetadata {
6957 /// Creates a new default instance.
6958 pub fn new() -> Self {
6959 std::default::Default::default()
6960 }
6961
6962 /// Sets the value of [transcription_metadata][crate::model::BatchRecognizeMetadata::transcription_metadata].
6963 ///
6964 /// # Example
6965 /// ```ignore,no_run
6966 /// # use google_cloud_speech_v2::model::BatchRecognizeMetadata;
6967 /// use google_cloud_speech_v2::model::BatchRecognizeTranscriptionMetadata;
6968 /// let x = BatchRecognizeMetadata::new().set_transcription_metadata([
6969 /// ("key0", BatchRecognizeTranscriptionMetadata::default()/* use setters */),
6970 /// ("key1", BatchRecognizeTranscriptionMetadata::default()/* use (different) setters */),
6971 /// ]);
6972 /// ```
6973 pub fn set_transcription_metadata<T, K, V>(mut self, v: T) -> Self
6974 where
6975 T: std::iter::IntoIterator<Item = (K, V)>,
6976 K: std::convert::Into<std::string::String>,
6977 V: std::convert::Into<crate::model::BatchRecognizeTranscriptionMetadata>,
6978 {
6979 use std::iter::Iterator;
6980 self.transcription_metadata = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
6981 self
6982 }
6983}
6984
6985impl wkt::message::Message for BatchRecognizeMetadata {
6986 fn typename() -> &'static str {
6987 "type.googleapis.com/google.cloud.speech.v2.BatchRecognizeMetadata"
6988 }
6989}
6990
6991/// Metadata about a single file in a batch for BatchRecognize.
6992#[derive(Clone, Default, PartialEq)]
6993#[non_exhaustive]
6994pub struct BatchRecognizeFileMetadata {
6995 /// Features and audio metadata to use for the Automatic Speech Recognition.
6996 /// This field in combination with the
6997 /// [config_mask][google.cloud.speech.v2.BatchRecognizeFileMetadata.config_mask]
6998 /// field can be used to override parts of the
6999 /// [default_recognition_config][google.cloud.speech.v2.Recognizer.default_recognition_config]
7000 /// of the Recognizer resource as well as the
7001 /// [config][google.cloud.speech.v2.BatchRecognizeRequest.config] at the
7002 /// request level.
7003 ///
7004 /// [google.cloud.speech.v2.BatchRecognizeFileMetadata.config_mask]: crate::model::BatchRecognizeFileMetadata::config_mask
7005 /// [google.cloud.speech.v2.BatchRecognizeRequest.config]: crate::model::BatchRecognizeRequest::config
7006 /// [google.cloud.speech.v2.Recognizer.default_recognition_config]: crate::model::Recognizer::default_recognition_config
7007 pub config: std::option::Option<crate::model::RecognitionConfig>,
7008
7009 /// The list of fields in
7010 /// [config][google.cloud.speech.v2.BatchRecognizeFileMetadata.config] that
7011 /// override the values in the
7012 /// [default_recognition_config][google.cloud.speech.v2.Recognizer.default_recognition_config]
7013 /// of the recognizer during this recognition request. If no mask is provided,
7014 /// all non-default valued fields in
7015 /// [config][google.cloud.speech.v2.BatchRecognizeFileMetadata.config] override
7016 /// the values in the recognizer for this recognition request. If a mask is
7017 /// provided, only the fields listed in the mask override the config in the
7018 /// recognizer for this recognition request. If a wildcard (`*`) is provided,
7019 /// [config][google.cloud.speech.v2.BatchRecognizeFileMetadata.config]
7020 /// completely overrides and replaces the config in the recognizer for this
7021 /// recognition request.
7022 ///
7023 /// [google.cloud.speech.v2.BatchRecognizeFileMetadata.config]: crate::model::BatchRecognizeFileMetadata::config
7024 /// [google.cloud.speech.v2.Recognizer.default_recognition_config]: crate::model::Recognizer::default_recognition_config
7025 pub config_mask: std::option::Option<wkt::FieldMask>,
7026
7027 /// The audio source, which is a Google Cloud Storage URI.
7028 pub audio_source: std::option::Option<crate::model::batch_recognize_file_metadata::AudioSource>,
7029
7030 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7031}
7032
7033impl BatchRecognizeFileMetadata {
7034 /// Creates a new default instance.
7035 pub fn new() -> Self {
7036 std::default::Default::default()
7037 }
7038
7039 /// Sets the value of [config][crate::model::BatchRecognizeFileMetadata::config].
7040 ///
7041 /// # Example
7042 /// ```ignore,no_run
7043 /// # use google_cloud_speech_v2::model::BatchRecognizeFileMetadata;
7044 /// use google_cloud_speech_v2::model::RecognitionConfig;
7045 /// let x = BatchRecognizeFileMetadata::new().set_config(RecognitionConfig::default()/* use setters */);
7046 /// ```
7047 pub fn set_config<T>(mut self, v: T) -> Self
7048 where
7049 T: std::convert::Into<crate::model::RecognitionConfig>,
7050 {
7051 self.config = std::option::Option::Some(v.into());
7052 self
7053 }
7054
7055 /// Sets or clears the value of [config][crate::model::BatchRecognizeFileMetadata::config].
7056 ///
7057 /// # Example
7058 /// ```ignore,no_run
7059 /// # use google_cloud_speech_v2::model::BatchRecognizeFileMetadata;
7060 /// use google_cloud_speech_v2::model::RecognitionConfig;
7061 /// let x = BatchRecognizeFileMetadata::new().set_or_clear_config(Some(RecognitionConfig::default()/* use setters */));
7062 /// let x = BatchRecognizeFileMetadata::new().set_or_clear_config(None::<RecognitionConfig>);
7063 /// ```
7064 pub fn set_or_clear_config<T>(mut self, v: std::option::Option<T>) -> Self
7065 where
7066 T: std::convert::Into<crate::model::RecognitionConfig>,
7067 {
7068 self.config = v.map(|x| x.into());
7069 self
7070 }
7071
7072 /// Sets the value of [config_mask][crate::model::BatchRecognizeFileMetadata::config_mask].
7073 ///
7074 /// # Example
7075 /// ```ignore,no_run
7076 /// # use google_cloud_speech_v2::model::BatchRecognizeFileMetadata;
7077 /// use wkt::FieldMask;
7078 /// let x = BatchRecognizeFileMetadata::new().set_config_mask(FieldMask::default()/* use setters */);
7079 /// ```
7080 pub fn set_config_mask<T>(mut self, v: T) -> Self
7081 where
7082 T: std::convert::Into<wkt::FieldMask>,
7083 {
7084 self.config_mask = std::option::Option::Some(v.into());
7085 self
7086 }
7087
7088 /// Sets or clears the value of [config_mask][crate::model::BatchRecognizeFileMetadata::config_mask].
7089 ///
7090 /// # Example
7091 /// ```ignore,no_run
7092 /// # use google_cloud_speech_v2::model::BatchRecognizeFileMetadata;
7093 /// use wkt::FieldMask;
7094 /// let x = BatchRecognizeFileMetadata::new().set_or_clear_config_mask(Some(FieldMask::default()/* use setters */));
7095 /// let x = BatchRecognizeFileMetadata::new().set_or_clear_config_mask(None::<FieldMask>);
7096 /// ```
7097 pub fn set_or_clear_config_mask<T>(mut self, v: std::option::Option<T>) -> Self
7098 where
7099 T: std::convert::Into<wkt::FieldMask>,
7100 {
7101 self.config_mask = v.map(|x| x.into());
7102 self
7103 }
7104
7105 /// Sets the value of [audio_source][crate::model::BatchRecognizeFileMetadata::audio_source].
7106 ///
7107 /// Note that all the setters affecting `audio_source` are mutually
7108 /// exclusive.
7109 ///
7110 /// # Example
7111 /// ```ignore,no_run
7112 /// # use google_cloud_speech_v2::model::BatchRecognizeFileMetadata;
7113 /// use google_cloud_speech_v2::model::batch_recognize_file_metadata::AudioSource;
7114 /// let x = BatchRecognizeFileMetadata::new().set_audio_source(Some(AudioSource::Uri("example".to_string())));
7115 /// ```
7116 pub fn set_audio_source<
7117 T: std::convert::Into<
7118 std::option::Option<crate::model::batch_recognize_file_metadata::AudioSource>,
7119 >,
7120 >(
7121 mut self,
7122 v: T,
7123 ) -> Self {
7124 self.audio_source = v.into();
7125 self
7126 }
7127
7128 /// The value of [audio_source][crate::model::BatchRecognizeFileMetadata::audio_source]
7129 /// if it holds a `Uri`, `None` if the field is not set or
7130 /// holds a different branch.
7131 pub fn uri(&self) -> std::option::Option<&std::string::String> {
7132 #[allow(unreachable_patterns)]
7133 self.audio_source.as_ref().and_then(|v| match v {
7134 crate::model::batch_recognize_file_metadata::AudioSource::Uri(v) => {
7135 std::option::Option::Some(v)
7136 }
7137 _ => std::option::Option::None,
7138 })
7139 }
7140
7141 /// Sets the value of [audio_source][crate::model::BatchRecognizeFileMetadata::audio_source]
7142 /// to hold a `Uri`.
7143 ///
7144 /// Note that all the setters affecting `audio_source` are
7145 /// mutually exclusive.
7146 ///
7147 /// # Example
7148 /// ```ignore,no_run
7149 /// # use google_cloud_speech_v2::model::BatchRecognizeFileMetadata;
7150 /// let x = BatchRecognizeFileMetadata::new().set_uri("example");
7151 /// assert!(x.uri().is_some());
7152 /// ```
7153 pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7154 self.audio_source = std::option::Option::Some(
7155 crate::model::batch_recognize_file_metadata::AudioSource::Uri(v.into()),
7156 );
7157 self
7158 }
7159}
7160
7161impl wkt::message::Message for BatchRecognizeFileMetadata {
7162 fn typename() -> &'static str {
7163 "type.googleapis.com/google.cloud.speech.v2.BatchRecognizeFileMetadata"
7164 }
7165}
7166
7167/// Defines additional types related to [BatchRecognizeFileMetadata].
7168pub mod batch_recognize_file_metadata {
7169 #[allow(unused_imports)]
7170 use super::*;
7171
7172 /// The audio source, which is a Google Cloud Storage URI.
7173 #[derive(Clone, Debug, PartialEq)]
7174 #[non_exhaustive]
7175 pub enum AudioSource {
7176 /// Cloud Storage URI for the audio file.
7177 Uri(std::string::String),
7178 }
7179}
7180
7181/// A streaming speech recognition result corresponding to a portion of the audio
7182/// that is currently being processed.
7183#[derive(Clone, Default, PartialEq)]
7184#[non_exhaustive]
7185pub struct StreamingRecognitionResult {
7186 /// May contain one or more recognition hypotheses. These alternatives are
7187 /// ordered in terms of accuracy, with the top (first) alternative being the
7188 /// most probable, as ranked by the recognizer.
7189 pub alternatives: std::vec::Vec<crate::model::SpeechRecognitionAlternative>,
7190
7191 /// If `false`, this
7192 /// [StreamingRecognitionResult][google.cloud.speech.v2.StreamingRecognitionResult]
7193 /// represents an interim result that may change. If `true`, this is the final
7194 /// time the speech service will return this particular
7195 /// [StreamingRecognitionResult][google.cloud.speech.v2.StreamingRecognitionResult],
7196 /// the recognizer will not return any further hypotheses for this portion of
7197 /// the transcript and corresponding audio.
7198 ///
7199 /// [google.cloud.speech.v2.StreamingRecognitionResult]: crate::model::StreamingRecognitionResult
7200 pub is_final: bool,
7201
7202 /// An estimate of the likelihood that the recognizer will not change its guess
7203 /// about this interim result. Values range from 0.0 (completely unstable)
7204 /// to 1.0 (completely stable). This field is only provided for interim results
7205 /// ([is_final][google.cloud.speech.v2.StreamingRecognitionResult.is_final]=`false`).
7206 /// The default of 0.0 is a sentinel value indicating `stability` was not set.
7207 ///
7208 /// [google.cloud.speech.v2.StreamingRecognitionResult.is_final]: crate::model::StreamingRecognitionResult::is_final
7209 pub stability: f32,
7210
7211 /// Time offset of the end of this result relative to the beginning of the
7212 /// audio.
7213 pub result_end_offset: std::option::Option<wkt::Duration>,
7214
7215 /// For multi-channel audio, this is the channel number corresponding to the
7216 /// recognized result for the audio from that channel.
7217 /// For
7218 /// `audio_channel_count` = `N`, its output values can range from `1` to `N`.
7219 pub channel_tag: i32,
7220
7221 /// Output only. The [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt)
7222 /// language tag of the language in this result. This language code was
7223 /// detected to have the most likelihood of being spoken in the audio.
7224 pub language_code: std::string::String,
7225
7226 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7227}
7228
7229impl StreamingRecognitionResult {
7230 /// Creates a new default instance.
7231 pub fn new() -> Self {
7232 std::default::Default::default()
7233 }
7234
7235 /// Sets the value of [alternatives][crate::model::StreamingRecognitionResult::alternatives].
7236 ///
7237 /// # Example
7238 /// ```ignore,no_run
7239 /// # use google_cloud_speech_v2::model::StreamingRecognitionResult;
7240 /// use google_cloud_speech_v2::model::SpeechRecognitionAlternative;
7241 /// let x = StreamingRecognitionResult::new()
7242 /// .set_alternatives([
7243 /// SpeechRecognitionAlternative::default()/* use setters */,
7244 /// SpeechRecognitionAlternative::default()/* use (different) setters */,
7245 /// ]);
7246 /// ```
7247 pub fn set_alternatives<T, V>(mut self, v: T) -> Self
7248 where
7249 T: std::iter::IntoIterator<Item = V>,
7250 V: std::convert::Into<crate::model::SpeechRecognitionAlternative>,
7251 {
7252 use std::iter::Iterator;
7253 self.alternatives = v.into_iter().map(|i| i.into()).collect();
7254 self
7255 }
7256
7257 /// Sets the value of [is_final][crate::model::StreamingRecognitionResult::is_final].
7258 ///
7259 /// # Example
7260 /// ```ignore,no_run
7261 /// # use google_cloud_speech_v2::model::StreamingRecognitionResult;
7262 /// let x = StreamingRecognitionResult::new().set_is_final(true);
7263 /// ```
7264 pub fn set_is_final<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
7265 self.is_final = v.into();
7266 self
7267 }
7268
7269 /// Sets the value of [stability][crate::model::StreamingRecognitionResult::stability].
7270 ///
7271 /// # Example
7272 /// ```ignore,no_run
7273 /// # use google_cloud_speech_v2::model::StreamingRecognitionResult;
7274 /// let x = StreamingRecognitionResult::new().set_stability(42.0);
7275 /// ```
7276 pub fn set_stability<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
7277 self.stability = v.into();
7278 self
7279 }
7280
7281 /// Sets the value of [result_end_offset][crate::model::StreamingRecognitionResult::result_end_offset].
7282 ///
7283 /// # Example
7284 /// ```ignore,no_run
7285 /// # use google_cloud_speech_v2::model::StreamingRecognitionResult;
7286 /// use wkt::Duration;
7287 /// let x = StreamingRecognitionResult::new().set_result_end_offset(Duration::default()/* use setters */);
7288 /// ```
7289 pub fn set_result_end_offset<T>(mut self, v: T) -> Self
7290 where
7291 T: std::convert::Into<wkt::Duration>,
7292 {
7293 self.result_end_offset = std::option::Option::Some(v.into());
7294 self
7295 }
7296
7297 /// Sets or clears the value of [result_end_offset][crate::model::StreamingRecognitionResult::result_end_offset].
7298 ///
7299 /// # Example
7300 /// ```ignore,no_run
7301 /// # use google_cloud_speech_v2::model::StreamingRecognitionResult;
7302 /// use wkt::Duration;
7303 /// let x = StreamingRecognitionResult::new().set_or_clear_result_end_offset(Some(Duration::default()/* use setters */));
7304 /// let x = StreamingRecognitionResult::new().set_or_clear_result_end_offset(None::<Duration>);
7305 /// ```
7306 pub fn set_or_clear_result_end_offset<T>(mut self, v: std::option::Option<T>) -> Self
7307 where
7308 T: std::convert::Into<wkt::Duration>,
7309 {
7310 self.result_end_offset = v.map(|x| x.into());
7311 self
7312 }
7313
7314 /// Sets the value of [channel_tag][crate::model::StreamingRecognitionResult::channel_tag].
7315 ///
7316 /// # Example
7317 /// ```ignore,no_run
7318 /// # use google_cloud_speech_v2::model::StreamingRecognitionResult;
7319 /// let x = StreamingRecognitionResult::new().set_channel_tag(42);
7320 /// ```
7321 pub fn set_channel_tag<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
7322 self.channel_tag = v.into();
7323 self
7324 }
7325
7326 /// Sets the value of [language_code][crate::model::StreamingRecognitionResult::language_code].
7327 ///
7328 /// # Example
7329 /// ```ignore,no_run
7330 /// # use google_cloud_speech_v2::model::StreamingRecognitionResult;
7331 /// let x = StreamingRecognitionResult::new().set_language_code("example");
7332 /// ```
7333 pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7334 self.language_code = v.into();
7335 self
7336 }
7337}
7338
7339impl wkt::message::Message for StreamingRecognitionResult {
7340 fn typename() -> &'static str {
7341 "type.googleapis.com/google.cloud.speech.v2.StreamingRecognitionResult"
7342 }
7343}
7344
7345/// `StreamingRecognizeResponse` is the only message returned to the client by
7346/// `StreamingRecognize`. A series of zero or more `StreamingRecognizeResponse`
7347/// messages are streamed back to the client. If there is no recognizable
7348/// audio then no messages are streamed back to the client.
7349///
7350/// Here are some examples of `StreamingRecognizeResponse`s that might
7351/// be returned while processing audio:
7352///
7353/// 1. results { alternatives { transcript: "tube" } stability: 0.01 }
7354///
7355/// 1. results { alternatives { transcript: "to be a" } stability: 0.01 }
7356///
7357/// 1. results { alternatives { transcript: "to be" } stability: 0.9 }
7358/// results { alternatives { transcript: " or not to be" } stability: 0.01 }
7359///
7360/// 1. results { alternatives { transcript: "to be or not to be"
7361/// confidence: 0.92 }
7362/// alternatives { transcript: "to bee or not to bee" }
7363/// is_final: true }
7364///
7365/// 1. results { alternatives { transcript: " that's" } stability: 0.01 }
7366///
7367/// 1. results { alternatives { transcript: " that is" } stability: 0.9 }
7368/// results { alternatives { transcript: " the question" } stability: 0.01 }
7369///
7370/// 1. results { alternatives { transcript: " that is the question"
7371/// confidence: 0.98 }
7372/// alternatives { transcript: " that was the question" }
7373/// is_final: true }
7374///
7375///
7376/// Notes:
7377///
7378/// - Only two of the above responses #4 and #7 contain final results; they are
7379/// indicated by `is_final: true`. Concatenating these together generates the
7380/// full transcript: "to be or not to be that is the question".
7381///
7382/// - The others contain interim `results`. #3 and #6 contain two interim
7383/// `results`: the first portion has a high stability and is less likely to
7384/// change; the second portion has a low stability and is very likely to
7385/// change. A UI designer might choose to show only high stability `results`.
7386///
7387/// - The specific `stability` and `confidence` values shown above are only for
7388/// illustrative purposes. Actual values may vary.
7389///
7390/// - In each response, only one of these fields will be set:
7391/// `error`,
7392/// `speech_event_type`, or
7393/// one or more (repeated) `results`.
7394///
7395#[derive(Clone, Default, PartialEq)]
7396#[non_exhaustive]
7397pub struct StreamingRecognizeResponse {
7398 /// This repeated list contains zero or more results that
7399 /// correspond to consecutive portions of the audio currently being processed.
7400 /// It contains zero or one
7401 /// [is_final][google.cloud.speech.v2.StreamingRecognitionResult.is_final]=`true`
7402 /// result (the newly settled portion), followed by zero or more
7403 /// [is_final][google.cloud.speech.v2.StreamingRecognitionResult.is_final]=`false`
7404 /// results (the interim results).
7405 ///
7406 /// [google.cloud.speech.v2.StreamingRecognitionResult.is_final]: crate::model::StreamingRecognitionResult::is_final
7407 pub results: std::vec::Vec<crate::model::StreamingRecognitionResult>,
7408
7409 /// Indicates the type of speech event.
7410 pub speech_event_type: crate::model::streaming_recognize_response::SpeechEventType,
7411
7412 /// Time offset between the beginning of the audio and event emission.
7413 pub speech_event_offset: std::option::Option<wkt::Duration>,
7414
7415 /// Metadata about the recognition.
7416 pub metadata: std::option::Option<crate::model::RecognitionResponseMetadata>,
7417
7418 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7419}
7420
7421impl StreamingRecognizeResponse {
7422 /// Creates a new default instance.
7423 pub fn new() -> Self {
7424 std::default::Default::default()
7425 }
7426
7427 /// Sets the value of [results][crate::model::StreamingRecognizeResponse::results].
7428 ///
7429 /// # Example
7430 /// ```ignore,no_run
7431 /// # use google_cloud_speech_v2::model::StreamingRecognizeResponse;
7432 /// use google_cloud_speech_v2::model::StreamingRecognitionResult;
7433 /// let x = StreamingRecognizeResponse::new()
7434 /// .set_results([
7435 /// StreamingRecognitionResult::default()/* use setters */,
7436 /// StreamingRecognitionResult::default()/* use (different) setters */,
7437 /// ]);
7438 /// ```
7439 pub fn set_results<T, V>(mut self, v: T) -> Self
7440 where
7441 T: std::iter::IntoIterator<Item = V>,
7442 V: std::convert::Into<crate::model::StreamingRecognitionResult>,
7443 {
7444 use std::iter::Iterator;
7445 self.results = v.into_iter().map(|i| i.into()).collect();
7446 self
7447 }
7448
7449 /// Sets the value of [speech_event_type][crate::model::StreamingRecognizeResponse::speech_event_type].
7450 ///
7451 /// # Example
7452 /// ```ignore,no_run
7453 /// # use google_cloud_speech_v2::model::StreamingRecognizeResponse;
7454 /// use google_cloud_speech_v2::model::streaming_recognize_response::SpeechEventType;
7455 /// let x0 = StreamingRecognizeResponse::new().set_speech_event_type(SpeechEventType::EndOfSingleUtterance);
7456 /// let x1 = StreamingRecognizeResponse::new().set_speech_event_type(SpeechEventType::SpeechActivityBegin);
7457 /// let x2 = StreamingRecognizeResponse::new().set_speech_event_type(SpeechEventType::SpeechActivityEnd);
7458 /// ```
7459 pub fn set_speech_event_type<
7460 T: std::convert::Into<crate::model::streaming_recognize_response::SpeechEventType>,
7461 >(
7462 mut self,
7463 v: T,
7464 ) -> Self {
7465 self.speech_event_type = v.into();
7466 self
7467 }
7468
7469 /// Sets the value of [speech_event_offset][crate::model::StreamingRecognizeResponse::speech_event_offset].
7470 ///
7471 /// # Example
7472 /// ```ignore,no_run
7473 /// # use google_cloud_speech_v2::model::StreamingRecognizeResponse;
7474 /// use wkt::Duration;
7475 /// let x = StreamingRecognizeResponse::new().set_speech_event_offset(Duration::default()/* use setters */);
7476 /// ```
7477 pub fn set_speech_event_offset<T>(mut self, v: T) -> Self
7478 where
7479 T: std::convert::Into<wkt::Duration>,
7480 {
7481 self.speech_event_offset = std::option::Option::Some(v.into());
7482 self
7483 }
7484
7485 /// Sets or clears the value of [speech_event_offset][crate::model::StreamingRecognizeResponse::speech_event_offset].
7486 ///
7487 /// # Example
7488 /// ```ignore,no_run
7489 /// # use google_cloud_speech_v2::model::StreamingRecognizeResponse;
7490 /// use wkt::Duration;
7491 /// let x = StreamingRecognizeResponse::new().set_or_clear_speech_event_offset(Some(Duration::default()/* use setters */));
7492 /// let x = StreamingRecognizeResponse::new().set_or_clear_speech_event_offset(None::<Duration>);
7493 /// ```
7494 pub fn set_or_clear_speech_event_offset<T>(mut self, v: std::option::Option<T>) -> Self
7495 where
7496 T: std::convert::Into<wkt::Duration>,
7497 {
7498 self.speech_event_offset = v.map(|x| x.into());
7499 self
7500 }
7501
7502 /// Sets the value of [metadata][crate::model::StreamingRecognizeResponse::metadata].
7503 ///
7504 /// # Example
7505 /// ```ignore,no_run
7506 /// # use google_cloud_speech_v2::model::StreamingRecognizeResponse;
7507 /// use google_cloud_speech_v2::model::RecognitionResponseMetadata;
7508 /// let x = StreamingRecognizeResponse::new().set_metadata(RecognitionResponseMetadata::default()/* use setters */);
7509 /// ```
7510 pub fn set_metadata<T>(mut self, v: T) -> Self
7511 where
7512 T: std::convert::Into<crate::model::RecognitionResponseMetadata>,
7513 {
7514 self.metadata = std::option::Option::Some(v.into());
7515 self
7516 }
7517
7518 /// Sets or clears the value of [metadata][crate::model::StreamingRecognizeResponse::metadata].
7519 ///
7520 /// # Example
7521 /// ```ignore,no_run
7522 /// # use google_cloud_speech_v2::model::StreamingRecognizeResponse;
7523 /// use google_cloud_speech_v2::model::RecognitionResponseMetadata;
7524 /// let x = StreamingRecognizeResponse::new().set_or_clear_metadata(Some(RecognitionResponseMetadata::default()/* use setters */));
7525 /// let x = StreamingRecognizeResponse::new().set_or_clear_metadata(None::<RecognitionResponseMetadata>);
7526 /// ```
7527 pub fn set_or_clear_metadata<T>(mut self, v: std::option::Option<T>) -> Self
7528 where
7529 T: std::convert::Into<crate::model::RecognitionResponseMetadata>,
7530 {
7531 self.metadata = v.map(|x| x.into());
7532 self
7533 }
7534}
7535
7536impl wkt::message::Message for StreamingRecognizeResponse {
7537 fn typename() -> &'static str {
7538 "type.googleapis.com/google.cloud.speech.v2.StreamingRecognizeResponse"
7539 }
7540}
7541
7542/// Defines additional types related to [StreamingRecognizeResponse].
7543pub mod streaming_recognize_response {
7544 #[allow(unused_imports)]
7545 use super::*;
7546
7547 /// Indicates the type of speech event.
7548 ///
7549 /// # Working with unknown values
7550 ///
7551 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
7552 /// additional enum variants at any time. Adding new variants is not considered
7553 /// a breaking change. Applications should write their code in anticipation of:
7554 ///
7555 /// - New values appearing in future releases of the client library, **and**
7556 /// - New values received dynamically, without application changes.
7557 ///
7558 /// Please consult the [Working with enums] section in the user guide for some
7559 /// guidelines.
7560 ///
7561 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
7562 #[derive(Clone, Debug, PartialEq)]
7563 #[non_exhaustive]
7564 pub enum SpeechEventType {
7565 /// No speech event specified.
7566 Unspecified,
7567 /// This event indicates that the server has detected the end of the user's
7568 /// speech utterance and expects no additional speech. Therefore, the server
7569 /// will not process additional audio and will close the gRPC bidirectional
7570 /// stream. This event is only sent if there was a force cutoff due to
7571 /// silence being detected early. This event is only available through the
7572 /// `latest_short` [model][google.cloud.speech.v2.Recognizer.model].
7573 ///
7574 /// [google.cloud.speech.v2.Recognizer.model]: crate::model::Recognizer::model
7575 EndOfSingleUtterance,
7576 /// This event indicates that the server has detected the beginning of human
7577 /// voice activity in the stream. This event can be returned multiple times
7578 /// if speech starts and stops repeatedly throughout the stream. This event
7579 /// is only sent if `voice_activity_events` is set to true.
7580 SpeechActivityBegin,
7581 /// This event indicates that the server has detected the end of human voice
7582 /// activity in the stream. This event can be returned multiple times if
7583 /// speech starts and stops repeatedly throughout the stream. This event is
7584 /// only sent if `voice_activity_events` is set to true.
7585 SpeechActivityEnd,
7586 /// If set, the enum was initialized with an unknown value.
7587 ///
7588 /// Applications can examine the value using [SpeechEventType::value] or
7589 /// [SpeechEventType::name].
7590 UnknownValue(speech_event_type::UnknownValue),
7591 }
7592
7593 #[doc(hidden)]
7594 pub mod speech_event_type {
7595 #[allow(unused_imports)]
7596 use super::*;
7597 #[derive(Clone, Debug, PartialEq)]
7598 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
7599 }
7600
7601 impl SpeechEventType {
7602 /// Gets the enum value.
7603 ///
7604 /// Returns `None` if the enum contains an unknown value deserialized from
7605 /// the string representation of enums.
7606 pub fn value(&self) -> std::option::Option<i32> {
7607 match self {
7608 Self::Unspecified => std::option::Option::Some(0),
7609 Self::EndOfSingleUtterance => std::option::Option::Some(1),
7610 Self::SpeechActivityBegin => std::option::Option::Some(2),
7611 Self::SpeechActivityEnd => std::option::Option::Some(3),
7612 Self::UnknownValue(u) => u.0.value(),
7613 }
7614 }
7615
7616 /// Gets the enum value as a string.
7617 ///
7618 /// Returns `None` if the enum contains an unknown value deserialized from
7619 /// the integer representation of enums.
7620 pub fn name(&self) -> std::option::Option<&str> {
7621 match self {
7622 Self::Unspecified => std::option::Option::Some("SPEECH_EVENT_TYPE_UNSPECIFIED"),
7623 Self::EndOfSingleUtterance => std::option::Option::Some("END_OF_SINGLE_UTTERANCE"),
7624 Self::SpeechActivityBegin => std::option::Option::Some("SPEECH_ACTIVITY_BEGIN"),
7625 Self::SpeechActivityEnd => std::option::Option::Some("SPEECH_ACTIVITY_END"),
7626 Self::UnknownValue(u) => u.0.name(),
7627 }
7628 }
7629 }
7630
7631 impl std::default::Default for SpeechEventType {
7632 fn default() -> Self {
7633 use std::convert::From;
7634 Self::from(0)
7635 }
7636 }
7637
7638 impl std::fmt::Display for SpeechEventType {
7639 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
7640 wkt::internal::display_enum(f, self.name(), self.value())
7641 }
7642 }
7643
7644 impl std::convert::From<i32> for SpeechEventType {
7645 fn from(value: i32) -> Self {
7646 match value {
7647 0 => Self::Unspecified,
7648 1 => Self::EndOfSingleUtterance,
7649 2 => Self::SpeechActivityBegin,
7650 3 => Self::SpeechActivityEnd,
7651 _ => Self::UnknownValue(speech_event_type::UnknownValue(
7652 wkt::internal::UnknownEnumValue::Integer(value),
7653 )),
7654 }
7655 }
7656 }
7657
7658 impl std::convert::From<&str> for SpeechEventType {
7659 fn from(value: &str) -> Self {
7660 use std::string::ToString;
7661 match value {
7662 "SPEECH_EVENT_TYPE_UNSPECIFIED" => Self::Unspecified,
7663 "END_OF_SINGLE_UTTERANCE" => Self::EndOfSingleUtterance,
7664 "SPEECH_ACTIVITY_BEGIN" => Self::SpeechActivityBegin,
7665 "SPEECH_ACTIVITY_END" => Self::SpeechActivityEnd,
7666 _ => Self::UnknownValue(speech_event_type::UnknownValue(
7667 wkt::internal::UnknownEnumValue::String(value.to_string()),
7668 )),
7669 }
7670 }
7671 }
7672
7673 impl serde::ser::Serialize for SpeechEventType {
7674 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7675 where
7676 S: serde::Serializer,
7677 {
7678 match self {
7679 Self::Unspecified => serializer.serialize_i32(0),
7680 Self::EndOfSingleUtterance => serializer.serialize_i32(1),
7681 Self::SpeechActivityBegin => serializer.serialize_i32(2),
7682 Self::SpeechActivityEnd => serializer.serialize_i32(3),
7683 Self::UnknownValue(u) => u.0.serialize(serializer),
7684 }
7685 }
7686 }
7687
7688 impl<'de> serde::de::Deserialize<'de> for SpeechEventType {
7689 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7690 where
7691 D: serde::Deserializer<'de>,
7692 {
7693 deserializer.deserialize_any(wkt::internal::EnumVisitor::<SpeechEventType>::new(
7694 ".google.cloud.speech.v2.StreamingRecognizeResponse.SpeechEventType",
7695 ))
7696 }
7697 }
7698}
7699
7700/// Message representing the config for the Speech-to-Text API. This includes an
7701/// optional [KMS key](https://cloud.google.com/kms/docs/resource-hierarchy#keys)
7702/// with which incoming data will be encrypted.
7703#[derive(Clone, Default, PartialEq)]
7704#[non_exhaustive]
7705pub struct Config {
7706 /// Output only. Identifier. The name of the config resource. There is exactly
7707 /// one config resource per project per location. The expected format is
7708 /// `projects/{project}/locations/{location}/config`.
7709 pub name: std::string::String,
7710
7711 /// Optional. An optional [KMS key
7712 /// name](https://cloud.google.com/kms/docs/resource-hierarchy#keys) that if
7713 /// present, will be used to encrypt Speech-to-Text resources at-rest. Updating
7714 /// this key will not encrypt existing resources using this key; only new
7715 /// resources will be encrypted using this key. The expected format is
7716 /// `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
7717 pub kms_key_name: std::string::String,
7718
7719 /// Output only. The most recent time this resource was modified.
7720 pub update_time: std::option::Option<wkt::Timestamp>,
7721
7722 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7723}
7724
7725impl Config {
7726 /// Creates a new default instance.
7727 pub fn new() -> Self {
7728 std::default::Default::default()
7729 }
7730
7731 /// Sets the value of [name][crate::model::Config::name].
7732 ///
7733 /// # Example
7734 /// ```ignore,no_run
7735 /// # use google_cloud_speech_v2::model::Config;
7736 /// # let project_id = "project_id";
7737 /// # let location_id = "location_id";
7738 /// let x = Config::new().set_name(format!("projects/{project_id}/locations/{location_id}/config"));
7739 /// ```
7740 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7741 self.name = v.into();
7742 self
7743 }
7744
7745 /// Sets the value of [kms_key_name][crate::model::Config::kms_key_name].
7746 ///
7747 /// # Example
7748 /// ```ignore,no_run
7749 /// # use google_cloud_speech_v2::model::Config;
7750 /// let x = Config::new().set_kms_key_name("example");
7751 /// ```
7752 pub fn set_kms_key_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7753 self.kms_key_name = v.into();
7754 self
7755 }
7756
7757 /// Sets the value of [update_time][crate::model::Config::update_time].
7758 ///
7759 /// # Example
7760 /// ```ignore,no_run
7761 /// # use google_cloud_speech_v2::model::Config;
7762 /// use wkt::Timestamp;
7763 /// let x = Config::new().set_update_time(Timestamp::default()/* use setters */);
7764 /// ```
7765 pub fn set_update_time<T>(mut self, v: T) -> Self
7766 where
7767 T: std::convert::Into<wkt::Timestamp>,
7768 {
7769 self.update_time = std::option::Option::Some(v.into());
7770 self
7771 }
7772
7773 /// Sets or clears the value of [update_time][crate::model::Config::update_time].
7774 ///
7775 /// # Example
7776 /// ```ignore,no_run
7777 /// # use google_cloud_speech_v2::model::Config;
7778 /// use wkt::Timestamp;
7779 /// let x = Config::new().set_or_clear_update_time(Some(Timestamp::default()/* use setters */));
7780 /// let x = Config::new().set_or_clear_update_time(None::<Timestamp>);
7781 /// ```
7782 pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
7783 where
7784 T: std::convert::Into<wkt::Timestamp>,
7785 {
7786 self.update_time = v.map(|x| x.into());
7787 self
7788 }
7789}
7790
7791impl wkt::message::Message for Config {
7792 fn typename() -> &'static str {
7793 "type.googleapis.com/google.cloud.speech.v2.Config"
7794 }
7795}
7796
7797/// Request message for the
7798/// [GetConfig][google.cloud.speech.v2.Speech.GetConfig] method.
7799///
7800/// [google.cloud.speech.v2.Speech.GetConfig]: crate::client::Speech::get_config
7801#[derive(Clone, Default, PartialEq)]
7802#[non_exhaustive]
7803pub struct GetConfigRequest {
7804 /// Required. The name of the config to retrieve. There is exactly one config
7805 /// resource per project per location. The expected format is
7806 /// `projects/{project}/locations/{location}/config`.
7807 pub name: std::string::String,
7808
7809 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7810}
7811
7812impl GetConfigRequest {
7813 /// Creates a new default instance.
7814 pub fn new() -> Self {
7815 std::default::Default::default()
7816 }
7817
7818 /// Sets the value of [name][crate::model::GetConfigRequest::name].
7819 ///
7820 /// # Example
7821 /// ```ignore,no_run
7822 /// # use google_cloud_speech_v2::model::GetConfigRequest;
7823 /// # let project_id = "project_id";
7824 /// # let location_id = "location_id";
7825 /// let x = GetConfigRequest::new().set_name(format!("projects/{project_id}/locations/{location_id}/config"));
7826 /// ```
7827 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7828 self.name = v.into();
7829 self
7830 }
7831}
7832
7833impl wkt::message::Message for GetConfigRequest {
7834 fn typename() -> &'static str {
7835 "type.googleapis.com/google.cloud.speech.v2.GetConfigRequest"
7836 }
7837}
7838
7839/// Request message for the
7840/// [UpdateConfig][google.cloud.speech.v2.Speech.UpdateConfig] method.
7841///
7842/// [google.cloud.speech.v2.Speech.UpdateConfig]: crate::client::Speech::update_config
7843#[derive(Clone, Default, PartialEq)]
7844#[non_exhaustive]
7845pub struct UpdateConfigRequest {
7846 /// Required. The config to update.
7847 ///
7848 /// The config's `name` field is used to identify the config to be updated.
7849 /// The expected format is `projects/{project}/locations/{location}/config`.
7850 pub config: std::option::Option<crate::model::Config>,
7851
7852 /// The list of fields to be updated.
7853 pub update_mask: std::option::Option<wkt::FieldMask>,
7854
7855 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7856}
7857
7858impl UpdateConfigRequest {
7859 /// Creates a new default instance.
7860 pub fn new() -> Self {
7861 std::default::Default::default()
7862 }
7863
7864 /// Sets the value of [config][crate::model::UpdateConfigRequest::config].
7865 ///
7866 /// # Example
7867 /// ```ignore,no_run
7868 /// # use google_cloud_speech_v2::model::UpdateConfigRequest;
7869 /// use google_cloud_speech_v2::model::Config;
7870 /// let x = UpdateConfigRequest::new().set_config(Config::default()/* use setters */);
7871 /// ```
7872 pub fn set_config<T>(mut self, v: T) -> Self
7873 where
7874 T: std::convert::Into<crate::model::Config>,
7875 {
7876 self.config = std::option::Option::Some(v.into());
7877 self
7878 }
7879
7880 /// Sets or clears the value of [config][crate::model::UpdateConfigRequest::config].
7881 ///
7882 /// # Example
7883 /// ```ignore,no_run
7884 /// # use google_cloud_speech_v2::model::UpdateConfigRequest;
7885 /// use google_cloud_speech_v2::model::Config;
7886 /// let x = UpdateConfigRequest::new().set_or_clear_config(Some(Config::default()/* use setters */));
7887 /// let x = UpdateConfigRequest::new().set_or_clear_config(None::<Config>);
7888 /// ```
7889 pub fn set_or_clear_config<T>(mut self, v: std::option::Option<T>) -> Self
7890 where
7891 T: std::convert::Into<crate::model::Config>,
7892 {
7893 self.config = v.map(|x| x.into());
7894 self
7895 }
7896
7897 /// Sets the value of [update_mask][crate::model::UpdateConfigRequest::update_mask].
7898 ///
7899 /// # Example
7900 /// ```ignore,no_run
7901 /// # use google_cloud_speech_v2::model::UpdateConfigRequest;
7902 /// use wkt::FieldMask;
7903 /// let x = UpdateConfigRequest::new().set_update_mask(FieldMask::default()/* use setters */);
7904 /// ```
7905 pub fn set_update_mask<T>(mut self, v: T) -> Self
7906 where
7907 T: std::convert::Into<wkt::FieldMask>,
7908 {
7909 self.update_mask = std::option::Option::Some(v.into());
7910 self
7911 }
7912
7913 /// Sets or clears the value of [update_mask][crate::model::UpdateConfigRequest::update_mask].
7914 ///
7915 /// # Example
7916 /// ```ignore,no_run
7917 /// # use google_cloud_speech_v2::model::UpdateConfigRequest;
7918 /// use wkt::FieldMask;
7919 /// let x = UpdateConfigRequest::new().set_or_clear_update_mask(Some(FieldMask::default()/* use setters */));
7920 /// let x = UpdateConfigRequest::new().set_or_clear_update_mask(None::<FieldMask>);
7921 /// ```
7922 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
7923 where
7924 T: std::convert::Into<wkt::FieldMask>,
7925 {
7926 self.update_mask = v.map(|x| x.into());
7927 self
7928 }
7929}
7930
7931impl wkt::message::Message for UpdateConfigRequest {
7932 fn typename() -> &'static str {
7933 "type.googleapis.com/google.cloud.speech.v2.UpdateConfigRequest"
7934 }
7935}
7936
7937/// CustomClass for biasing in speech recognition. Used to define a set of words
7938/// or phrases that represents a common concept or theme likely to appear in your
7939/// audio, for example a list of passenger ship names.
7940#[derive(Clone, Default, PartialEq)]
7941#[non_exhaustive]
7942pub struct CustomClass {
7943 /// Output only. Identifier. The resource name of the CustomClass.
7944 /// Format:
7945 /// `projects/{project}/locations/{location}/customClasses/{custom_class}`.
7946 pub name: std::string::String,
7947
7948 /// Output only. System-assigned unique identifier for the CustomClass.
7949 pub uid: std::string::String,
7950
7951 /// Optional. User-settable, human-readable name for the CustomClass. Must be
7952 /// 63 characters or less.
7953 pub display_name: std::string::String,
7954
7955 /// A collection of class items.
7956 pub items: std::vec::Vec<crate::model::custom_class::ClassItem>,
7957
7958 /// Output only. The CustomClass lifecycle state.
7959 pub state: crate::model::custom_class::State,
7960
7961 /// Output only. Creation time.
7962 pub create_time: std::option::Option<wkt::Timestamp>,
7963
7964 /// Output only. The most recent time this resource was modified.
7965 pub update_time: std::option::Option<wkt::Timestamp>,
7966
7967 /// Output only. The time at which this resource was requested for deletion.
7968 pub delete_time: std::option::Option<wkt::Timestamp>,
7969
7970 /// Output only. The time at which this resource will be purged.
7971 pub expire_time: std::option::Option<wkt::Timestamp>,
7972
7973 /// Optional. Allows users to store small amounts of arbitrary data.
7974 /// Both the key and the value must be 63 characters or less each.
7975 /// At most 100 annotations.
7976 pub annotations: std::collections::HashMap<std::string::String, std::string::String>,
7977
7978 /// Output only. This checksum is computed by the server based on the value of
7979 /// other fields. This may be sent on update, undelete, and delete requests to
7980 /// ensure the client has an up-to-date value before proceeding.
7981 pub etag: std::string::String,
7982
7983 /// Output only. Whether or not this CustomClass is in the process of being
7984 /// updated.
7985 pub reconciling: bool,
7986
7987 /// Output only. The [KMS key
7988 /// name](https://cloud.google.com/kms/docs/resource-hierarchy#keys) with which
7989 /// the CustomClass is encrypted. The expected format is
7990 /// `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
7991 pub kms_key_name: std::string::String,
7992
7993 /// Output only. The [KMS key version
7994 /// name](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions)
7995 /// with which the CustomClass is encrypted. The expected format is
7996 /// `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}`.
7997 pub kms_key_version_name: std::string::String,
7998
7999 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8000}
8001
8002impl CustomClass {
8003 /// Creates a new default instance.
8004 pub fn new() -> Self {
8005 std::default::Default::default()
8006 }
8007
8008 /// Sets the value of [name][crate::model::CustomClass::name].
8009 ///
8010 /// # Example
8011 /// ```ignore,no_run
8012 /// # use google_cloud_speech_v2::model::CustomClass;
8013 /// # let project_id = "project_id";
8014 /// # let location_id = "location_id";
8015 /// # let custom_class_id = "custom_class_id";
8016 /// let x = CustomClass::new().set_name(format!("projects/{project_id}/locations/{location_id}/customClasses/{custom_class_id}"));
8017 /// ```
8018 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8019 self.name = v.into();
8020 self
8021 }
8022
8023 /// Sets the value of [uid][crate::model::CustomClass::uid].
8024 ///
8025 /// # Example
8026 /// ```ignore,no_run
8027 /// # use google_cloud_speech_v2::model::CustomClass;
8028 /// let x = CustomClass::new().set_uid("example");
8029 /// ```
8030 pub fn set_uid<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8031 self.uid = v.into();
8032 self
8033 }
8034
8035 /// Sets the value of [display_name][crate::model::CustomClass::display_name].
8036 ///
8037 /// # Example
8038 /// ```ignore,no_run
8039 /// # use google_cloud_speech_v2::model::CustomClass;
8040 /// let x = CustomClass::new().set_display_name("example");
8041 /// ```
8042 pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8043 self.display_name = v.into();
8044 self
8045 }
8046
8047 /// Sets the value of [items][crate::model::CustomClass::items].
8048 ///
8049 /// # Example
8050 /// ```ignore,no_run
8051 /// # use google_cloud_speech_v2::model::CustomClass;
8052 /// use google_cloud_speech_v2::model::custom_class::ClassItem;
8053 /// let x = CustomClass::new()
8054 /// .set_items([
8055 /// ClassItem::default()/* use setters */,
8056 /// ClassItem::default()/* use (different) setters */,
8057 /// ]);
8058 /// ```
8059 pub fn set_items<T, V>(mut self, v: T) -> Self
8060 where
8061 T: std::iter::IntoIterator<Item = V>,
8062 V: std::convert::Into<crate::model::custom_class::ClassItem>,
8063 {
8064 use std::iter::Iterator;
8065 self.items = v.into_iter().map(|i| i.into()).collect();
8066 self
8067 }
8068
8069 /// Sets the value of [state][crate::model::CustomClass::state].
8070 ///
8071 /// # Example
8072 /// ```ignore,no_run
8073 /// # use google_cloud_speech_v2::model::CustomClass;
8074 /// use google_cloud_speech_v2::model::custom_class::State;
8075 /// let x0 = CustomClass::new().set_state(State::Active);
8076 /// let x1 = CustomClass::new().set_state(State::Deleted);
8077 /// ```
8078 pub fn set_state<T: std::convert::Into<crate::model::custom_class::State>>(
8079 mut self,
8080 v: T,
8081 ) -> Self {
8082 self.state = v.into();
8083 self
8084 }
8085
8086 /// Sets the value of [create_time][crate::model::CustomClass::create_time].
8087 ///
8088 /// # Example
8089 /// ```ignore,no_run
8090 /// # use google_cloud_speech_v2::model::CustomClass;
8091 /// use wkt::Timestamp;
8092 /// let x = CustomClass::new().set_create_time(Timestamp::default()/* use setters */);
8093 /// ```
8094 pub fn set_create_time<T>(mut self, v: T) -> Self
8095 where
8096 T: std::convert::Into<wkt::Timestamp>,
8097 {
8098 self.create_time = std::option::Option::Some(v.into());
8099 self
8100 }
8101
8102 /// Sets or clears the value of [create_time][crate::model::CustomClass::create_time].
8103 ///
8104 /// # Example
8105 /// ```ignore,no_run
8106 /// # use google_cloud_speech_v2::model::CustomClass;
8107 /// use wkt::Timestamp;
8108 /// let x = CustomClass::new().set_or_clear_create_time(Some(Timestamp::default()/* use setters */));
8109 /// let x = CustomClass::new().set_or_clear_create_time(None::<Timestamp>);
8110 /// ```
8111 pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
8112 where
8113 T: std::convert::Into<wkt::Timestamp>,
8114 {
8115 self.create_time = v.map(|x| x.into());
8116 self
8117 }
8118
8119 /// Sets the value of [update_time][crate::model::CustomClass::update_time].
8120 ///
8121 /// # Example
8122 /// ```ignore,no_run
8123 /// # use google_cloud_speech_v2::model::CustomClass;
8124 /// use wkt::Timestamp;
8125 /// let x = CustomClass::new().set_update_time(Timestamp::default()/* use setters */);
8126 /// ```
8127 pub fn set_update_time<T>(mut self, v: T) -> Self
8128 where
8129 T: std::convert::Into<wkt::Timestamp>,
8130 {
8131 self.update_time = std::option::Option::Some(v.into());
8132 self
8133 }
8134
8135 /// Sets or clears the value of [update_time][crate::model::CustomClass::update_time].
8136 ///
8137 /// # Example
8138 /// ```ignore,no_run
8139 /// # use google_cloud_speech_v2::model::CustomClass;
8140 /// use wkt::Timestamp;
8141 /// let x = CustomClass::new().set_or_clear_update_time(Some(Timestamp::default()/* use setters */));
8142 /// let x = CustomClass::new().set_or_clear_update_time(None::<Timestamp>);
8143 /// ```
8144 pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
8145 where
8146 T: std::convert::Into<wkt::Timestamp>,
8147 {
8148 self.update_time = v.map(|x| x.into());
8149 self
8150 }
8151
8152 /// Sets the value of [delete_time][crate::model::CustomClass::delete_time].
8153 ///
8154 /// # Example
8155 /// ```ignore,no_run
8156 /// # use google_cloud_speech_v2::model::CustomClass;
8157 /// use wkt::Timestamp;
8158 /// let x = CustomClass::new().set_delete_time(Timestamp::default()/* use setters */);
8159 /// ```
8160 pub fn set_delete_time<T>(mut self, v: T) -> Self
8161 where
8162 T: std::convert::Into<wkt::Timestamp>,
8163 {
8164 self.delete_time = std::option::Option::Some(v.into());
8165 self
8166 }
8167
8168 /// Sets or clears the value of [delete_time][crate::model::CustomClass::delete_time].
8169 ///
8170 /// # Example
8171 /// ```ignore,no_run
8172 /// # use google_cloud_speech_v2::model::CustomClass;
8173 /// use wkt::Timestamp;
8174 /// let x = CustomClass::new().set_or_clear_delete_time(Some(Timestamp::default()/* use setters */));
8175 /// let x = CustomClass::new().set_or_clear_delete_time(None::<Timestamp>);
8176 /// ```
8177 pub fn set_or_clear_delete_time<T>(mut self, v: std::option::Option<T>) -> Self
8178 where
8179 T: std::convert::Into<wkt::Timestamp>,
8180 {
8181 self.delete_time = v.map(|x| x.into());
8182 self
8183 }
8184
8185 /// Sets the value of [expire_time][crate::model::CustomClass::expire_time].
8186 ///
8187 /// # Example
8188 /// ```ignore,no_run
8189 /// # use google_cloud_speech_v2::model::CustomClass;
8190 /// use wkt::Timestamp;
8191 /// let x = CustomClass::new().set_expire_time(Timestamp::default()/* use setters */);
8192 /// ```
8193 pub fn set_expire_time<T>(mut self, v: T) -> Self
8194 where
8195 T: std::convert::Into<wkt::Timestamp>,
8196 {
8197 self.expire_time = std::option::Option::Some(v.into());
8198 self
8199 }
8200
8201 /// Sets or clears the value of [expire_time][crate::model::CustomClass::expire_time].
8202 ///
8203 /// # Example
8204 /// ```ignore,no_run
8205 /// # use google_cloud_speech_v2::model::CustomClass;
8206 /// use wkt::Timestamp;
8207 /// let x = CustomClass::new().set_or_clear_expire_time(Some(Timestamp::default()/* use setters */));
8208 /// let x = CustomClass::new().set_or_clear_expire_time(None::<Timestamp>);
8209 /// ```
8210 pub fn set_or_clear_expire_time<T>(mut self, v: std::option::Option<T>) -> Self
8211 where
8212 T: std::convert::Into<wkt::Timestamp>,
8213 {
8214 self.expire_time = v.map(|x| x.into());
8215 self
8216 }
8217
8218 /// Sets the value of [annotations][crate::model::CustomClass::annotations].
8219 ///
8220 /// # Example
8221 /// ```ignore,no_run
8222 /// # use google_cloud_speech_v2::model::CustomClass;
8223 /// let x = CustomClass::new().set_annotations([
8224 /// ("key0", "abc"),
8225 /// ("key1", "xyz"),
8226 /// ]);
8227 /// ```
8228 pub fn set_annotations<T, K, V>(mut self, v: T) -> Self
8229 where
8230 T: std::iter::IntoIterator<Item = (K, V)>,
8231 K: std::convert::Into<std::string::String>,
8232 V: std::convert::Into<std::string::String>,
8233 {
8234 use std::iter::Iterator;
8235 self.annotations = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
8236 self
8237 }
8238
8239 /// Sets the value of [etag][crate::model::CustomClass::etag].
8240 ///
8241 /// # Example
8242 /// ```ignore,no_run
8243 /// # use google_cloud_speech_v2::model::CustomClass;
8244 /// let x = CustomClass::new().set_etag("example");
8245 /// ```
8246 pub fn set_etag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8247 self.etag = v.into();
8248 self
8249 }
8250
8251 /// Sets the value of [reconciling][crate::model::CustomClass::reconciling].
8252 ///
8253 /// # Example
8254 /// ```ignore,no_run
8255 /// # use google_cloud_speech_v2::model::CustomClass;
8256 /// let x = CustomClass::new().set_reconciling(true);
8257 /// ```
8258 pub fn set_reconciling<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8259 self.reconciling = v.into();
8260 self
8261 }
8262
8263 /// Sets the value of [kms_key_name][crate::model::CustomClass::kms_key_name].
8264 ///
8265 /// # Example
8266 /// ```ignore,no_run
8267 /// # use google_cloud_speech_v2::model::CustomClass;
8268 /// let x = CustomClass::new().set_kms_key_name("example");
8269 /// ```
8270 pub fn set_kms_key_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8271 self.kms_key_name = v.into();
8272 self
8273 }
8274
8275 /// Sets the value of [kms_key_version_name][crate::model::CustomClass::kms_key_version_name].
8276 ///
8277 /// # Example
8278 /// ```ignore,no_run
8279 /// # use google_cloud_speech_v2::model::CustomClass;
8280 /// let x = CustomClass::new().set_kms_key_version_name("example");
8281 /// ```
8282 pub fn set_kms_key_version_name<T: std::convert::Into<std::string::String>>(
8283 mut self,
8284 v: T,
8285 ) -> Self {
8286 self.kms_key_version_name = v.into();
8287 self
8288 }
8289}
8290
8291impl wkt::message::Message for CustomClass {
8292 fn typename() -> &'static str {
8293 "type.googleapis.com/google.cloud.speech.v2.CustomClass"
8294 }
8295}
8296
8297/// Defines additional types related to [CustomClass].
8298pub mod custom_class {
8299 #[allow(unused_imports)]
8300 use super::*;
8301
8302 /// An item of the class.
8303 #[derive(Clone, Default, PartialEq)]
8304 #[non_exhaustive]
8305 pub struct ClassItem {
8306 /// The class item's value.
8307 pub value: std::string::String,
8308
8309 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8310 }
8311
8312 impl ClassItem {
8313 /// Creates a new default instance.
8314 pub fn new() -> Self {
8315 std::default::Default::default()
8316 }
8317
8318 /// Sets the value of [value][crate::model::custom_class::ClassItem::value].
8319 ///
8320 /// # Example
8321 /// ```ignore,no_run
8322 /// # use google_cloud_speech_v2::model::custom_class::ClassItem;
8323 /// let x = ClassItem::new().set_value("example");
8324 /// ```
8325 pub fn set_value<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8326 self.value = v.into();
8327 self
8328 }
8329 }
8330
8331 impl wkt::message::Message for ClassItem {
8332 fn typename() -> &'static str {
8333 "type.googleapis.com/google.cloud.speech.v2.CustomClass.ClassItem"
8334 }
8335 }
8336
8337 /// Set of states that define the lifecycle of a CustomClass.
8338 ///
8339 /// # Working with unknown values
8340 ///
8341 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
8342 /// additional enum variants at any time. Adding new variants is not considered
8343 /// a breaking change. Applications should write their code in anticipation of:
8344 ///
8345 /// - New values appearing in future releases of the client library, **and**
8346 /// - New values received dynamically, without application changes.
8347 ///
8348 /// Please consult the [Working with enums] section in the user guide for some
8349 /// guidelines.
8350 ///
8351 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
8352 #[derive(Clone, Debug, PartialEq)]
8353 #[non_exhaustive]
8354 pub enum State {
8355 /// Unspecified state. This is only used/useful for distinguishing
8356 /// unset values.
8357 Unspecified,
8358 /// The normal and active state.
8359 Active,
8360 /// This CustomClass has been deleted.
8361 Deleted,
8362 /// If set, the enum was initialized with an unknown value.
8363 ///
8364 /// Applications can examine the value using [State::value] or
8365 /// [State::name].
8366 UnknownValue(state::UnknownValue),
8367 }
8368
8369 #[doc(hidden)]
8370 pub mod state {
8371 #[allow(unused_imports)]
8372 use super::*;
8373 #[derive(Clone, Debug, PartialEq)]
8374 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
8375 }
8376
8377 impl State {
8378 /// Gets the enum value.
8379 ///
8380 /// Returns `None` if the enum contains an unknown value deserialized from
8381 /// the string representation of enums.
8382 pub fn value(&self) -> std::option::Option<i32> {
8383 match self {
8384 Self::Unspecified => std::option::Option::Some(0),
8385 Self::Active => std::option::Option::Some(2),
8386 Self::Deleted => std::option::Option::Some(4),
8387 Self::UnknownValue(u) => u.0.value(),
8388 }
8389 }
8390
8391 /// Gets the enum value as a string.
8392 ///
8393 /// Returns `None` if the enum contains an unknown value deserialized from
8394 /// the integer representation of enums.
8395 pub fn name(&self) -> std::option::Option<&str> {
8396 match self {
8397 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
8398 Self::Active => std::option::Option::Some("ACTIVE"),
8399 Self::Deleted => std::option::Option::Some("DELETED"),
8400 Self::UnknownValue(u) => u.0.name(),
8401 }
8402 }
8403 }
8404
8405 impl std::default::Default for State {
8406 fn default() -> Self {
8407 use std::convert::From;
8408 Self::from(0)
8409 }
8410 }
8411
8412 impl std::fmt::Display for State {
8413 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
8414 wkt::internal::display_enum(f, self.name(), self.value())
8415 }
8416 }
8417
8418 impl std::convert::From<i32> for State {
8419 fn from(value: i32) -> Self {
8420 match value {
8421 0 => Self::Unspecified,
8422 2 => Self::Active,
8423 4 => Self::Deleted,
8424 _ => Self::UnknownValue(state::UnknownValue(
8425 wkt::internal::UnknownEnumValue::Integer(value),
8426 )),
8427 }
8428 }
8429 }
8430
8431 impl std::convert::From<&str> for State {
8432 fn from(value: &str) -> Self {
8433 use std::string::ToString;
8434 match value {
8435 "STATE_UNSPECIFIED" => Self::Unspecified,
8436 "ACTIVE" => Self::Active,
8437 "DELETED" => Self::Deleted,
8438 _ => Self::UnknownValue(state::UnknownValue(
8439 wkt::internal::UnknownEnumValue::String(value.to_string()),
8440 )),
8441 }
8442 }
8443 }
8444
8445 impl serde::ser::Serialize for State {
8446 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8447 where
8448 S: serde::Serializer,
8449 {
8450 match self {
8451 Self::Unspecified => serializer.serialize_i32(0),
8452 Self::Active => serializer.serialize_i32(2),
8453 Self::Deleted => serializer.serialize_i32(4),
8454 Self::UnknownValue(u) => u.0.serialize(serializer),
8455 }
8456 }
8457 }
8458
8459 impl<'de> serde::de::Deserialize<'de> for State {
8460 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8461 where
8462 D: serde::Deserializer<'de>,
8463 {
8464 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
8465 ".google.cloud.speech.v2.CustomClass.State",
8466 ))
8467 }
8468 }
8469}
8470
8471/// PhraseSet for biasing in speech recognition. A PhraseSet is used to provide
8472/// "hints" to the speech recognizer to favor specific words and phrases in the
8473/// results.
8474#[derive(Clone, Default, PartialEq)]
8475#[non_exhaustive]
8476pub struct PhraseSet {
8477 /// Output only. Identifier. The resource name of the PhraseSet.
8478 /// Format: `projects/{project}/locations/{location}/phraseSets/{phrase_set}`.
8479 pub name: std::string::String,
8480
8481 /// Output only. System-assigned unique identifier for the PhraseSet.
8482 pub uid: std::string::String,
8483
8484 /// A list of word and phrases.
8485 pub phrases: std::vec::Vec<crate::model::phrase_set::Phrase>,
8486
8487 /// Hint Boost. Positive value will increase the probability that a specific
8488 /// phrase will be recognized over other similar sounding phrases. The higher
8489 /// the boost, the higher the chance of false positive recognition as well.
8490 /// Valid `boost` values are between 0 (exclusive) and 20. We recommend using a
8491 /// binary search approach to finding the optimal value for your use case as
8492 /// well as adding phrases both with and without boost to your requests.
8493 pub boost: f32,
8494
8495 /// User-settable, human-readable name for the PhraseSet. Must be 63
8496 /// characters or less.
8497 pub display_name: std::string::String,
8498
8499 /// Output only. The PhraseSet lifecycle state.
8500 pub state: crate::model::phrase_set::State,
8501
8502 /// Output only. Creation time.
8503 pub create_time: std::option::Option<wkt::Timestamp>,
8504
8505 /// Output only. The most recent time this resource was modified.
8506 pub update_time: std::option::Option<wkt::Timestamp>,
8507
8508 /// Output only. The time at which this resource was requested for deletion.
8509 pub delete_time: std::option::Option<wkt::Timestamp>,
8510
8511 /// Output only. The time at which this resource will be purged.
8512 pub expire_time: std::option::Option<wkt::Timestamp>,
8513
8514 /// Allows users to store small amounts of arbitrary data.
8515 /// Both the key and the value must be 63 characters or less each.
8516 /// At most 100 annotations.
8517 pub annotations: std::collections::HashMap<std::string::String, std::string::String>,
8518
8519 /// Output only. This checksum is computed by the server based on the value of
8520 /// other fields. This may be sent on update, undelete, and delete requests to
8521 /// ensure the client has an up-to-date value before proceeding.
8522 pub etag: std::string::String,
8523
8524 /// Output only. Whether or not this PhraseSet is in the process of being
8525 /// updated.
8526 pub reconciling: bool,
8527
8528 /// Output only. The [KMS key
8529 /// name](https://cloud.google.com/kms/docs/resource-hierarchy#keys) with which
8530 /// the PhraseSet is encrypted. The expected format is
8531 /// `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
8532 pub kms_key_name: std::string::String,
8533
8534 /// Output only. The [KMS key version
8535 /// name](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions)
8536 /// with which the PhraseSet is encrypted. The expected format is
8537 /// `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}`.
8538 pub kms_key_version_name: std::string::String,
8539
8540 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8541}
8542
8543impl PhraseSet {
8544 /// Creates a new default instance.
8545 pub fn new() -> Self {
8546 std::default::Default::default()
8547 }
8548
8549 /// Sets the value of [name][crate::model::PhraseSet::name].
8550 ///
8551 /// # Example
8552 /// ```ignore,no_run
8553 /// # use google_cloud_speech_v2::model::PhraseSet;
8554 /// # let project_id = "project_id";
8555 /// # let location_id = "location_id";
8556 /// # let phrase_set_id = "phrase_set_id";
8557 /// let x = PhraseSet::new().set_name(format!("projects/{project_id}/locations/{location_id}/phraseSets/{phrase_set_id}"));
8558 /// ```
8559 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8560 self.name = v.into();
8561 self
8562 }
8563
8564 /// Sets the value of [uid][crate::model::PhraseSet::uid].
8565 ///
8566 /// # Example
8567 /// ```ignore,no_run
8568 /// # use google_cloud_speech_v2::model::PhraseSet;
8569 /// let x = PhraseSet::new().set_uid("example");
8570 /// ```
8571 pub fn set_uid<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8572 self.uid = v.into();
8573 self
8574 }
8575
8576 /// Sets the value of [phrases][crate::model::PhraseSet::phrases].
8577 ///
8578 /// # Example
8579 /// ```ignore,no_run
8580 /// # use google_cloud_speech_v2::model::PhraseSet;
8581 /// use google_cloud_speech_v2::model::phrase_set::Phrase;
8582 /// let x = PhraseSet::new()
8583 /// .set_phrases([
8584 /// Phrase::default()/* use setters */,
8585 /// Phrase::default()/* use (different) setters */,
8586 /// ]);
8587 /// ```
8588 pub fn set_phrases<T, V>(mut self, v: T) -> Self
8589 where
8590 T: std::iter::IntoIterator<Item = V>,
8591 V: std::convert::Into<crate::model::phrase_set::Phrase>,
8592 {
8593 use std::iter::Iterator;
8594 self.phrases = v.into_iter().map(|i| i.into()).collect();
8595 self
8596 }
8597
8598 /// Sets the value of [boost][crate::model::PhraseSet::boost].
8599 ///
8600 /// # Example
8601 /// ```ignore,no_run
8602 /// # use google_cloud_speech_v2::model::PhraseSet;
8603 /// let x = PhraseSet::new().set_boost(42.0);
8604 /// ```
8605 pub fn set_boost<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
8606 self.boost = v.into();
8607 self
8608 }
8609
8610 /// Sets the value of [display_name][crate::model::PhraseSet::display_name].
8611 ///
8612 /// # Example
8613 /// ```ignore,no_run
8614 /// # use google_cloud_speech_v2::model::PhraseSet;
8615 /// let x = PhraseSet::new().set_display_name("example");
8616 /// ```
8617 pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8618 self.display_name = v.into();
8619 self
8620 }
8621
8622 /// Sets the value of [state][crate::model::PhraseSet::state].
8623 ///
8624 /// # Example
8625 /// ```ignore,no_run
8626 /// # use google_cloud_speech_v2::model::PhraseSet;
8627 /// use google_cloud_speech_v2::model::phrase_set::State;
8628 /// let x0 = PhraseSet::new().set_state(State::Active);
8629 /// let x1 = PhraseSet::new().set_state(State::Deleted);
8630 /// ```
8631 pub fn set_state<T: std::convert::Into<crate::model::phrase_set::State>>(
8632 mut self,
8633 v: T,
8634 ) -> Self {
8635 self.state = v.into();
8636 self
8637 }
8638
8639 /// Sets the value of [create_time][crate::model::PhraseSet::create_time].
8640 ///
8641 /// # Example
8642 /// ```ignore,no_run
8643 /// # use google_cloud_speech_v2::model::PhraseSet;
8644 /// use wkt::Timestamp;
8645 /// let x = PhraseSet::new().set_create_time(Timestamp::default()/* use setters */);
8646 /// ```
8647 pub fn set_create_time<T>(mut self, v: T) -> Self
8648 where
8649 T: std::convert::Into<wkt::Timestamp>,
8650 {
8651 self.create_time = std::option::Option::Some(v.into());
8652 self
8653 }
8654
8655 /// Sets or clears the value of [create_time][crate::model::PhraseSet::create_time].
8656 ///
8657 /// # Example
8658 /// ```ignore,no_run
8659 /// # use google_cloud_speech_v2::model::PhraseSet;
8660 /// use wkt::Timestamp;
8661 /// let x = PhraseSet::new().set_or_clear_create_time(Some(Timestamp::default()/* use setters */));
8662 /// let x = PhraseSet::new().set_or_clear_create_time(None::<Timestamp>);
8663 /// ```
8664 pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
8665 where
8666 T: std::convert::Into<wkt::Timestamp>,
8667 {
8668 self.create_time = v.map(|x| x.into());
8669 self
8670 }
8671
8672 /// Sets the value of [update_time][crate::model::PhraseSet::update_time].
8673 ///
8674 /// # Example
8675 /// ```ignore,no_run
8676 /// # use google_cloud_speech_v2::model::PhraseSet;
8677 /// use wkt::Timestamp;
8678 /// let x = PhraseSet::new().set_update_time(Timestamp::default()/* use setters */);
8679 /// ```
8680 pub fn set_update_time<T>(mut self, v: T) -> Self
8681 where
8682 T: std::convert::Into<wkt::Timestamp>,
8683 {
8684 self.update_time = std::option::Option::Some(v.into());
8685 self
8686 }
8687
8688 /// Sets or clears the value of [update_time][crate::model::PhraseSet::update_time].
8689 ///
8690 /// # Example
8691 /// ```ignore,no_run
8692 /// # use google_cloud_speech_v2::model::PhraseSet;
8693 /// use wkt::Timestamp;
8694 /// let x = PhraseSet::new().set_or_clear_update_time(Some(Timestamp::default()/* use setters */));
8695 /// let x = PhraseSet::new().set_or_clear_update_time(None::<Timestamp>);
8696 /// ```
8697 pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
8698 where
8699 T: std::convert::Into<wkt::Timestamp>,
8700 {
8701 self.update_time = v.map(|x| x.into());
8702 self
8703 }
8704
8705 /// Sets the value of [delete_time][crate::model::PhraseSet::delete_time].
8706 ///
8707 /// # Example
8708 /// ```ignore,no_run
8709 /// # use google_cloud_speech_v2::model::PhraseSet;
8710 /// use wkt::Timestamp;
8711 /// let x = PhraseSet::new().set_delete_time(Timestamp::default()/* use setters */);
8712 /// ```
8713 pub fn set_delete_time<T>(mut self, v: T) -> Self
8714 where
8715 T: std::convert::Into<wkt::Timestamp>,
8716 {
8717 self.delete_time = std::option::Option::Some(v.into());
8718 self
8719 }
8720
8721 /// Sets or clears the value of [delete_time][crate::model::PhraseSet::delete_time].
8722 ///
8723 /// # Example
8724 /// ```ignore,no_run
8725 /// # use google_cloud_speech_v2::model::PhraseSet;
8726 /// use wkt::Timestamp;
8727 /// let x = PhraseSet::new().set_or_clear_delete_time(Some(Timestamp::default()/* use setters */));
8728 /// let x = PhraseSet::new().set_or_clear_delete_time(None::<Timestamp>);
8729 /// ```
8730 pub fn set_or_clear_delete_time<T>(mut self, v: std::option::Option<T>) -> Self
8731 where
8732 T: std::convert::Into<wkt::Timestamp>,
8733 {
8734 self.delete_time = v.map(|x| x.into());
8735 self
8736 }
8737
8738 /// Sets the value of [expire_time][crate::model::PhraseSet::expire_time].
8739 ///
8740 /// # Example
8741 /// ```ignore,no_run
8742 /// # use google_cloud_speech_v2::model::PhraseSet;
8743 /// use wkt::Timestamp;
8744 /// let x = PhraseSet::new().set_expire_time(Timestamp::default()/* use setters */);
8745 /// ```
8746 pub fn set_expire_time<T>(mut self, v: T) -> Self
8747 where
8748 T: std::convert::Into<wkt::Timestamp>,
8749 {
8750 self.expire_time = std::option::Option::Some(v.into());
8751 self
8752 }
8753
8754 /// Sets or clears the value of [expire_time][crate::model::PhraseSet::expire_time].
8755 ///
8756 /// # Example
8757 /// ```ignore,no_run
8758 /// # use google_cloud_speech_v2::model::PhraseSet;
8759 /// use wkt::Timestamp;
8760 /// let x = PhraseSet::new().set_or_clear_expire_time(Some(Timestamp::default()/* use setters */));
8761 /// let x = PhraseSet::new().set_or_clear_expire_time(None::<Timestamp>);
8762 /// ```
8763 pub fn set_or_clear_expire_time<T>(mut self, v: std::option::Option<T>) -> Self
8764 where
8765 T: std::convert::Into<wkt::Timestamp>,
8766 {
8767 self.expire_time = v.map(|x| x.into());
8768 self
8769 }
8770
8771 /// Sets the value of [annotations][crate::model::PhraseSet::annotations].
8772 ///
8773 /// # Example
8774 /// ```ignore,no_run
8775 /// # use google_cloud_speech_v2::model::PhraseSet;
8776 /// let x = PhraseSet::new().set_annotations([
8777 /// ("key0", "abc"),
8778 /// ("key1", "xyz"),
8779 /// ]);
8780 /// ```
8781 pub fn set_annotations<T, K, V>(mut self, v: T) -> Self
8782 where
8783 T: std::iter::IntoIterator<Item = (K, V)>,
8784 K: std::convert::Into<std::string::String>,
8785 V: std::convert::Into<std::string::String>,
8786 {
8787 use std::iter::Iterator;
8788 self.annotations = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
8789 self
8790 }
8791
8792 /// Sets the value of [etag][crate::model::PhraseSet::etag].
8793 ///
8794 /// # Example
8795 /// ```ignore,no_run
8796 /// # use google_cloud_speech_v2::model::PhraseSet;
8797 /// let x = PhraseSet::new().set_etag("example");
8798 /// ```
8799 pub fn set_etag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8800 self.etag = v.into();
8801 self
8802 }
8803
8804 /// Sets the value of [reconciling][crate::model::PhraseSet::reconciling].
8805 ///
8806 /// # Example
8807 /// ```ignore,no_run
8808 /// # use google_cloud_speech_v2::model::PhraseSet;
8809 /// let x = PhraseSet::new().set_reconciling(true);
8810 /// ```
8811 pub fn set_reconciling<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8812 self.reconciling = v.into();
8813 self
8814 }
8815
8816 /// Sets the value of [kms_key_name][crate::model::PhraseSet::kms_key_name].
8817 ///
8818 /// # Example
8819 /// ```ignore,no_run
8820 /// # use google_cloud_speech_v2::model::PhraseSet;
8821 /// let x = PhraseSet::new().set_kms_key_name("example");
8822 /// ```
8823 pub fn set_kms_key_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8824 self.kms_key_name = v.into();
8825 self
8826 }
8827
8828 /// Sets the value of [kms_key_version_name][crate::model::PhraseSet::kms_key_version_name].
8829 ///
8830 /// # Example
8831 /// ```ignore,no_run
8832 /// # use google_cloud_speech_v2::model::PhraseSet;
8833 /// let x = PhraseSet::new().set_kms_key_version_name("example");
8834 /// ```
8835 pub fn set_kms_key_version_name<T: std::convert::Into<std::string::String>>(
8836 mut self,
8837 v: T,
8838 ) -> Self {
8839 self.kms_key_version_name = v.into();
8840 self
8841 }
8842}
8843
8844impl wkt::message::Message for PhraseSet {
8845 fn typename() -> &'static str {
8846 "type.googleapis.com/google.cloud.speech.v2.PhraseSet"
8847 }
8848}
8849
8850/// Defines additional types related to [PhraseSet].
8851pub mod phrase_set {
8852 #[allow(unused_imports)]
8853 use super::*;
8854
8855 /// A Phrase contains words and phrase "hints" so that the speech recognition
8856 /// is more likely to recognize them. This can be used to improve the accuracy
8857 /// for specific words and phrases, for example, if specific commands are
8858 /// typically spoken by the user. This can also be used to add additional words
8859 /// to the vocabulary of the recognizer.
8860 ///
8861 /// List items can also include CustomClass references containing groups of
8862 /// words that represent common concepts that occur in natural language.
8863 #[derive(Clone, Default, PartialEq)]
8864 #[non_exhaustive]
8865 pub struct Phrase {
8866 /// The phrase itself.
8867 pub value: std::string::String,
8868
8869 /// Hint Boost. Overrides the boost set at the phrase set level.
8870 /// Positive value will increase the probability that a specific phrase will
8871 /// be recognized over other similar sounding phrases. The higher the boost,
8872 /// the higher the chance of false positive recognition as well. Negative
8873 /// boost values would correspond to anti-biasing. Anti-biasing is not
8874 /// enabled, so negative boost values will return an error. Boost values must
8875 /// be between 0 and 20. Any values outside that range will return an error.
8876 /// We recommend using a binary search approach to finding the optimal value
8877 /// for your use case as well as adding phrases both with and without boost
8878 /// to your requests.
8879 pub boost: f32,
8880
8881 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8882 }
8883
8884 impl Phrase {
8885 /// Creates a new default instance.
8886 pub fn new() -> Self {
8887 std::default::Default::default()
8888 }
8889
8890 /// Sets the value of [value][crate::model::phrase_set::Phrase::value].
8891 ///
8892 /// # Example
8893 /// ```ignore,no_run
8894 /// # use google_cloud_speech_v2::model::phrase_set::Phrase;
8895 /// let x = Phrase::new().set_value("example");
8896 /// ```
8897 pub fn set_value<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8898 self.value = v.into();
8899 self
8900 }
8901
8902 /// Sets the value of [boost][crate::model::phrase_set::Phrase::boost].
8903 ///
8904 /// # Example
8905 /// ```ignore,no_run
8906 /// # use google_cloud_speech_v2::model::phrase_set::Phrase;
8907 /// let x = Phrase::new().set_boost(42.0);
8908 /// ```
8909 pub fn set_boost<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
8910 self.boost = v.into();
8911 self
8912 }
8913 }
8914
8915 impl wkt::message::Message for Phrase {
8916 fn typename() -> &'static str {
8917 "type.googleapis.com/google.cloud.speech.v2.PhraseSet.Phrase"
8918 }
8919 }
8920
8921 /// Set of states that define the lifecycle of a PhraseSet.
8922 ///
8923 /// # Working with unknown values
8924 ///
8925 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
8926 /// additional enum variants at any time. Adding new variants is not considered
8927 /// a breaking change. Applications should write their code in anticipation of:
8928 ///
8929 /// - New values appearing in future releases of the client library, **and**
8930 /// - New values received dynamically, without application changes.
8931 ///
8932 /// Please consult the [Working with enums] section in the user guide for some
8933 /// guidelines.
8934 ///
8935 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
8936 #[derive(Clone, Debug, PartialEq)]
8937 #[non_exhaustive]
8938 pub enum State {
8939 /// Unspecified state. This is only used/useful for distinguishing
8940 /// unset values.
8941 Unspecified,
8942 /// The normal and active state.
8943 Active,
8944 /// This PhraseSet has been deleted.
8945 Deleted,
8946 /// If set, the enum was initialized with an unknown value.
8947 ///
8948 /// Applications can examine the value using [State::value] or
8949 /// [State::name].
8950 UnknownValue(state::UnknownValue),
8951 }
8952
8953 #[doc(hidden)]
8954 pub mod state {
8955 #[allow(unused_imports)]
8956 use super::*;
8957 #[derive(Clone, Debug, PartialEq)]
8958 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
8959 }
8960
8961 impl State {
8962 /// Gets the enum value.
8963 ///
8964 /// Returns `None` if the enum contains an unknown value deserialized from
8965 /// the string representation of enums.
8966 pub fn value(&self) -> std::option::Option<i32> {
8967 match self {
8968 Self::Unspecified => std::option::Option::Some(0),
8969 Self::Active => std::option::Option::Some(2),
8970 Self::Deleted => std::option::Option::Some(4),
8971 Self::UnknownValue(u) => u.0.value(),
8972 }
8973 }
8974
8975 /// Gets the enum value as a string.
8976 ///
8977 /// Returns `None` if the enum contains an unknown value deserialized from
8978 /// the integer representation of enums.
8979 pub fn name(&self) -> std::option::Option<&str> {
8980 match self {
8981 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
8982 Self::Active => std::option::Option::Some("ACTIVE"),
8983 Self::Deleted => std::option::Option::Some("DELETED"),
8984 Self::UnknownValue(u) => u.0.name(),
8985 }
8986 }
8987 }
8988
8989 impl std::default::Default for State {
8990 fn default() -> Self {
8991 use std::convert::From;
8992 Self::from(0)
8993 }
8994 }
8995
8996 impl std::fmt::Display for State {
8997 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
8998 wkt::internal::display_enum(f, self.name(), self.value())
8999 }
9000 }
9001
9002 impl std::convert::From<i32> for State {
9003 fn from(value: i32) -> Self {
9004 match value {
9005 0 => Self::Unspecified,
9006 2 => Self::Active,
9007 4 => Self::Deleted,
9008 _ => Self::UnknownValue(state::UnknownValue(
9009 wkt::internal::UnknownEnumValue::Integer(value),
9010 )),
9011 }
9012 }
9013 }
9014
9015 impl std::convert::From<&str> for State {
9016 fn from(value: &str) -> Self {
9017 use std::string::ToString;
9018 match value {
9019 "STATE_UNSPECIFIED" => Self::Unspecified,
9020 "ACTIVE" => Self::Active,
9021 "DELETED" => Self::Deleted,
9022 _ => Self::UnknownValue(state::UnknownValue(
9023 wkt::internal::UnknownEnumValue::String(value.to_string()),
9024 )),
9025 }
9026 }
9027 }
9028
9029 impl serde::ser::Serialize for State {
9030 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9031 where
9032 S: serde::Serializer,
9033 {
9034 match self {
9035 Self::Unspecified => serializer.serialize_i32(0),
9036 Self::Active => serializer.serialize_i32(2),
9037 Self::Deleted => serializer.serialize_i32(4),
9038 Self::UnknownValue(u) => u.0.serialize(serializer),
9039 }
9040 }
9041 }
9042
9043 impl<'de> serde::de::Deserialize<'de> for State {
9044 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9045 where
9046 D: serde::Deserializer<'de>,
9047 {
9048 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
9049 ".google.cloud.speech.v2.PhraseSet.State",
9050 ))
9051 }
9052 }
9053}
9054
9055/// Request message for the
9056/// [CreateCustomClass][google.cloud.speech.v2.Speech.CreateCustomClass] method.
9057///
9058/// [google.cloud.speech.v2.Speech.CreateCustomClass]: crate::client::Speech::create_custom_class
9059#[derive(Clone, Default, PartialEq)]
9060#[non_exhaustive]
9061pub struct CreateCustomClassRequest {
9062 /// Required. The CustomClass to create.
9063 pub custom_class: std::option::Option<crate::model::CustomClass>,
9064
9065 /// If set, validate the request and preview the CustomClass, but do not
9066 /// actually create it.
9067 pub validate_only: bool,
9068
9069 /// The ID to use for the CustomClass, which will become the final component of
9070 /// the CustomClass's resource name.
9071 ///
9072 /// This value should be 4-63 characters, and valid characters
9073 /// are /[a-z][0-9]-/.
9074 pub custom_class_id: std::string::String,
9075
9076 /// Required. The project and location where this CustomClass will be created.
9077 /// The expected format is `projects/{project}/locations/{location}`.
9078 pub parent: std::string::String,
9079
9080 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9081}
9082
9083impl CreateCustomClassRequest {
9084 /// Creates a new default instance.
9085 pub fn new() -> Self {
9086 std::default::Default::default()
9087 }
9088
9089 /// Sets the value of [custom_class][crate::model::CreateCustomClassRequest::custom_class].
9090 ///
9091 /// # Example
9092 /// ```ignore,no_run
9093 /// # use google_cloud_speech_v2::model::CreateCustomClassRequest;
9094 /// use google_cloud_speech_v2::model::CustomClass;
9095 /// let x = CreateCustomClassRequest::new().set_custom_class(CustomClass::default()/* use setters */);
9096 /// ```
9097 pub fn set_custom_class<T>(mut self, v: T) -> Self
9098 where
9099 T: std::convert::Into<crate::model::CustomClass>,
9100 {
9101 self.custom_class = std::option::Option::Some(v.into());
9102 self
9103 }
9104
9105 /// Sets or clears the value of [custom_class][crate::model::CreateCustomClassRequest::custom_class].
9106 ///
9107 /// # Example
9108 /// ```ignore,no_run
9109 /// # use google_cloud_speech_v2::model::CreateCustomClassRequest;
9110 /// use google_cloud_speech_v2::model::CustomClass;
9111 /// let x = CreateCustomClassRequest::new().set_or_clear_custom_class(Some(CustomClass::default()/* use setters */));
9112 /// let x = CreateCustomClassRequest::new().set_or_clear_custom_class(None::<CustomClass>);
9113 /// ```
9114 pub fn set_or_clear_custom_class<T>(mut self, v: std::option::Option<T>) -> Self
9115 where
9116 T: std::convert::Into<crate::model::CustomClass>,
9117 {
9118 self.custom_class = v.map(|x| x.into());
9119 self
9120 }
9121
9122 /// Sets the value of [validate_only][crate::model::CreateCustomClassRequest::validate_only].
9123 ///
9124 /// # Example
9125 /// ```ignore,no_run
9126 /// # use google_cloud_speech_v2::model::CreateCustomClassRequest;
9127 /// let x = CreateCustomClassRequest::new().set_validate_only(true);
9128 /// ```
9129 pub fn set_validate_only<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
9130 self.validate_only = v.into();
9131 self
9132 }
9133
9134 /// Sets the value of [custom_class_id][crate::model::CreateCustomClassRequest::custom_class_id].
9135 ///
9136 /// # Example
9137 /// ```ignore,no_run
9138 /// # use google_cloud_speech_v2::model::CreateCustomClassRequest;
9139 /// let x = CreateCustomClassRequest::new().set_custom_class_id("example");
9140 /// ```
9141 pub fn set_custom_class_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9142 self.custom_class_id = v.into();
9143 self
9144 }
9145
9146 /// Sets the value of [parent][crate::model::CreateCustomClassRequest::parent].
9147 ///
9148 /// # Example
9149 /// ```ignore,no_run
9150 /// # use google_cloud_speech_v2::model::CreateCustomClassRequest;
9151 /// # let project_id = "project_id";
9152 /// # let location_id = "location_id";
9153 /// let x = CreateCustomClassRequest::new().set_parent(format!("projects/{project_id}/locations/{location_id}"));
9154 /// ```
9155 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9156 self.parent = v.into();
9157 self
9158 }
9159}
9160
9161impl wkt::message::Message for CreateCustomClassRequest {
9162 fn typename() -> &'static str {
9163 "type.googleapis.com/google.cloud.speech.v2.CreateCustomClassRequest"
9164 }
9165}
9166
9167/// Request message for the
9168/// [ListCustomClasses][google.cloud.speech.v2.Speech.ListCustomClasses] method.
9169///
9170/// [google.cloud.speech.v2.Speech.ListCustomClasses]: crate::client::Speech::list_custom_classes
9171#[derive(Clone, Default, PartialEq)]
9172#[non_exhaustive]
9173pub struct ListCustomClassesRequest {
9174 /// Required. The project and location of CustomClass resources to list. The
9175 /// expected format is `projects/{project}/locations/{location}`.
9176 pub parent: std::string::String,
9177
9178 /// Number of results per requests. A valid page_size ranges from 0 to 100
9179 /// inclusive. If the page_size is zero or unspecified, a page size of 5 will
9180 /// be chosen. If the page size exceeds 100, it will be coerced down to 100.
9181 /// Note that a call might return fewer results than the requested page size.
9182 pub page_size: i32,
9183
9184 /// A page token, received from a previous
9185 /// [ListCustomClasses][google.cloud.speech.v2.Speech.ListCustomClasses] call.
9186 /// Provide this to retrieve the subsequent page.
9187 ///
9188 /// When paginating, all other parameters provided to
9189 /// [ListCustomClasses][google.cloud.speech.v2.Speech.ListCustomClasses] must
9190 /// match the call that provided the page token.
9191 ///
9192 /// [google.cloud.speech.v2.Speech.ListCustomClasses]: crate::client::Speech::list_custom_classes
9193 pub page_token: std::string::String,
9194
9195 /// Whether, or not, to show resources that have been deleted.
9196 pub show_deleted: bool,
9197
9198 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9199}
9200
9201impl ListCustomClassesRequest {
9202 /// Creates a new default instance.
9203 pub fn new() -> Self {
9204 std::default::Default::default()
9205 }
9206
9207 /// Sets the value of [parent][crate::model::ListCustomClassesRequest::parent].
9208 ///
9209 /// # Example
9210 /// ```ignore,no_run
9211 /// # use google_cloud_speech_v2::model::ListCustomClassesRequest;
9212 /// let x = ListCustomClassesRequest::new().set_parent("example");
9213 /// ```
9214 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9215 self.parent = v.into();
9216 self
9217 }
9218
9219 /// Sets the value of [page_size][crate::model::ListCustomClassesRequest::page_size].
9220 ///
9221 /// # Example
9222 /// ```ignore,no_run
9223 /// # use google_cloud_speech_v2::model::ListCustomClassesRequest;
9224 /// let x = ListCustomClassesRequest::new().set_page_size(42);
9225 /// ```
9226 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
9227 self.page_size = v.into();
9228 self
9229 }
9230
9231 /// Sets the value of [page_token][crate::model::ListCustomClassesRequest::page_token].
9232 ///
9233 /// # Example
9234 /// ```ignore,no_run
9235 /// # use google_cloud_speech_v2::model::ListCustomClassesRequest;
9236 /// let x = ListCustomClassesRequest::new().set_page_token("example");
9237 /// ```
9238 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9239 self.page_token = v.into();
9240 self
9241 }
9242
9243 /// Sets the value of [show_deleted][crate::model::ListCustomClassesRequest::show_deleted].
9244 ///
9245 /// # Example
9246 /// ```ignore,no_run
9247 /// # use google_cloud_speech_v2::model::ListCustomClassesRequest;
9248 /// let x = ListCustomClassesRequest::new().set_show_deleted(true);
9249 /// ```
9250 pub fn set_show_deleted<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
9251 self.show_deleted = v.into();
9252 self
9253 }
9254}
9255
9256impl wkt::message::Message for ListCustomClassesRequest {
9257 fn typename() -> &'static str {
9258 "type.googleapis.com/google.cloud.speech.v2.ListCustomClassesRequest"
9259 }
9260}
9261
9262/// Response message for the
9263/// [ListCustomClasses][google.cloud.speech.v2.Speech.ListCustomClasses] method.
9264///
9265/// [google.cloud.speech.v2.Speech.ListCustomClasses]: crate::client::Speech::list_custom_classes
9266#[derive(Clone, Default, PartialEq)]
9267#[non_exhaustive]
9268pub struct ListCustomClassesResponse {
9269 /// The list of requested CustomClasses.
9270 pub custom_classes: std::vec::Vec<crate::model::CustomClass>,
9271
9272 /// A token, which can be sent as
9273 /// [page_token][google.cloud.speech.v2.ListCustomClassesRequest.page_token] to
9274 /// retrieve the next page. If this field is omitted, there are no subsequent
9275 /// pages. This token expires after 72 hours.
9276 ///
9277 /// [google.cloud.speech.v2.ListCustomClassesRequest.page_token]: crate::model::ListCustomClassesRequest::page_token
9278 pub next_page_token: std::string::String,
9279
9280 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9281}
9282
9283impl ListCustomClassesResponse {
9284 /// Creates a new default instance.
9285 pub fn new() -> Self {
9286 std::default::Default::default()
9287 }
9288
9289 /// Sets the value of [custom_classes][crate::model::ListCustomClassesResponse::custom_classes].
9290 ///
9291 /// # Example
9292 /// ```ignore,no_run
9293 /// # use google_cloud_speech_v2::model::ListCustomClassesResponse;
9294 /// use google_cloud_speech_v2::model::CustomClass;
9295 /// let x = ListCustomClassesResponse::new()
9296 /// .set_custom_classes([
9297 /// CustomClass::default()/* use setters */,
9298 /// CustomClass::default()/* use (different) setters */,
9299 /// ]);
9300 /// ```
9301 pub fn set_custom_classes<T, V>(mut self, v: T) -> Self
9302 where
9303 T: std::iter::IntoIterator<Item = V>,
9304 V: std::convert::Into<crate::model::CustomClass>,
9305 {
9306 use std::iter::Iterator;
9307 self.custom_classes = v.into_iter().map(|i| i.into()).collect();
9308 self
9309 }
9310
9311 /// Sets the value of [next_page_token][crate::model::ListCustomClassesResponse::next_page_token].
9312 ///
9313 /// # Example
9314 /// ```ignore,no_run
9315 /// # use google_cloud_speech_v2::model::ListCustomClassesResponse;
9316 /// let x = ListCustomClassesResponse::new().set_next_page_token("example");
9317 /// ```
9318 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9319 self.next_page_token = v.into();
9320 self
9321 }
9322}
9323
9324impl wkt::message::Message for ListCustomClassesResponse {
9325 fn typename() -> &'static str {
9326 "type.googleapis.com/google.cloud.speech.v2.ListCustomClassesResponse"
9327 }
9328}
9329
9330#[doc(hidden)]
9331impl google_cloud_gax::paginator::internal::PageableResponse for ListCustomClassesResponse {
9332 type PageItem = crate::model::CustomClass;
9333
9334 fn items(self) -> std::vec::Vec<Self::PageItem> {
9335 self.custom_classes
9336 }
9337
9338 fn next_page_token(&self) -> std::string::String {
9339 use std::clone::Clone;
9340 self.next_page_token.clone()
9341 }
9342}
9343
9344/// Request message for the
9345/// [GetCustomClass][google.cloud.speech.v2.Speech.GetCustomClass] method.
9346///
9347/// [google.cloud.speech.v2.Speech.GetCustomClass]: crate::client::Speech::get_custom_class
9348#[derive(Clone, Default, PartialEq)]
9349#[non_exhaustive]
9350pub struct GetCustomClassRequest {
9351 /// Required. The name of the CustomClass to retrieve. The expected format is
9352 /// `projects/{project}/locations/{location}/customClasses/{custom_class}`.
9353 pub name: std::string::String,
9354
9355 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9356}
9357
9358impl GetCustomClassRequest {
9359 /// Creates a new default instance.
9360 pub fn new() -> Self {
9361 std::default::Default::default()
9362 }
9363
9364 /// Sets the value of [name][crate::model::GetCustomClassRequest::name].
9365 ///
9366 /// # Example
9367 /// ```ignore,no_run
9368 /// # use google_cloud_speech_v2::model::GetCustomClassRequest;
9369 /// # let project_id = "project_id";
9370 /// # let location_id = "location_id";
9371 /// # let custom_class_id = "custom_class_id";
9372 /// let x = GetCustomClassRequest::new().set_name(format!("projects/{project_id}/locations/{location_id}/customClasses/{custom_class_id}"));
9373 /// ```
9374 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9375 self.name = v.into();
9376 self
9377 }
9378}
9379
9380impl wkt::message::Message for GetCustomClassRequest {
9381 fn typename() -> &'static str {
9382 "type.googleapis.com/google.cloud.speech.v2.GetCustomClassRequest"
9383 }
9384}
9385
9386/// Request message for the
9387/// [UpdateCustomClass][google.cloud.speech.v2.Speech.UpdateCustomClass] method.
9388///
9389/// [google.cloud.speech.v2.Speech.UpdateCustomClass]: crate::client::Speech::update_custom_class
9390#[derive(Clone, Default, PartialEq)]
9391#[non_exhaustive]
9392pub struct UpdateCustomClassRequest {
9393 /// Required. The CustomClass to update.
9394 ///
9395 /// The CustomClass's `name` field is used to identify the CustomClass to
9396 /// update. Format:
9397 /// `projects/{project}/locations/{location}/customClasses/{custom_class}`.
9398 pub custom_class: std::option::Option<crate::model::CustomClass>,
9399
9400 /// The list of fields to be updated. If empty, all fields are considered for
9401 /// update.
9402 pub update_mask: std::option::Option<wkt::FieldMask>,
9403
9404 /// If set, validate the request and preview the updated CustomClass, but do
9405 /// not actually update it.
9406 pub validate_only: bool,
9407
9408 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9409}
9410
9411impl UpdateCustomClassRequest {
9412 /// Creates a new default instance.
9413 pub fn new() -> Self {
9414 std::default::Default::default()
9415 }
9416
9417 /// Sets the value of [custom_class][crate::model::UpdateCustomClassRequest::custom_class].
9418 ///
9419 /// # Example
9420 /// ```ignore,no_run
9421 /// # use google_cloud_speech_v2::model::UpdateCustomClassRequest;
9422 /// use google_cloud_speech_v2::model::CustomClass;
9423 /// let x = UpdateCustomClassRequest::new().set_custom_class(CustomClass::default()/* use setters */);
9424 /// ```
9425 pub fn set_custom_class<T>(mut self, v: T) -> Self
9426 where
9427 T: std::convert::Into<crate::model::CustomClass>,
9428 {
9429 self.custom_class = std::option::Option::Some(v.into());
9430 self
9431 }
9432
9433 /// Sets or clears the value of [custom_class][crate::model::UpdateCustomClassRequest::custom_class].
9434 ///
9435 /// # Example
9436 /// ```ignore,no_run
9437 /// # use google_cloud_speech_v2::model::UpdateCustomClassRequest;
9438 /// use google_cloud_speech_v2::model::CustomClass;
9439 /// let x = UpdateCustomClassRequest::new().set_or_clear_custom_class(Some(CustomClass::default()/* use setters */));
9440 /// let x = UpdateCustomClassRequest::new().set_or_clear_custom_class(None::<CustomClass>);
9441 /// ```
9442 pub fn set_or_clear_custom_class<T>(mut self, v: std::option::Option<T>) -> Self
9443 where
9444 T: std::convert::Into<crate::model::CustomClass>,
9445 {
9446 self.custom_class = v.map(|x| x.into());
9447 self
9448 }
9449
9450 /// Sets the value of [update_mask][crate::model::UpdateCustomClassRequest::update_mask].
9451 ///
9452 /// # Example
9453 /// ```ignore,no_run
9454 /// # use google_cloud_speech_v2::model::UpdateCustomClassRequest;
9455 /// use wkt::FieldMask;
9456 /// let x = UpdateCustomClassRequest::new().set_update_mask(FieldMask::default()/* use setters */);
9457 /// ```
9458 pub fn set_update_mask<T>(mut self, v: T) -> Self
9459 where
9460 T: std::convert::Into<wkt::FieldMask>,
9461 {
9462 self.update_mask = std::option::Option::Some(v.into());
9463 self
9464 }
9465
9466 /// Sets or clears the value of [update_mask][crate::model::UpdateCustomClassRequest::update_mask].
9467 ///
9468 /// # Example
9469 /// ```ignore,no_run
9470 /// # use google_cloud_speech_v2::model::UpdateCustomClassRequest;
9471 /// use wkt::FieldMask;
9472 /// let x = UpdateCustomClassRequest::new().set_or_clear_update_mask(Some(FieldMask::default()/* use setters */));
9473 /// let x = UpdateCustomClassRequest::new().set_or_clear_update_mask(None::<FieldMask>);
9474 /// ```
9475 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
9476 where
9477 T: std::convert::Into<wkt::FieldMask>,
9478 {
9479 self.update_mask = v.map(|x| x.into());
9480 self
9481 }
9482
9483 /// Sets the value of [validate_only][crate::model::UpdateCustomClassRequest::validate_only].
9484 ///
9485 /// # Example
9486 /// ```ignore,no_run
9487 /// # use google_cloud_speech_v2::model::UpdateCustomClassRequest;
9488 /// let x = UpdateCustomClassRequest::new().set_validate_only(true);
9489 /// ```
9490 pub fn set_validate_only<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
9491 self.validate_only = v.into();
9492 self
9493 }
9494}
9495
9496impl wkt::message::Message for UpdateCustomClassRequest {
9497 fn typename() -> &'static str {
9498 "type.googleapis.com/google.cloud.speech.v2.UpdateCustomClassRequest"
9499 }
9500}
9501
9502/// Request message for the
9503/// [DeleteCustomClass][google.cloud.speech.v2.Speech.DeleteCustomClass] method.
9504///
9505/// [google.cloud.speech.v2.Speech.DeleteCustomClass]: crate::client::Speech::delete_custom_class
9506#[derive(Clone, Default, PartialEq)]
9507#[non_exhaustive]
9508pub struct DeleteCustomClassRequest {
9509 /// Required. The name of the CustomClass to delete.
9510 /// Format:
9511 /// `projects/{project}/locations/{location}/customClasses/{custom_class}`
9512 pub name: std::string::String,
9513
9514 /// If set, validate the request and preview the deleted CustomClass, but do
9515 /// not actually delete it.
9516 pub validate_only: bool,
9517
9518 /// If set to true, and the CustomClass is not found, the request will succeed
9519 /// and be a no-op (no Operation is recorded in this case).
9520 pub allow_missing: bool,
9521
9522 /// This checksum is computed by the server based on the value of other
9523 /// fields. This may be sent on update, undelete, and delete requests to ensure
9524 /// the client has an up-to-date value before proceeding.
9525 pub etag: std::string::String,
9526
9527 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9528}
9529
9530impl DeleteCustomClassRequest {
9531 /// Creates a new default instance.
9532 pub fn new() -> Self {
9533 std::default::Default::default()
9534 }
9535
9536 /// Sets the value of [name][crate::model::DeleteCustomClassRequest::name].
9537 ///
9538 /// # Example
9539 /// ```ignore,no_run
9540 /// # use google_cloud_speech_v2::model::DeleteCustomClassRequest;
9541 /// # let project_id = "project_id";
9542 /// # let location_id = "location_id";
9543 /// # let custom_class_id = "custom_class_id";
9544 /// let x = DeleteCustomClassRequest::new().set_name(format!("projects/{project_id}/locations/{location_id}/customClasses/{custom_class_id}"));
9545 /// ```
9546 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9547 self.name = v.into();
9548 self
9549 }
9550
9551 /// Sets the value of [validate_only][crate::model::DeleteCustomClassRequest::validate_only].
9552 ///
9553 /// # Example
9554 /// ```ignore,no_run
9555 /// # use google_cloud_speech_v2::model::DeleteCustomClassRequest;
9556 /// let x = DeleteCustomClassRequest::new().set_validate_only(true);
9557 /// ```
9558 pub fn set_validate_only<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
9559 self.validate_only = v.into();
9560 self
9561 }
9562
9563 /// Sets the value of [allow_missing][crate::model::DeleteCustomClassRequest::allow_missing].
9564 ///
9565 /// # Example
9566 /// ```ignore,no_run
9567 /// # use google_cloud_speech_v2::model::DeleteCustomClassRequest;
9568 /// let x = DeleteCustomClassRequest::new().set_allow_missing(true);
9569 /// ```
9570 pub fn set_allow_missing<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
9571 self.allow_missing = v.into();
9572 self
9573 }
9574
9575 /// Sets the value of [etag][crate::model::DeleteCustomClassRequest::etag].
9576 ///
9577 /// # Example
9578 /// ```ignore,no_run
9579 /// # use google_cloud_speech_v2::model::DeleteCustomClassRequest;
9580 /// let x = DeleteCustomClassRequest::new().set_etag("example");
9581 /// ```
9582 pub fn set_etag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9583 self.etag = v.into();
9584 self
9585 }
9586}
9587
9588impl wkt::message::Message for DeleteCustomClassRequest {
9589 fn typename() -> &'static str {
9590 "type.googleapis.com/google.cloud.speech.v2.DeleteCustomClassRequest"
9591 }
9592}
9593
9594/// Request message for the
9595/// [UndeleteCustomClass][google.cloud.speech.v2.Speech.UndeleteCustomClass]
9596/// method.
9597///
9598/// [google.cloud.speech.v2.Speech.UndeleteCustomClass]: crate::client::Speech::undelete_custom_class
9599#[derive(Clone, Default, PartialEq)]
9600#[non_exhaustive]
9601pub struct UndeleteCustomClassRequest {
9602 /// Required. The name of the CustomClass to undelete.
9603 /// Format:
9604 /// `projects/{project}/locations/{location}/customClasses/{custom_class}`
9605 pub name: std::string::String,
9606
9607 /// If set, validate the request and preview the undeleted CustomClass, but do
9608 /// not actually undelete it.
9609 pub validate_only: bool,
9610
9611 /// This checksum is computed by the server based on the value of other
9612 /// fields. This may be sent on update, undelete, and delete requests to ensure
9613 /// the client has an up-to-date value before proceeding.
9614 pub etag: std::string::String,
9615
9616 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9617}
9618
9619impl UndeleteCustomClassRequest {
9620 /// Creates a new default instance.
9621 pub fn new() -> Self {
9622 std::default::Default::default()
9623 }
9624
9625 /// Sets the value of [name][crate::model::UndeleteCustomClassRequest::name].
9626 ///
9627 /// # Example
9628 /// ```ignore,no_run
9629 /// # use google_cloud_speech_v2::model::UndeleteCustomClassRequest;
9630 /// # let project_id = "project_id";
9631 /// # let location_id = "location_id";
9632 /// # let custom_class_id = "custom_class_id";
9633 /// let x = UndeleteCustomClassRequest::new().set_name(format!("projects/{project_id}/locations/{location_id}/customClasses/{custom_class_id}"));
9634 /// ```
9635 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9636 self.name = v.into();
9637 self
9638 }
9639
9640 /// Sets the value of [validate_only][crate::model::UndeleteCustomClassRequest::validate_only].
9641 ///
9642 /// # Example
9643 /// ```ignore,no_run
9644 /// # use google_cloud_speech_v2::model::UndeleteCustomClassRequest;
9645 /// let x = UndeleteCustomClassRequest::new().set_validate_only(true);
9646 /// ```
9647 pub fn set_validate_only<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
9648 self.validate_only = v.into();
9649 self
9650 }
9651
9652 /// Sets the value of [etag][crate::model::UndeleteCustomClassRequest::etag].
9653 ///
9654 /// # Example
9655 /// ```ignore,no_run
9656 /// # use google_cloud_speech_v2::model::UndeleteCustomClassRequest;
9657 /// let x = UndeleteCustomClassRequest::new().set_etag("example");
9658 /// ```
9659 pub fn set_etag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9660 self.etag = v.into();
9661 self
9662 }
9663}
9664
9665impl wkt::message::Message for UndeleteCustomClassRequest {
9666 fn typename() -> &'static str {
9667 "type.googleapis.com/google.cloud.speech.v2.UndeleteCustomClassRequest"
9668 }
9669}
9670
9671/// Request message for the
9672/// [CreatePhraseSet][google.cloud.speech.v2.Speech.CreatePhraseSet] method.
9673///
9674/// [google.cloud.speech.v2.Speech.CreatePhraseSet]: crate::client::Speech::create_phrase_set
9675#[derive(Clone, Default, PartialEq)]
9676#[non_exhaustive]
9677pub struct CreatePhraseSetRequest {
9678 /// Required. The PhraseSet to create.
9679 pub phrase_set: std::option::Option<crate::model::PhraseSet>,
9680
9681 /// If set, validate the request and preview the PhraseSet, but do not
9682 /// actually create it.
9683 pub validate_only: bool,
9684
9685 /// The ID to use for the PhraseSet, which will become the final component of
9686 /// the PhraseSet's resource name.
9687 ///
9688 /// This value should be 4-63 characters, and valid characters
9689 /// are /[a-z][0-9]-/.
9690 pub phrase_set_id: std::string::String,
9691
9692 /// Required. The project and location where this PhraseSet will be created.
9693 /// The expected format is `projects/{project}/locations/{location}`.
9694 pub parent: std::string::String,
9695
9696 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9697}
9698
9699impl CreatePhraseSetRequest {
9700 /// Creates a new default instance.
9701 pub fn new() -> Self {
9702 std::default::Default::default()
9703 }
9704
9705 /// Sets the value of [phrase_set][crate::model::CreatePhraseSetRequest::phrase_set].
9706 ///
9707 /// # Example
9708 /// ```ignore,no_run
9709 /// # use google_cloud_speech_v2::model::CreatePhraseSetRequest;
9710 /// use google_cloud_speech_v2::model::PhraseSet;
9711 /// let x = CreatePhraseSetRequest::new().set_phrase_set(PhraseSet::default()/* use setters */);
9712 /// ```
9713 pub fn set_phrase_set<T>(mut self, v: T) -> Self
9714 where
9715 T: std::convert::Into<crate::model::PhraseSet>,
9716 {
9717 self.phrase_set = std::option::Option::Some(v.into());
9718 self
9719 }
9720
9721 /// Sets or clears the value of [phrase_set][crate::model::CreatePhraseSetRequest::phrase_set].
9722 ///
9723 /// # Example
9724 /// ```ignore,no_run
9725 /// # use google_cloud_speech_v2::model::CreatePhraseSetRequest;
9726 /// use google_cloud_speech_v2::model::PhraseSet;
9727 /// let x = CreatePhraseSetRequest::new().set_or_clear_phrase_set(Some(PhraseSet::default()/* use setters */));
9728 /// let x = CreatePhraseSetRequest::new().set_or_clear_phrase_set(None::<PhraseSet>);
9729 /// ```
9730 pub fn set_or_clear_phrase_set<T>(mut self, v: std::option::Option<T>) -> Self
9731 where
9732 T: std::convert::Into<crate::model::PhraseSet>,
9733 {
9734 self.phrase_set = v.map(|x| x.into());
9735 self
9736 }
9737
9738 /// Sets the value of [validate_only][crate::model::CreatePhraseSetRequest::validate_only].
9739 ///
9740 /// # Example
9741 /// ```ignore,no_run
9742 /// # use google_cloud_speech_v2::model::CreatePhraseSetRequest;
9743 /// let x = CreatePhraseSetRequest::new().set_validate_only(true);
9744 /// ```
9745 pub fn set_validate_only<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
9746 self.validate_only = v.into();
9747 self
9748 }
9749
9750 /// Sets the value of [phrase_set_id][crate::model::CreatePhraseSetRequest::phrase_set_id].
9751 ///
9752 /// # Example
9753 /// ```ignore,no_run
9754 /// # use google_cloud_speech_v2::model::CreatePhraseSetRequest;
9755 /// let x = CreatePhraseSetRequest::new().set_phrase_set_id("example");
9756 /// ```
9757 pub fn set_phrase_set_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9758 self.phrase_set_id = v.into();
9759 self
9760 }
9761
9762 /// Sets the value of [parent][crate::model::CreatePhraseSetRequest::parent].
9763 ///
9764 /// # Example
9765 /// ```ignore,no_run
9766 /// # use google_cloud_speech_v2::model::CreatePhraseSetRequest;
9767 /// # let project_id = "project_id";
9768 /// # let location_id = "location_id";
9769 /// let x = CreatePhraseSetRequest::new().set_parent(format!("projects/{project_id}/locations/{location_id}"));
9770 /// ```
9771 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9772 self.parent = v.into();
9773 self
9774 }
9775}
9776
9777impl wkt::message::Message for CreatePhraseSetRequest {
9778 fn typename() -> &'static str {
9779 "type.googleapis.com/google.cloud.speech.v2.CreatePhraseSetRequest"
9780 }
9781}
9782
9783/// Request message for the
9784/// [ListPhraseSets][google.cloud.speech.v2.Speech.ListPhraseSets] method.
9785///
9786/// [google.cloud.speech.v2.Speech.ListPhraseSets]: crate::client::Speech::list_phrase_sets
9787#[derive(Clone, Default, PartialEq)]
9788#[non_exhaustive]
9789pub struct ListPhraseSetsRequest {
9790 /// Required. The project and location of PhraseSet resources to list. The
9791 /// expected format is `projects/{project}/locations/{location}`.
9792 pub parent: std::string::String,
9793
9794 /// The maximum number of PhraseSets to return. The service may return fewer
9795 /// than this value. If unspecified, at most 5 PhraseSets will be returned.
9796 /// The maximum value is 100; values above 100 will be coerced to 100.
9797 pub page_size: i32,
9798
9799 /// A page token, received from a previous
9800 /// [ListPhraseSets][google.cloud.speech.v2.Speech.ListPhraseSets] call.
9801 /// Provide this to retrieve the subsequent page.
9802 ///
9803 /// When paginating, all other parameters provided to
9804 /// [ListPhraseSets][google.cloud.speech.v2.Speech.ListPhraseSets] must match
9805 /// the call that provided the page token.
9806 ///
9807 /// [google.cloud.speech.v2.Speech.ListPhraseSets]: crate::client::Speech::list_phrase_sets
9808 pub page_token: std::string::String,
9809
9810 /// Whether, or not, to show resources that have been deleted.
9811 pub show_deleted: bool,
9812
9813 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9814}
9815
9816impl ListPhraseSetsRequest {
9817 /// Creates a new default instance.
9818 pub fn new() -> Self {
9819 std::default::Default::default()
9820 }
9821
9822 /// Sets the value of [parent][crate::model::ListPhraseSetsRequest::parent].
9823 ///
9824 /// # Example
9825 /// ```ignore,no_run
9826 /// # use google_cloud_speech_v2::model::ListPhraseSetsRequest;
9827 /// let x = ListPhraseSetsRequest::new().set_parent("example");
9828 /// ```
9829 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9830 self.parent = v.into();
9831 self
9832 }
9833
9834 /// Sets the value of [page_size][crate::model::ListPhraseSetsRequest::page_size].
9835 ///
9836 /// # Example
9837 /// ```ignore,no_run
9838 /// # use google_cloud_speech_v2::model::ListPhraseSetsRequest;
9839 /// let x = ListPhraseSetsRequest::new().set_page_size(42);
9840 /// ```
9841 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
9842 self.page_size = v.into();
9843 self
9844 }
9845
9846 /// Sets the value of [page_token][crate::model::ListPhraseSetsRequest::page_token].
9847 ///
9848 /// # Example
9849 /// ```ignore,no_run
9850 /// # use google_cloud_speech_v2::model::ListPhraseSetsRequest;
9851 /// let x = ListPhraseSetsRequest::new().set_page_token("example");
9852 /// ```
9853 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9854 self.page_token = v.into();
9855 self
9856 }
9857
9858 /// Sets the value of [show_deleted][crate::model::ListPhraseSetsRequest::show_deleted].
9859 ///
9860 /// # Example
9861 /// ```ignore,no_run
9862 /// # use google_cloud_speech_v2::model::ListPhraseSetsRequest;
9863 /// let x = ListPhraseSetsRequest::new().set_show_deleted(true);
9864 /// ```
9865 pub fn set_show_deleted<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
9866 self.show_deleted = v.into();
9867 self
9868 }
9869}
9870
9871impl wkt::message::Message for ListPhraseSetsRequest {
9872 fn typename() -> &'static str {
9873 "type.googleapis.com/google.cloud.speech.v2.ListPhraseSetsRequest"
9874 }
9875}
9876
9877/// Response message for the
9878/// [ListPhraseSets][google.cloud.speech.v2.Speech.ListPhraseSets] method.
9879///
9880/// [google.cloud.speech.v2.Speech.ListPhraseSets]: crate::client::Speech::list_phrase_sets
9881#[derive(Clone, Default, PartialEq)]
9882#[non_exhaustive]
9883pub struct ListPhraseSetsResponse {
9884 /// The list of requested PhraseSets.
9885 pub phrase_sets: std::vec::Vec<crate::model::PhraseSet>,
9886
9887 /// A token, which can be sent as
9888 /// [page_token][google.cloud.speech.v2.ListPhraseSetsRequest.page_token] to
9889 /// retrieve the next page. If this field is omitted, there are no subsequent
9890 /// pages. This token expires after 72 hours.
9891 ///
9892 /// [google.cloud.speech.v2.ListPhraseSetsRequest.page_token]: crate::model::ListPhraseSetsRequest::page_token
9893 pub next_page_token: std::string::String,
9894
9895 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9896}
9897
9898impl ListPhraseSetsResponse {
9899 /// Creates a new default instance.
9900 pub fn new() -> Self {
9901 std::default::Default::default()
9902 }
9903
9904 /// Sets the value of [phrase_sets][crate::model::ListPhraseSetsResponse::phrase_sets].
9905 ///
9906 /// # Example
9907 /// ```ignore,no_run
9908 /// # use google_cloud_speech_v2::model::ListPhraseSetsResponse;
9909 /// use google_cloud_speech_v2::model::PhraseSet;
9910 /// let x = ListPhraseSetsResponse::new()
9911 /// .set_phrase_sets([
9912 /// PhraseSet::default()/* use setters */,
9913 /// PhraseSet::default()/* use (different) setters */,
9914 /// ]);
9915 /// ```
9916 pub fn set_phrase_sets<T, V>(mut self, v: T) -> Self
9917 where
9918 T: std::iter::IntoIterator<Item = V>,
9919 V: std::convert::Into<crate::model::PhraseSet>,
9920 {
9921 use std::iter::Iterator;
9922 self.phrase_sets = v.into_iter().map(|i| i.into()).collect();
9923 self
9924 }
9925
9926 /// Sets the value of [next_page_token][crate::model::ListPhraseSetsResponse::next_page_token].
9927 ///
9928 /// # Example
9929 /// ```ignore,no_run
9930 /// # use google_cloud_speech_v2::model::ListPhraseSetsResponse;
9931 /// let x = ListPhraseSetsResponse::new().set_next_page_token("example");
9932 /// ```
9933 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9934 self.next_page_token = v.into();
9935 self
9936 }
9937}
9938
9939impl wkt::message::Message for ListPhraseSetsResponse {
9940 fn typename() -> &'static str {
9941 "type.googleapis.com/google.cloud.speech.v2.ListPhraseSetsResponse"
9942 }
9943}
9944
9945#[doc(hidden)]
9946impl google_cloud_gax::paginator::internal::PageableResponse for ListPhraseSetsResponse {
9947 type PageItem = crate::model::PhraseSet;
9948
9949 fn items(self) -> std::vec::Vec<Self::PageItem> {
9950 self.phrase_sets
9951 }
9952
9953 fn next_page_token(&self) -> std::string::String {
9954 use std::clone::Clone;
9955 self.next_page_token.clone()
9956 }
9957}
9958
9959/// Request message for the
9960/// [GetPhraseSet][google.cloud.speech.v2.Speech.GetPhraseSet] method.
9961///
9962/// [google.cloud.speech.v2.Speech.GetPhraseSet]: crate::client::Speech::get_phrase_set
9963#[derive(Clone, Default, PartialEq)]
9964#[non_exhaustive]
9965pub struct GetPhraseSetRequest {
9966 /// Required. The name of the PhraseSet to retrieve. The expected format is
9967 /// `projects/{project}/locations/{location}/phraseSets/{phrase_set}`.
9968 pub name: std::string::String,
9969
9970 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9971}
9972
9973impl GetPhraseSetRequest {
9974 /// Creates a new default instance.
9975 pub fn new() -> Self {
9976 std::default::Default::default()
9977 }
9978
9979 /// Sets the value of [name][crate::model::GetPhraseSetRequest::name].
9980 ///
9981 /// # Example
9982 /// ```ignore,no_run
9983 /// # use google_cloud_speech_v2::model::GetPhraseSetRequest;
9984 /// # let project_id = "project_id";
9985 /// # let location_id = "location_id";
9986 /// # let phrase_set_id = "phrase_set_id";
9987 /// let x = GetPhraseSetRequest::new().set_name(format!("projects/{project_id}/locations/{location_id}/phraseSets/{phrase_set_id}"));
9988 /// ```
9989 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9990 self.name = v.into();
9991 self
9992 }
9993}
9994
9995impl wkt::message::Message for GetPhraseSetRequest {
9996 fn typename() -> &'static str {
9997 "type.googleapis.com/google.cloud.speech.v2.GetPhraseSetRequest"
9998 }
9999}
10000
10001/// Request message for the
10002/// [UpdatePhraseSet][google.cloud.speech.v2.Speech.UpdatePhraseSet] method.
10003///
10004/// [google.cloud.speech.v2.Speech.UpdatePhraseSet]: crate::client::Speech::update_phrase_set
10005#[derive(Clone, Default, PartialEq)]
10006#[non_exhaustive]
10007pub struct UpdatePhraseSetRequest {
10008 /// Required. The PhraseSet to update.
10009 ///
10010 /// The PhraseSet's `name` field is used to identify the PhraseSet to update.
10011 /// Format: `projects/{project}/locations/{location}/phraseSets/{phrase_set}`.
10012 pub phrase_set: std::option::Option<crate::model::PhraseSet>,
10013
10014 /// The list of fields to update. If empty, all non-default valued fields are
10015 /// considered for update. Use `*` to update the entire PhraseSet resource.
10016 pub update_mask: std::option::Option<wkt::FieldMask>,
10017
10018 /// If set, validate the request and preview the updated PhraseSet, but do not
10019 /// actually update it.
10020 pub validate_only: bool,
10021
10022 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10023}
10024
10025impl UpdatePhraseSetRequest {
10026 /// Creates a new default instance.
10027 pub fn new() -> Self {
10028 std::default::Default::default()
10029 }
10030
10031 /// Sets the value of [phrase_set][crate::model::UpdatePhraseSetRequest::phrase_set].
10032 ///
10033 /// # Example
10034 /// ```ignore,no_run
10035 /// # use google_cloud_speech_v2::model::UpdatePhraseSetRequest;
10036 /// use google_cloud_speech_v2::model::PhraseSet;
10037 /// let x = UpdatePhraseSetRequest::new().set_phrase_set(PhraseSet::default()/* use setters */);
10038 /// ```
10039 pub fn set_phrase_set<T>(mut self, v: T) -> Self
10040 where
10041 T: std::convert::Into<crate::model::PhraseSet>,
10042 {
10043 self.phrase_set = std::option::Option::Some(v.into());
10044 self
10045 }
10046
10047 /// Sets or clears the value of [phrase_set][crate::model::UpdatePhraseSetRequest::phrase_set].
10048 ///
10049 /// # Example
10050 /// ```ignore,no_run
10051 /// # use google_cloud_speech_v2::model::UpdatePhraseSetRequest;
10052 /// use google_cloud_speech_v2::model::PhraseSet;
10053 /// let x = UpdatePhraseSetRequest::new().set_or_clear_phrase_set(Some(PhraseSet::default()/* use setters */));
10054 /// let x = UpdatePhraseSetRequest::new().set_or_clear_phrase_set(None::<PhraseSet>);
10055 /// ```
10056 pub fn set_or_clear_phrase_set<T>(mut self, v: std::option::Option<T>) -> Self
10057 where
10058 T: std::convert::Into<crate::model::PhraseSet>,
10059 {
10060 self.phrase_set = v.map(|x| x.into());
10061 self
10062 }
10063
10064 /// Sets the value of [update_mask][crate::model::UpdatePhraseSetRequest::update_mask].
10065 ///
10066 /// # Example
10067 /// ```ignore,no_run
10068 /// # use google_cloud_speech_v2::model::UpdatePhraseSetRequest;
10069 /// use wkt::FieldMask;
10070 /// let x = UpdatePhraseSetRequest::new().set_update_mask(FieldMask::default()/* use setters */);
10071 /// ```
10072 pub fn set_update_mask<T>(mut self, v: T) -> Self
10073 where
10074 T: std::convert::Into<wkt::FieldMask>,
10075 {
10076 self.update_mask = std::option::Option::Some(v.into());
10077 self
10078 }
10079
10080 /// Sets or clears the value of [update_mask][crate::model::UpdatePhraseSetRequest::update_mask].
10081 ///
10082 /// # Example
10083 /// ```ignore,no_run
10084 /// # use google_cloud_speech_v2::model::UpdatePhraseSetRequest;
10085 /// use wkt::FieldMask;
10086 /// let x = UpdatePhraseSetRequest::new().set_or_clear_update_mask(Some(FieldMask::default()/* use setters */));
10087 /// let x = UpdatePhraseSetRequest::new().set_or_clear_update_mask(None::<FieldMask>);
10088 /// ```
10089 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
10090 where
10091 T: std::convert::Into<wkt::FieldMask>,
10092 {
10093 self.update_mask = v.map(|x| x.into());
10094 self
10095 }
10096
10097 /// Sets the value of [validate_only][crate::model::UpdatePhraseSetRequest::validate_only].
10098 ///
10099 /// # Example
10100 /// ```ignore,no_run
10101 /// # use google_cloud_speech_v2::model::UpdatePhraseSetRequest;
10102 /// let x = UpdatePhraseSetRequest::new().set_validate_only(true);
10103 /// ```
10104 pub fn set_validate_only<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
10105 self.validate_only = v.into();
10106 self
10107 }
10108}
10109
10110impl wkt::message::Message for UpdatePhraseSetRequest {
10111 fn typename() -> &'static str {
10112 "type.googleapis.com/google.cloud.speech.v2.UpdatePhraseSetRequest"
10113 }
10114}
10115
10116/// Request message for the
10117/// [DeletePhraseSet][google.cloud.speech.v2.Speech.DeletePhraseSet] method.
10118///
10119/// [google.cloud.speech.v2.Speech.DeletePhraseSet]: crate::client::Speech::delete_phrase_set
10120#[derive(Clone, Default, PartialEq)]
10121#[non_exhaustive]
10122pub struct DeletePhraseSetRequest {
10123 /// Required. The name of the PhraseSet to delete.
10124 /// Format: `projects/{project}/locations/{location}/phraseSets/{phrase_set}`
10125 pub name: std::string::String,
10126
10127 /// If set, validate the request and preview the deleted PhraseSet, but do not
10128 /// actually delete it.
10129 pub validate_only: bool,
10130
10131 /// If set to true, and the PhraseSet is not found, the request will succeed
10132 /// and be a no-op (no Operation is recorded in this case).
10133 pub allow_missing: bool,
10134
10135 /// This checksum is computed by the server based on the value of other
10136 /// fields. This may be sent on update, undelete, and delete requests to ensure
10137 /// the client has an up-to-date value before proceeding.
10138 pub etag: std::string::String,
10139
10140 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10141}
10142
10143impl DeletePhraseSetRequest {
10144 /// Creates a new default instance.
10145 pub fn new() -> Self {
10146 std::default::Default::default()
10147 }
10148
10149 /// Sets the value of [name][crate::model::DeletePhraseSetRequest::name].
10150 ///
10151 /// # Example
10152 /// ```ignore,no_run
10153 /// # use google_cloud_speech_v2::model::DeletePhraseSetRequest;
10154 /// # let project_id = "project_id";
10155 /// # let location_id = "location_id";
10156 /// # let phrase_set_id = "phrase_set_id";
10157 /// let x = DeletePhraseSetRequest::new().set_name(format!("projects/{project_id}/locations/{location_id}/phraseSets/{phrase_set_id}"));
10158 /// ```
10159 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
10160 self.name = v.into();
10161 self
10162 }
10163
10164 /// Sets the value of [validate_only][crate::model::DeletePhraseSetRequest::validate_only].
10165 ///
10166 /// # Example
10167 /// ```ignore,no_run
10168 /// # use google_cloud_speech_v2::model::DeletePhraseSetRequest;
10169 /// let x = DeletePhraseSetRequest::new().set_validate_only(true);
10170 /// ```
10171 pub fn set_validate_only<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
10172 self.validate_only = v.into();
10173 self
10174 }
10175
10176 /// Sets the value of [allow_missing][crate::model::DeletePhraseSetRequest::allow_missing].
10177 ///
10178 /// # Example
10179 /// ```ignore,no_run
10180 /// # use google_cloud_speech_v2::model::DeletePhraseSetRequest;
10181 /// let x = DeletePhraseSetRequest::new().set_allow_missing(true);
10182 /// ```
10183 pub fn set_allow_missing<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
10184 self.allow_missing = v.into();
10185 self
10186 }
10187
10188 /// Sets the value of [etag][crate::model::DeletePhraseSetRequest::etag].
10189 ///
10190 /// # Example
10191 /// ```ignore,no_run
10192 /// # use google_cloud_speech_v2::model::DeletePhraseSetRequest;
10193 /// let x = DeletePhraseSetRequest::new().set_etag("example");
10194 /// ```
10195 pub fn set_etag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
10196 self.etag = v.into();
10197 self
10198 }
10199}
10200
10201impl wkt::message::Message for DeletePhraseSetRequest {
10202 fn typename() -> &'static str {
10203 "type.googleapis.com/google.cloud.speech.v2.DeletePhraseSetRequest"
10204 }
10205}
10206
10207/// Request message for the
10208/// [UndeletePhraseSet][google.cloud.speech.v2.Speech.UndeletePhraseSet]
10209/// method.
10210///
10211/// [google.cloud.speech.v2.Speech.UndeletePhraseSet]: crate::client::Speech::undelete_phrase_set
10212#[derive(Clone, Default, PartialEq)]
10213#[non_exhaustive]
10214pub struct UndeletePhraseSetRequest {
10215 /// Required. The name of the PhraseSet to undelete.
10216 /// Format: `projects/{project}/locations/{location}/phraseSets/{phrase_set}`
10217 pub name: std::string::String,
10218
10219 /// If set, validate the request and preview the undeleted PhraseSet, but do
10220 /// not actually undelete it.
10221 pub validate_only: bool,
10222
10223 /// This checksum is computed by the server based on the value of other
10224 /// fields. This may be sent on update, undelete, and delete requests to ensure
10225 /// the client has an up-to-date value before proceeding.
10226 pub etag: std::string::String,
10227
10228 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10229}
10230
10231impl UndeletePhraseSetRequest {
10232 /// Creates a new default instance.
10233 pub fn new() -> Self {
10234 std::default::Default::default()
10235 }
10236
10237 /// Sets the value of [name][crate::model::UndeletePhraseSetRequest::name].
10238 ///
10239 /// # Example
10240 /// ```ignore,no_run
10241 /// # use google_cloud_speech_v2::model::UndeletePhraseSetRequest;
10242 /// # let project_id = "project_id";
10243 /// # let location_id = "location_id";
10244 /// # let phrase_set_id = "phrase_set_id";
10245 /// let x = UndeletePhraseSetRequest::new().set_name(format!("projects/{project_id}/locations/{location_id}/phraseSets/{phrase_set_id}"));
10246 /// ```
10247 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
10248 self.name = v.into();
10249 self
10250 }
10251
10252 /// Sets the value of [validate_only][crate::model::UndeletePhraseSetRequest::validate_only].
10253 ///
10254 /// # Example
10255 /// ```ignore,no_run
10256 /// # use google_cloud_speech_v2::model::UndeletePhraseSetRequest;
10257 /// let x = UndeletePhraseSetRequest::new().set_validate_only(true);
10258 /// ```
10259 pub fn set_validate_only<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
10260 self.validate_only = v.into();
10261 self
10262 }
10263
10264 /// Sets the value of [etag][crate::model::UndeletePhraseSetRequest::etag].
10265 ///
10266 /// # Example
10267 /// ```ignore,no_run
10268 /// # use google_cloud_speech_v2::model::UndeletePhraseSetRequest;
10269 /// let x = UndeletePhraseSetRequest::new().set_etag("example");
10270 /// ```
10271 pub fn set_etag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
10272 self.etag = v.into();
10273 self
10274 }
10275}
10276
10277impl wkt::message::Message for UndeletePhraseSetRequest {
10278 fn typename() -> &'static str {
10279 "type.googleapis.com/google.cloud.speech.v2.UndeletePhraseSetRequest"
10280 }
10281}
10282
10283/// Represents a singular feature of a model. If the feature is `recognizer`,
10284/// the release_state of the feature represents the release_state of the model
10285#[derive(Clone, Default, PartialEq)]
10286#[non_exhaustive]
10287pub struct ModelFeature {
10288 /// The name of the feature (Note: the feature can be `recognizer`)
10289 pub feature: std::string::String,
10290
10291 /// The release state of the feature
10292 pub release_state: std::string::String,
10293
10294 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10295}
10296
10297impl ModelFeature {
10298 /// Creates a new default instance.
10299 pub fn new() -> Self {
10300 std::default::Default::default()
10301 }
10302
10303 /// Sets the value of [feature][crate::model::ModelFeature::feature].
10304 ///
10305 /// # Example
10306 /// ```ignore,no_run
10307 /// # use google_cloud_speech_v2::model::ModelFeature;
10308 /// let x = ModelFeature::new().set_feature("example");
10309 /// ```
10310 pub fn set_feature<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
10311 self.feature = v.into();
10312 self
10313 }
10314
10315 /// Sets the value of [release_state][crate::model::ModelFeature::release_state].
10316 ///
10317 /// # Example
10318 /// ```ignore,no_run
10319 /// # use google_cloud_speech_v2::model::ModelFeature;
10320 /// let x = ModelFeature::new().set_release_state("example");
10321 /// ```
10322 pub fn set_release_state<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
10323 self.release_state = v.into();
10324 self
10325 }
10326}
10327
10328impl wkt::message::Message for ModelFeature {
10329 fn typename() -> &'static str {
10330 "type.googleapis.com/google.cloud.speech.v2.ModelFeature"
10331 }
10332}
10333
10334/// Represents the collection of features belonging to a model
10335#[derive(Clone, Default, PartialEq)]
10336#[non_exhaustive]
10337pub struct ModelFeatures {
10338 /// Repeated field that contains all features of the model
10339 pub model_feature: std::vec::Vec<crate::model::ModelFeature>,
10340
10341 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10342}
10343
10344impl ModelFeatures {
10345 /// Creates a new default instance.
10346 pub fn new() -> Self {
10347 std::default::Default::default()
10348 }
10349
10350 /// Sets the value of [model_feature][crate::model::ModelFeatures::model_feature].
10351 ///
10352 /// # Example
10353 /// ```ignore,no_run
10354 /// # use google_cloud_speech_v2::model::ModelFeatures;
10355 /// use google_cloud_speech_v2::model::ModelFeature;
10356 /// let x = ModelFeatures::new()
10357 /// .set_model_feature([
10358 /// ModelFeature::default()/* use setters */,
10359 /// ModelFeature::default()/* use (different) setters */,
10360 /// ]);
10361 /// ```
10362 pub fn set_model_feature<T, V>(mut self, v: T) -> Self
10363 where
10364 T: std::iter::IntoIterator<Item = V>,
10365 V: std::convert::Into<crate::model::ModelFeature>,
10366 {
10367 use std::iter::Iterator;
10368 self.model_feature = v.into_iter().map(|i| i.into()).collect();
10369 self
10370 }
10371}
10372
10373impl wkt::message::Message for ModelFeatures {
10374 fn typename() -> &'static str {
10375 "type.googleapis.com/google.cloud.speech.v2.ModelFeatures"
10376 }
10377}
10378
10379/// The metadata about the models in a given region for a specific locale.
10380/// Currently this is just the features of the model
10381#[derive(Clone, Default, PartialEq)]
10382#[non_exhaustive]
10383pub struct ModelMetadata {
10384 /// Map of the model name -> features of that model
10385 pub model_features: std::collections::HashMap<std::string::String, crate::model::ModelFeatures>,
10386
10387 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10388}
10389
10390impl ModelMetadata {
10391 /// Creates a new default instance.
10392 pub fn new() -> Self {
10393 std::default::Default::default()
10394 }
10395
10396 /// Sets the value of [model_features][crate::model::ModelMetadata::model_features].
10397 ///
10398 /// # Example
10399 /// ```ignore,no_run
10400 /// # use google_cloud_speech_v2::model::ModelMetadata;
10401 /// use google_cloud_speech_v2::model::ModelFeatures;
10402 /// let x = ModelMetadata::new().set_model_features([
10403 /// ("key0", ModelFeatures::default()/* use setters */),
10404 /// ("key1", ModelFeatures::default()/* use (different) setters */),
10405 /// ]);
10406 /// ```
10407 pub fn set_model_features<T, K, V>(mut self, v: T) -> Self
10408 where
10409 T: std::iter::IntoIterator<Item = (K, V)>,
10410 K: std::convert::Into<std::string::String>,
10411 V: std::convert::Into<crate::model::ModelFeatures>,
10412 {
10413 use std::iter::Iterator;
10414 self.model_features = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
10415 self
10416 }
10417}
10418
10419impl wkt::message::Message for ModelMetadata {
10420 fn typename() -> &'static str {
10421 "type.googleapis.com/google.cloud.speech.v2.ModelMetadata"
10422 }
10423}
10424
10425/// The metadata about locales available in a given region. Currently this is
10426/// just the models that are available for each locale
10427#[derive(Clone, Default, PartialEq)]
10428#[non_exhaustive]
10429pub struct LanguageMetadata {
10430 /// Map of locale (language code) -> models
10431 pub models: std::collections::HashMap<std::string::String, crate::model::ModelMetadata>,
10432
10433 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10434}
10435
10436impl LanguageMetadata {
10437 /// Creates a new default instance.
10438 pub fn new() -> Self {
10439 std::default::Default::default()
10440 }
10441
10442 /// Sets the value of [models][crate::model::LanguageMetadata::models].
10443 ///
10444 /// # Example
10445 /// ```ignore,no_run
10446 /// # use google_cloud_speech_v2::model::LanguageMetadata;
10447 /// use google_cloud_speech_v2::model::ModelMetadata;
10448 /// let x = LanguageMetadata::new().set_models([
10449 /// ("key0", ModelMetadata::default()/* use setters */),
10450 /// ("key1", ModelMetadata::default()/* use (different) setters */),
10451 /// ]);
10452 /// ```
10453 pub fn set_models<T, K, V>(mut self, v: T) -> Self
10454 where
10455 T: std::iter::IntoIterator<Item = (K, V)>,
10456 K: std::convert::Into<std::string::String>,
10457 V: std::convert::Into<crate::model::ModelMetadata>,
10458 {
10459 use std::iter::Iterator;
10460 self.models = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
10461 self
10462 }
10463}
10464
10465impl wkt::message::Message for LanguageMetadata {
10466 fn typename() -> &'static str {
10467 "type.googleapis.com/google.cloud.speech.v2.LanguageMetadata"
10468 }
10469}
10470
10471/// The access metadata for a particular region. This can be applied if the org
10472/// policy for the given project disallows a particular region.
10473#[derive(Clone, Default, PartialEq)]
10474#[non_exhaustive]
10475pub struct AccessMetadata {
10476 /// Describes the different types of constraints that are applied.
10477 pub constraint_type: crate::model::access_metadata::ConstraintType,
10478
10479 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10480}
10481
10482impl AccessMetadata {
10483 /// Creates a new default instance.
10484 pub fn new() -> Self {
10485 std::default::Default::default()
10486 }
10487
10488 /// Sets the value of [constraint_type][crate::model::AccessMetadata::constraint_type].
10489 ///
10490 /// # Example
10491 /// ```ignore,no_run
10492 /// # use google_cloud_speech_v2::model::AccessMetadata;
10493 /// use google_cloud_speech_v2::model::access_metadata::ConstraintType;
10494 /// let x0 = AccessMetadata::new().set_constraint_type(ConstraintType::ResourceLocationsOrgPolicyCreateConstraint);
10495 /// ```
10496 pub fn set_constraint_type<
10497 T: std::convert::Into<crate::model::access_metadata::ConstraintType>,
10498 >(
10499 mut self,
10500 v: T,
10501 ) -> Self {
10502 self.constraint_type = v.into();
10503 self
10504 }
10505}
10506
10507impl wkt::message::Message for AccessMetadata {
10508 fn typename() -> &'static str {
10509 "type.googleapis.com/google.cloud.speech.v2.AccessMetadata"
10510 }
10511}
10512
10513/// Defines additional types related to [AccessMetadata].
10514pub mod access_metadata {
10515 #[allow(unused_imports)]
10516 use super::*;
10517
10518 /// Describes the different types of constraints that can be applied on a
10519 /// region.
10520 ///
10521 /// # Working with unknown values
10522 ///
10523 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
10524 /// additional enum variants at any time. Adding new variants is not considered
10525 /// a breaking change. Applications should write their code in anticipation of:
10526 ///
10527 /// - New values appearing in future releases of the client library, **and**
10528 /// - New values received dynamically, without application changes.
10529 ///
10530 /// Please consult the [Working with enums] section in the user guide for some
10531 /// guidelines.
10532 ///
10533 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
10534 #[derive(Clone, Debug, PartialEq)]
10535 #[non_exhaustive]
10536 pub enum ConstraintType {
10537 /// Unspecified constraint applied.
10538 Unspecified,
10539 /// The project's org policy disallows the given region.
10540 ResourceLocationsOrgPolicyCreateConstraint,
10541 /// If set, the enum was initialized with an unknown value.
10542 ///
10543 /// Applications can examine the value using [ConstraintType::value] or
10544 /// [ConstraintType::name].
10545 UnknownValue(constraint_type::UnknownValue),
10546 }
10547
10548 #[doc(hidden)]
10549 pub mod constraint_type {
10550 #[allow(unused_imports)]
10551 use super::*;
10552 #[derive(Clone, Debug, PartialEq)]
10553 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
10554 }
10555
10556 impl ConstraintType {
10557 /// Gets the enum value.
10558 ///
10559 /// Returns `None` if the enum contains an unknown value deserialized from
10560 /// the string representation of enums.
10561 pub fn value(&self) -> std::option::Option<i32> {
10562 match self {
10563 Self::Unspecified => std::option::Option::Some(0),
10564 Self::ResourceLocationsOrgPolicyCreateConstraint => std::option::Option::Some(1),
10565 Self::UnknownValue(u) => u.0.value(),
10566 }
10567 }
10568
10569 /// Gets the enum value as a string.
10570 ///
10571 /// Returns `None` if the enum contains an unknown value deserialized from
10572 /// the integer representation of enums.
10573 pub fn name(&self) -> std::option::Option<&str> {
10574 match self {
10575 Self::Unspecified => std::option::Option::Some("CONSTRAINT_TYPE_UNSPECIFIED"),
10576 Self::ResourceLocationsOrgPolicyCreateConstraint => {
10577 std::option::Option::Some("RESOURCE_LOCATIONS_ORG_POLICY_CREATE_CONSTRAINT")
10578 }
10579 Self::UnknownValue(u) => u.0.name(),
10580 }
10581 }
10582 }
10583
10584 impl std::default::Default for ConstraintType {
10585 fn default() -> Self {
10586 use std::convert::From;
10587 Self::from(0)
10588 }
10589 }
10590
10591 impl std::fmt::Display for ConstraintType {
10592 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
10593 wkt::internal::display_enum(f, self.name(), self.value())
10594 }
10595 }
10596
10597 impl std::convert::From<i32> for ConstraintType {
10598 fn from(value: i32) -> Self {
10599 match value {
10600 0 => Self::Unspecified,
10601 1 => Self::ResourceLocationsOrgPolicyCreateConstraint,
10602 _ => Self::UnknownValue(constraint_type::UnknownValue(
10603 wkt::internal::UnknownEnumValue::Integer(value),
10604 )),
10605 }
10606 }
10607 }
10608
10609 impl std::convert::From<&str> for ConstraintType {
10610 fn from(value: &str) -> Self {
10611 use std::string::ToString;
10612 match value {
10613 "CONSTRAINT_TYPE_UNSPECIFIED" => Self::Unspecified,
10614 "RESOURCE_LOCATIONS_ORG_POLICY_CREATE_CONSTRAINT" => {
10615 Self::ResourceLocationsOrgPolicyCreateConstraint
10616 }
10617 _ => Self::UnknownValue(constraint_type::UnknownValue(
10618 wkt::internal::UnknownEnumValue::String(value.to_string()),
10619 )),
10620 }
10621 }
10622 }
10623
10624 impl serde::ser::Serialize for ConstraintType {
10625 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10626 where
10627 S: serde::Serializer,
10628 {
10629 match self {
10630 Self::Unspecified => serializer.serialize_i32(0),
10631 Self::ResourceLocationsOrgPolicyCreateConstraint => serializer.serialize_i32(1),
10632 Self::UnknownValue(u) => u.0.serialize(serializer),
10633 }
10634 }
10635 }
10636
10637 impl<'de> serde::de::Deserialize<'de> for ConstraintType {
10638 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10639 where
10640 D: serde::Deserializer<'de>,
10641 {
10642 deserializer.deserialize_any(wkt::internal::EnumVisitor::<ConstraintType>::new(
10643 ".google.cloud.speech.v2.AccessMetadata.ConstraintType",
10644 ))
10645 }
10646 }
10647}
10648
10649/// Main metadata for the Locations API for STT V2. Currently this is just the
10650/// metadata about locales, models, and features
10651#[derive(Clone, Default, PartialEq)]
10652#[non_exhaustive]
10653pub struct LocationsMetadata {
10654 /// Information about available locales, models, and features represented in
10655 /// the hierarchical structure of locales -> models -> features
10656 pub languages: std::option::Option<crate::model::LanguageMetadata>,
10657
10658 /// Information about access metadata for the region and given project.
10659 pub access_metadata: std::option::Option<crate::model::AccessMetadata>,
10660
10661 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10662}
10663
10664impl LocationsMetadata {
10665 /// Creates a new default instance.
10666 pub fn new() -> Self {
10667 std::default::Default::default()
10668 }
10669
10670 /// Sets the value of [languages][crate::model::LocationsMetadata::languages].
10671 ///
10672 /// # Example
10673 /// ```ignore,no_run
10674 /// # use google_cloud_speech_v2::model::LocationsMetadata;
10675 /// use google_cloud_speech_v2::model::LanguageMetadata;
10676 /// let x = LocationsMetadata::new().set_languages(LanguageMetadata::default()/* use setters */);
10677 /// ```
10678 pub fn set_languages<T>(mut self, v: T) -> Self
10679 where
10680 T: std::convert::Into<crate::model::LanguageMetadata>,
10681 {
10682 self.languages = std::option::Option::Some(v.into());
10683 self
10684 }
10685
10686 /// Sets or clears the value of [languages][crate::model::LocationsMetadata::languages].
10687 ///
10688 /// # Example
10689 /// ```ignore,no_run
10690 /// # use google_cloud_speech_v2::model::LocationsMetadata;
10691 /// use google_cloud_speech_v2::model::LanguageMetadata;
10692 /// let x = LocationsMetadata::new().set_or_clear_languages(Some(LanguageMetadata::default()/* use setters */));
10693 /// let x = LocationsMetadata::new().set_or_clear_languages(None::<LanguageMetadata>);
10694 /// ```
10695 pub fn set_or_clear_languages<T>(mut self, v: std::option::Option<T>) -> Self
10696 where
10697 T: std::convert::Into<crate::model::LanguageMetadata>,
10698 {
10699 self.languages = v.map(|x| x.into());
10700 self
10701 }
10702
10703 /// Sets the value of [access_metadata][crate::model::LocationsMetadata::access_metadata].
10704 ///
10705 /// # Example
10706 /// ```ignore,no_run
10707 /// # use google_cloud_speech_v2::model::LocationsMetadata;
10708 /// use google_cloud_speech_v2::model::AccessMetadata;
10709 /// let x = LocationsMetadata::new().set_access_metadata(AccessMetadata::default()/* use setters */);
10710 /// ```
10711 pub fn set_access_metadata<T>(mut self, v: T) -> Self
10712 where
10713 T: std::convert::Into<crate::model::AccessMetadata>,
10714 {
10715 self.access_metadata = std::option::Option::Some(v.into());
10716 self
10717 }
10718
10719 /// Sets or clears the value of [access_metadata][crate::model::LocationsMetadata::access_metadata].
10720 ///
10721 /// # Example
10722 /// ```ignore,no_run
10723 /// # use google_cloud_speech_v2::model::LocationsMetadata;
10724 /// use google_cloud_speech_v2::model::AccessMetadata;
10725 /// let x = LocationsMetadata::new().set_or_clear_access_metadata(Some(AccessMetadata::default()/* use setters */));
10726 /// let x = LocationsMetadata::new().set_or_clear_access_metadata(None::<AccessMetadata>);
10727 /// ```
10728 pub fn set_or_clear_access_metadata<T>(mut self, v: std::option::Option<T>) -> Self
10729 where
10730 T: std::convert::Into<crate::model::AccessMetadata>,
10731 {
10732 self.access_metadata = v.map(|x| x.into());
10733 self
10734 }
10735}
10736
10737impl wkt::message::Message for LocationsMetadata {
10738 fn typename() -> &'static str {
10739 "type.googleapis.com/google.cloud.speech.v2.LocationsMetadata"
10740 }
10741}