aws_sdk_polly/operation/
synthesize_speech.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2/// Orchestration and serialization glue logic for `SynthesizeSpeech`.
3#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct SynthesizeSpeech;
6impl SynthesizeSpeech {
7    /// Creates a new `SynthesizeSpeech`
8    pub fn new() -> Self {
9        Self
10    }
11    pub(crate) async fn orchestrate(
12        runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
13        input: crate::operation::synthesize_speech::SynthesizeSpeechInput,
14    ) -> ::std::result::Result<
15        crate::operation::synthesize_speech::SynthesizeSpeechOutput,
16        ::aws_smithy_runtime_api::client::result::SdkError<
17            crate::operation::synthesize_speech::SynthesizeSpeechError,
18            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
19        >,
20    > {
21        let map_err = |err: ::aws_smithy_runtime_api::client::result::SdkError<
22            ::aws_smithy_runtime_api::client::interceptors::context::Error,
23            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
24        >| {
25            err.map_service_error(|err| {
26                err.downcast::<crate::operation::synthesize_speech::SynthesizeSpeechError>()
27                    .expect("correct error type")
28            })
29        };
30        let context = Self::orchestrate_with_stop_point(runtime_plugins, input, ::aws_smithy_runtime::client::orchestrator::StopPoint::None)
31            .await
32            .map_err(map_err)?;
33        let output = context.finalize().map_err(map_err)?;
34        ::std::result::Result::Ok(
35            output
36                .downcast::<crate::operation::synthesize_speech::SynthesizeSpeechOutput>()
37                .expect("correct output type"),
38        )
39    }
40
41    pub(crate) async fn orchestrate_with_stop_point(
42        runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
43        input: crate::operation::synthesize_speech::SynthesizeSpeechInput,
44        stop_point: ::aws_smithy_runtime::client::orchestrator::StopPoint,
45    ) -> ::std::result::Result<
46        ::aws_smithy_runtime_api::client::interceptors::context::InterceptorContext,
47        ::aws_smithy_runtime_api::client::result::SdkError<
48            ::aws_smithy_runtime_api::client::interceptors::context::Error,
49            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
50        >,
51    > {
52        let input = ::aws_smithy_runtime_api::client::interceptors::context::Input::erase(input);
53        use ::tracing::Instrument;
54        ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point("Polly", "SynthesizeSpeech", input, runtime_plugins, stop_point)
55            // Create a parent span for the entire operation. Includes a random, internal-only,
56            // seven-digit ID for the operation orchestration so that it can be correlated in the logs.
57            .instrument(::tracing::debug_span!(
58                "Polly.SynthesizeSpeech",
59                "rpc.service" = "Polly",
60                "rpc.method" = "SynthesizeSpeech",
61                "sdk_invocation_id" = ::fastrand::u32(1_000_000..10_000_000),
62                "rpc.system" = "aws-api",
63            ))
64            .await
65    }
66
67    pub(crate) fn operation_runtime_plugins(
68        client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
69        client_config: &crate::config::Config,
70        config_override: ::std::option::Option<crate::config::Builder>,
71    ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
72        let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
73
74        if let ::std::option::Option::Some(config_override) = config_override {
75            for plugin in config_override.runtime_plugins.iter().cloned() {
76                runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
77            }
78            runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
79                config_override,
80                client_config.config.clone(),
81                &client_config.runtime_components,
82            ));
83        }
84        runtime_plugins
85    }
86}
87impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for SynthesizeSpeech {
88    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
89        let mut cfg = ::aws_smithy_types::config_bag::Layer::new("SynthesizeSpeech");
90
91        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
92            SynthesizeSpeechRequestSerializer,
93        ));
94        cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
95            SynthesizeSpeechResponseDeserializer,
96        ));
97
98        cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
99            crate::config::auth::Params::builder()
100                .operation_name("SynthesizeSpeech")
101                .build()
102                .expect("required fields set"),
103        ));
104
105        cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new("SynthesizeSpeech", "Polly"));
106        let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
107        signing_options.double_uri_encode = true;
108        signing_options.content_sha256_header = false;
109        signing_options.normalize_uri_path = true;
110        signing_options.payload_override = None;
111
112        cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
113            signing_options,
114            ..::std::default::Default::default()
115        });
116
117        ::std::option::Option::Some(cfg.freeze())
118    }
119
120    fn runtime_components(
121        &self,
122        _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
123    ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
124        #[allow(unused_mut)]
125        let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("SynthesizeSpeech")
126            .with_interceptor(::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default())
127            .with_interceptor(SynthesizeSpeechEndpointParamsInterceptor)
128            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
129                crate::operation::synthesize_speech::SynthesizeSpeechError,
130            >::new())
131            .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
132                crate::operation::synthesize_speech::SynthesizeSpeechError,
133            >::new())
134            .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
135                crate::operation::synthesize_speech::SynthesizeSpeechError,
136            >::new());
137
138        ::std::borrow::Cow::Owned(rcb)
139    }
140}
141
142#[derive(Debug)]
143struct SynthesizeSpeechResponseDeserializer;
144impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for SynthesizeSpeechResponseDeserializer {
145    fn deserialize_streaming(
146        &self,
147        response: &mut ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
148    ) -> ::std::option::Option<::aws_smithy_runtime_api::client::interceptors::context::OutputOrError> {
149        #[allow(unused_mut)]
150        let mut force_error = false;
151        ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
152
153        // If this is an error, defer to the non-streaming parser
154        if (!response.status().is_success() && response.status().as_u16() != 200) || force_error {
155            return ::std::option::Option::None;
156        }
157        ::std::option::Option::Some(crate::protocol_serde::type_erase_result(
158            crate::protocol_serde::shape_synthesize_speech::de_synthesize_speech_http_response(response),
159        ))
160    }
161
162    fn deserialize_nonstreaming(
163        &self,
164        response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
165    ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
166        // For streaming operations, we only hit this case if its an error
167        let body = response.body().bytes().expect("body loaded");
168        crate::protocol_serde::type_erase_result(crate::protocol_serde::shape_synthesize_speech::de_synthesize_speech_http_error(
169            response.status().as_u16(),
170            response.headers(),
171            body,
172        ))
173    }
174}
175#[derive(Debug)]
176struct SynthesizeSpeechRequestSerializer;
177impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for SynthesizeSpeechRequestSerializer {
178    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
179    fn serialize_input(
180        &self,
181        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
182        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
183    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
184        let input = input
185            .downcast::<crate::operation::synthesize_speech::SynthesizeSpeechInput>()
186            .expect("correct type");
187        let _header_serialization_settings = _cfg
188            .load::<crate::serialization_settings::HeaderSerializationSettings>()
189            .cloned()
190            .unwrap_or_default();
191        let mut request_builder = {
192            #[allow(clippy::uninlined_format_args)]
193            fn uri_base(
194                _input: &crate::operation::synthesize_speech::SynthesizeSpeechInput,
195                output: &mut ::std::string::String,
196            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
197                use ::std::fmt::Write as _;
198                ::std::write!(output, "/v1/speech").expect("formatting should succeed");
199                ::std::result::Result::Ok(())
200            }
201            #[allow(clippy::unnecessary_wraps)]
202            fn update_http_builder(
203                input: &crate::operation::synthesize_speech::SynthesizeSpeechInput,
204                builder: ::http::request::Builder,
205            ) -> ::std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
206                let mut uri = ::std::string::String::new();
207                uri_base(input, &mut uri)?;
208                ::std::result::Result::Ok(builder.method("POST").uri(uri))
209            }
210            let mut builder = update_http_builder(&input, ::http::request::Builder::new())?;
211            builder = _header_serialization_settings.set_default_header(builder, ::http::header::CONTENT_TYPE, "application/json");
212            builder
213        };
214        let body = ::aws_smithy_types::body::SdkBody::from(crate::protocol_serde::shape_synthesize_speech::ser_synthesize_speech_input(&input)?);
215        if let Some(content_length) = body.content_length() {
216            let content_length = content_length.to_string();
217            request_builder = _header_serialization_settings.set_default_header(request_builder, ::http::header::CONTENT_LENGTH, &content_length);
218        }
219        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
220    }
221}
222#[derive(Debug)]
223struct SynthesizeSpeechEndpointParamsInterceptor;
224
225impl ::aws_smithy_runtime_api::client::interceptors::Intercept for SynthesizeSpeechEndpointParamsInterceptor {
226    fn name(&self) -> &'static str {
227        "SynthesizeSpeechEndpointParamsInterceptor"
228    }
229
230    fn read_before_execution(
231        &self,
232        context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
233            '_,
234            ::aws_smithy_runtime_api::client::interceptors::context::Input,
235            ::aws_smithy_runtime_api::client::interceptors::context::Output,
236            ::aws_smithy_runtime_api::client::interceptors::context::Error,
237        >,
238        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
239    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
240        let _input = context
241            .input()
242            .downcast_ref::<SynthesizeSpeechInput>()
243            .ok_or("failed to downcast to SynthesizeSpeechInput")?;
244
245        let params = crate::config::endpoint::Params::builder()
246            .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
247            .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
248            .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
249            .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
250            .build()
251            .map_err(|err| {
252                ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
253            })?;
254        cfg.interceptor_state()
255            .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
256        ::std::result::Result::Ok(())
257    }
258}
259
260// The get_* functions below are generated from JMESPath expressions in the
261// operationContextParams trait. They target the operation's input shape.
262
263/// Error type for the `SynthesizeSpeechError` operation.
264#[non_exhaustive]
265#[derive(::std::fmt::Debug)]
266pub enum SynthesizeSpeechError {
267    /// <p>This engine is not compatible with the voice that you have designated. Choose a new voice that is compatible with the engine or change the engine and restart the operation.</p>
268    EngineNotSupportedException(crate::types::error::EngineNotSupportedException),
269    /// <p>The specified sample rate is not valid.</p>
270    InvalidSampleRateException(crate::types::error::InvalidSampleRateException),
271    /// <p>The SSML you provided is invalid. Verify the SSML syntax, spelling of tags and values, and then try again.</p>
272    InvalidSsmlException(crate::types::error::InvalidSsmlException),
273    /// <p>The language specified is not currently supported by Amazon Polly in this capacity.</p>
274    LanguageNotSupportedException(crate::types::error::LanguageNotSupportedException),
275    /// <p>Amazon Polly can't find the specified lexicon. This could be caused by a lexicon that is missing, its name is misspelled or specifying a lexicon that is in a different region.</p>
276    /// <p>Verify that the lexicon exists, is in the region (see <code>ListLexicons</code>) and that you spelled its name is spelled correctly. Then try again.</p>
277    LexiconNotFoundException(crate::types::error::LexiconNotFoundException),
278    /// <p>Speech marks are not supported for the <code>OutputFormat</code> selected. Speech marks are only available for content in <code>json</code> format.</p>
279    MarksNotSupportedForFormatException(crate::types::error::MarksNotSupportedForFormatException),
280    /// <p>An unknown condition has caused a service failure.</p>
281    ServiceFailureException(crate::types::error::ServiceFailureException),
282    /// <p>SSML speech marks are not supported for plain text-type input.</p>
283    SsmlMarksNotSupportedForTextTypeException(crate::types::error::SsmlMarksNotSupportedForTextTypeException),
284    /// <p>The value of the "Text" parameter is longer than the accepted limits. For the <code>SynthesizeSpeech</code> API, the limit for input text is a maximum of 6000 characters total, of which no more than 3000 can be billed characters. For the <code>StartSpeechSynthesisTask</code> API, the maximum is 200,000 characters, of which no more than 100,000 can be billed characters. SSML tags are not counted as billed characters.</p>
285    TextLengthExceededException(crate::types::error::TextLengthExceededException),
286    /// An unexpected error occurred (e.g., invalid JSON returned by the service or an unknown error code).
287    #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
288    variable wildcard pattern and check `.code()`:
289     \
290    &nbsp;&nbsp;&nbsp;`err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
291     \
292    See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-SynthesizeSpeechError) for what information is available for the error.")]
293    Unhandled(crate::error::sealed_unhandled::Unhandled),
294}
295impl SynthesizeSpeechError {
296    /// Creates the `SynthesizeSpeechError::Unhandled` variant from any error type.
297    pub fn unhandled(
298        err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
299    ) -> Self {
300        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
301            source: err.into(),
302            meta: ::std::default::Default::default(),
303        })
304    }
305
306    /// Creates the `SynthesizeSpeechError::Unhandled` variant from an [`ErrorMetadata`](::aws_smithy_types::error::ErrorMetadata).
307    pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
308        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
309            source: err.clone().into(),
310            meta: err,
311        })
312    }
313    ///
314    /// Returns error metadata, which includes the error code, message,
315    /// request ID, and potentially additional information.
316    ///
317    pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
318        match self {
319            Self::EngineNotSupportedException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
320            Self::InvalidSampleRateException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
321            Self::InvalidSsmlException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
322            Self::LanguageNotSupportedException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
323            Self::LexiconNotFoundException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
324            Self::MarksNotSupportedForFormatException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
325            Self::ServiceFailureException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
326            Self::SsmlMarksNotSupportedForTextTypeException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
327            Self::TextLengthExceededException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
328            Self::Unhandled(e) => &e.meta,
329        }
330    }
331    /// Returns `true` if the error kind is `SynthesizeSpeechError::EngineNotSupportedException`.
332    pub fn is_engine_not_supported_exception(&self) -> bool {
333        matches!(self, Self::EngineNotSupportedException(_))
334    }
335    /// Returns `true` if the error kind is `SynthesizeSpeechError::InvalidSampleRateException`.
336    pub fn is_invalid_sample_rate_exception(&self) -> bool {
337        matches!(self, Self::InvalidSampleRateException(_))
338    }
339    /// Returns `true` if the error kind is `SynthesizeSpeechError::InvalidSsmlException`.
340    pub fn is_invalid_ssml_exception(&self) -> bool {
341        matches!(self, Self::InvalidSsmlException(_))
342    }
343    /// Returns `true` if the error kind is `SynthesizeSpeechError::LanguageNotSupportedException`.
344    pub fn is_language_not_supported_exception(&self) -> bool {
345        matches!(self, Self::LanguageNotSupportedException(_))
346    }
347    /// Returns `true` if the error kind is `SynthesizeSpeechError::LexiconNotFoundException`.
348    pub fn is_lexicon_not_found_exception(&self) -> bool {
349        matches!(self, Self::LexiconNotFoundException(_))
350    }
351    /// Returns `true` if the error kind is `SynthesizeSpeechError::MarksNotSupportedForFormatException`.
352    pub fn is_marks_not_supported_for_format_exception(&self) -> bool {
353        matches!(self, Self::MarksNotSupportedForFormatException(_))
354    }
355    /// Returns `true` if the error kind is `SynthesizeSpeechError::ServiceFailureException`.
356    pub fn is_service_failure_exception(&self) -> bool {
357        matches!(self, Self::ServiceFailureException(_))
358    }
359    /// Returns `true` if the error kind is `SynthesizeSpeechError::SsmlMarksNotSupportedForTextTypeException`.
360    pub fn is_ssml_marks_not_supported_for_text_type_exception(&self) -> bool {
361        matches!(self, Self::SsmlMarksNotSupportedForTextTypeException(_))
362    }
363    /// Returns `true` if the error kind is `SynthesizeSpeechError::TextLengthExceededException`.
364    pub fn is_text_length_exceeded_exception(&self) -> bool {
365        matches!(self, Self::TextLengthExceededException(_))
366    }
367}
368impl ::std::error::Error for SynthesizeSpeechError {
369    fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
370        match self {
371            Self::EngineNotSupportedException(_inner) => ::std::option::Option::Some(_inner),
372            Self::InvalidSampleRateException(_inner) => ::std::option::Option::Some(_inner),
373            Self::InvalidSsmlException(_inner) => ::std::option::Option::Some(_inner),
374            Self::LanguageNotSupportedException(_inner) => ::std::option::Option::Some(_inner),
375            Self::LexiconNotFoundException(_inner) => ::std::option::Option::Some(_inner),
376            Self::MarksNotSupportedForFormatException(_inner) => ::std::option::Option::Some(_inner),
377            Self::ServiceFailureException(_inner) => ::std::option::Option::Some(_inner),
378            Self::SsmlMarksNotSupportedForTextTypeException(_inner) => ::std::option::Option::Some(_inner),
379            Self::TextLengthExceededException(_inner) => ::std::option::Option::Some(_inner),
380            Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
381        }
382    }
383}
384impl ::std::fmt::Display for SynthesizeSpeechError {
385    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
386        match self {
387            Self::EngineNotSupportedException(_inner) => _inner.fmt(f),
388            Self::InvalidSampleRateException(_inner) => _inner.fmt(f),
389            Self::InvalidSsmlException(_inner) => _inner.fmt(f),
390            Self::LanguageNotSupportedException(_inner) => _inner.fmt(f),
391            Self::LexiconNotFoundException(_inner) => _inner.fmt(f),
392            Self::MarksNotSupportedForFormatException(_inner) => _inner.fmt(f),
393            Self::ServiceFailureException(_inner) => _inner.fmt(f),
394            Self::SsmlMarksNotSupportedForTextTypeException(_inner) => _inner.fmt(f),
395            Self::TextLengthExceededException(_inner) => _inner.fmt(f),
396            Self::Unhandled(_inner) => {
397                if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
398                    write!(f, "unhandled error ({code})")
399                } else {
400                    f.write_str("unhandled error")
401                }
402            }
403        }
404    }
405}
406impl ::aws_smithy_types::retry::ProvideErrorKind for SynthesizeSpeechError {
407    fn code(&self) -> ::std::option::Option<&str> {
408        ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
409    }
410    fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
411        ::std::option::Option::None
412    }
413}
414impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for SynthesizeSpeechError {
415    fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
416        match self {
417            Self::EngineNotSupportedException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
418            Self::InvalidSampleRateException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
419            Self::InvalidSsmlException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
420            Self::LanguageNotSupportedException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
421            Self::LexiconNotFoundException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
422            Self::MarksNotSupportedForFormatException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
423            Self::ServiceFailureException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
424            Self::SsmlMarksNotSupportedForTextTypeException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
425            Self::TextLengthExceededException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
426            Self::Unhandled(_inner) => &_inner.meta,
427        }
428    }
429}
430impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for SynthesizeSpeechError {
431    fn create_unhandled_error(
432        source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
433        meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
434    ) -> Self {
435        Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
436            source,
437            meta: meta.unwrap_or_default(),
438        })
439    }
440}
441impl ::aws_types::request_id::RequestId for crate::operation::synthesize_speech::SynthesizeSpeechError {
442    fn request_id(&self) -> Option<&str> {
443        self.meta().request_id()
444    }
445}
446
447pub use crate::operation::synthesize_speech::_synthesize_speech_output::SynthesizeSpeechOutput;
448
449pub use crate::operation::synthesize_speech::_synthesize_speech_input::SynthesizeSpeechInput;
450
451mod _synthesize_speech_input;
452
453mod _synthesize_speech_output;
454
455/// Builders
456pub mod builders;
457
458#[derive(Debug)]
459struct SynthesizeSpeechPresigningRequestSerializer;
460impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for SynthesizeSpeechPresigningRequestSerializer {
461    #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
462    fn serialize_input(
463        &self,
464        input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
465        _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
466    ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
467        let input = input
468            .downcast::<crate::operation::synthesize_speech::SynthesizeSpeechInput>()
469            .expect("correct type");
470        let _header_serialization_settings = _cfg
471            .load::<crate::serialization_settings::HeaderSerializationSettings>()
472            .cloned()
473            .unwrap_or_default();
474        let mut request_builder = {
475            #[allow(clippy::uninlined_format_args)]
476            fn uri_base(
477                _input: &crate::operation::synthesize_speech::SynthesizeSpeechInput,
478                output: &mut ::std::string::String,
479            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
480                use ::std::fmt::Write as _;
481                ::std::write!(output, "/v1/speech").expect("formatting should succeed");
482                ::std::result::Result::Ok(())
483            }
484            fn uri_query(
485                _input: &crate::operation::synthesize_speech::SynthesizeSpeechInput,
486                mut output: &mut ::std::string::String,
487            ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
488                let mut query = ::aws_smithy_http::query::Writer::new(output);
489                if let ::std::option::Option::Some(inner_1) = &_input.engine {
490                    {
491                        query.push_kv("Engine", &::aws_smithy_http::query::fmt_string(inner_1));
492                    }
493                }
494                if let ::std::option::Option::Some(inner_2) = &_input.language_code {
495                    {
496                        query.push_kv("LanguageCode", &::aws_smithy_http::query::fmt_string(inner_2));
497                    }
498                }
499                if let ::std::option::Option::Some(inner_3) = &_input.lexicon_names {
500                    {
501                        for inner_4 in inner_3 {
502                            query.push_kv("LexiconNames", &::aws_smithy_http::query::fmt_string(inner_4));
503                        }
504                    }
505                }
506                let inner_5 = &_input.output_format;
507                let inner_5 = inner_5
508                    .as_ref()
509                    .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("output_format", "cannot be empty or unset"))?;
510                query.push_kv("OutputFormat", &::aws_smithy_http::query::fmt_string(inner_5));
511                if let ::std::option::Option::Some(inner_6) = &_input.sample_rate {
512                    {
513                        query.push_kv("SampleRate", &::aws_smithy_http::query::fmt_string(inner_6));
514                    }
515                }
516                if let ::std::option::Option::Some(inner_7) = &_input.speech_mark_types {
517                    {
518                        for inner_8 in inner_7 {
519                            query.push_kv("SpeechMarkTypes", &::aws_smithy_http::query::fmt_string(inner_8));
520                        }
521                    }
522                }
523                let inner_9 = &_input.text;
524                let inner_9 = inner_9
525                    .as_ref()
526                    .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("text", "cannot be empty or unset"))?;
527                if inner_9.is_empty() {
528                    return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
529                        "text",
530                        "cannot be empty or unset",
531                    ));
532                }
533                query.push_kv("Text", &::aws_smithy_http::query::fmt_string(inner_9));
534                if let ::std::option::Option::Some(inner_10) = &_input.text_type {
535                    {
536                        query.push_kv("TextType", &::aws_smithy_http::query::fmt_string(inner_10));
537                    }
538                }
539                let inner_11 = &_input.voice_id;
540                let inner_11 = inner_11
541                    .as_ref()
542                    .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("voice_id", "cannot be empty or unset"))?;
543                query.push_kv("VoiceId", &::aws_smithy_http::query::fmt_string(inner_11));
544                ::std::result::Result::Ok(())
545            }
546            #[allow(clippy::unnecessary_wraps)]
547            fn update_http_builder(
548                input: &crate::operation::synthesize_speech::SynthesizeSpeechInput,
549                builder: ::http::request::Builder,
550            ) -> ::std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
551                let mut uri = ::std::string::String::new();
552                uri_base(input, &mut uri)?;
553                uri_query(input, &mut uri)?;
554                ::std::result::Result::Ok(builder.method("GET").uri(uri))
555            }
556            let mut builder = update_http_builder(&input, ::http::request::Builder::new())?;
557            builder
558        };
559        let body = ::aws_smithy_types::body::SdkBody::empty();
560
561        ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
562    }
563}