Synthesize audio.

        Synthesizes text to audio that is spoken in the specified voice. The service bases
        its understanding of the language for the input text on the specified voice. Use a
        voice that matches the language of the input text.
        The method accepts a maximum of 5 KB of input text in the body of the request, and
        8 KB for the URL and headers. The 5 KB limit includes any SSML tags that you
        specify. The service returns the synthesized audio stream as an array of bytes.
        **See also:** [The HTTP
        interface](https://cloud.ibm.com/docs/services/text-to-speech/http.html).
        ### Audio formats (accept types)
         The service can return audio in the following formats (MIME types).
        * Where indicated, you can optionally specify the sampling rate (`rate`) of the
        audio. You must specify a sampling rate for the `audio/l16` and `audio/mulaw`
        formats. A specified sampling rate must lie in the range of 8 kHz to 192 kHz.
        * For the `audio/l16` format, you can optionally specify the endianness
        (`endianness`) of the audio: `endianness=big-endian` or
        `endianness=little-endian`.
        Use the `Accept` header or the `accept` parameter to specify the requested format
        of the response audio. If you omit an audio format altogether, the service returns
        the audio in Ogg format with the Opus codec (`audio/ogg;codecs=opus`). The service
        always returns single-channel audio.
        * `audio/basic`
          The service returns audio with a sampling rate of 8000 Hz.
        * `audio/flac`
          You can optionally specify the `rate` of the audio. The default sampling rate is
        22,050 Hz.
        * `audio/l16`
          You must specify the `rate` of the audio. You can optionally specify the
        `endianness` of the audio. The default endianness is `little-endian`.
        * `audio/mp3`
          You can optionally specify the `rate` of the audio. The default sampling rate is
        22,050 Hz.
        * `audio/mpeg`
          You can optionally specify the `rate` of the audio. The default sampling rate is
        22,050 Hz.
        * `audio/mulaw`
          You must specify the `rate` of the audio.
        * `audio/ogg`
          The service returns the audio in the `vorbis` codec. You can optionally specify
        the `rate` of the audio. The default sampling rate is 22,050 Hz.
        * `audio/ogg;codecs=opus`
          You can optionally specify the `rate` of the audio. The default sampling rate is
        22,050 Hz.
        * `audio/ogg;codecs=vorbis`
          You can optionally specify the `rate` of the audio. The default sampling rate is
        22,050 Hz.
        * `audio/wav`
          You can optionally specify the `rate` of the audio. The default sampling rate is
        22,050 Hz.
        * `audio/webm`
          The service returns the audio in the `opus` codec. The service returns audio
        with a sampling rate of 48,000 Hz.
        * `audio/webm;codecs=opus`
          The service returns audio with a sampling rate of 48,000 Hz.
        * `audio/webm;codecs=vorbis`
          You can optionally specify the `rate` of the audio. The default sampling rate is
        22,050 Hz.
        For more information about specifying an audio format, including additional
        details about some of the formats, see [Audio
        formats](https://cloud.ibm.com/docs/services/text-to-speech/audio-formats.html).
        ### Warning messages
         If a request includes invalid query parameters, the service returns a `Warnings`
        response header that provides messages about the invalid parameters. The warning
        includes a descriptive message and a list of invalid argument strings. For
        example, a message such as `\"Unknown arguments:\"` or `\"Unknown url query
        arguments:\"` followed by a list of the form `\"{invalid_arg_1},
        {invalid_arg_2}.\"` The request succeeds despite the warnings.

        :param str text: The text to synthesize.
        :param str voice: The voice to use for synthesis.
        :param str customization_id: The customization ID (GUID) of a custom voice model
        to use for the synthesis. If a custom voice model is specified, it is guaranteed
        to work only if it matches the language of the indicated voice. You must make the
        request with service credentials created for the instance of the service that owns
        the custom model. Omit the parameter to use the specified voice with no
        customization.
        :param str accept: The requested format (MIME type) of the audio. You can use the
        `Accept` header or the `accept` parameter to specify the audio format. For more
        information about specifying an audio format, see **Audio formats (accept types)**
        in the method description.
        Default: `audio/ogg;codecs=opus`.
        :param dict headers: A `dict` containing the request headers
        :return: A `DetailedResponse` containing the result, headers and HTTP status code.
        :rtype: DetailedResponse

def synthesize(self,
                   text,
                   voice=None,
                   customization_id=None,
                   accept=None,
                   **kwargs):
        """
        Synthesize audio.

        Synthesizes text to audio that is spoken in the specified voice. The service bases
        its understanding of the language for the input text on the specified voice. Use a
        voice that matches the language of the input text.
        The method accepts a maximum of 5 KB of input text in the body of the request, and
        8 KB for the URL and headers. The 5 KB limit includes any SSML tags that you
        specify. The service returns the synthesized audio stream as an array of bytes.
        **See also:** [The HTTP
        interface](https://cloud.ibm.com/docs/services/text-to-speech/http.html).
        ### Audio formats (accept types)
         The service can return audio in the following formats (MIME types).
        * Where indicated, you can optionally specify the sampling rate (`rate`) of the
        audio. You must specify a sampling rate for the `audio/l16` and `audio/mulaw`
        formats. A specified sampling rate must lie in the range of 8 kHz to 192 kHz.
        * For the `audio/l16` format, you can optionally specify the endianness
        (`endianness`) of the audio: `endianness=big-endian` or
        `endianness=little-endian`.
        Use the `Accept` header or the `accept` parameter to specify the requested format
        of the response audio. If you omit an audio format altogether, the service returns
        the audio in Ogg format with the Opus codec (`audio/ogg;codecs=opus`). The service
        always returns single-channel audio.
        * `audio/basic`
          The service returns audio with a sampling rate of 8000 Hz.
        * `audio/flac`
          You can optionally specify the `rate` of the audio. The default sampling rate is
        22,050 Hz.
        * `audio/l16`
          You must specify the `rate` of the audio. You can optionally specify the
        `endianness` of the audio. The default endianness is `little-endian`.
        * `audio/mp3`
          You can optionally specify the `rate` of the audio. The default sampling rate is
        22,050 Hz.
        * `audio/mpeg`
          You can optionally specify the `rate` of the audio. The default sampling rate is
        22,050 Hz.
        * `audio/mulaw`
          You must specify the `rate` of the audio.
        * `audio/ogg`
          The service returns the audio in the `vorbis` codec. You can optionally specify
        the `rate` of the audio. The default sampling rate is 22,050 Hz.
        * `audio/ogg;codecs=opus`
          You can optionally specify the `rate` of the audio. The default sampling rate is
        22,050 Hz.
        * `audio/ogg;codecs=vorbis`
          You can optionally specify the `rate` of the audio. The default sampling rate is
        22,050 Hz.
        * `audio/wav`
          You can optionally specify the `rate` of the audio. The default sampling rate is
        22,050 Hz.
        * `audio/webm`
          The service returns the audio in the `opus` codec. The service returns audio
        with a sampling rate of 48,000 Hz.
        * `audio/webm;codecs=opus`
          The service returns audio with a sampling rate of 48,000 Hz.
        * `audio/webm;codecs=vorbis`
          You can optionally specify the `rate` of the audio. The default sampling rate is
        22,050 Hz.
        For more information about specifying an audio format, including additional
        details about some of the formats, see [Audio
        formats](https://cloud.ibm.com/docs/services/text-to-speech/audio-formats.html).
        ### Warning messages
         If a request includes invalid query parameters, the service returns a `Warnings`
        response header that provides messages about the invalid parameters. The warning
        includes a descriptive message and a list of invalid argument strings. For
        example, a message such as `\"Unknown arguments:\"` or `\"Unknown url query
        arguments:\"` followed by a list of the form `\"{invalid_arg_1},
        {invalid_arg_2}.\"` The request succeeds despite the warnings.

        :param str text: The text to synthesize.
        :param str voice: The voice to use for synthesis.
        :param str customization_id: The customization ID (GUID) of a custom voice model
        to use for the synthesis. If a custom voice model is specified, it is guaranteed
        to work only if it matches the language of the indicated voice. You must make the
        request with service credentials created for the instance of the service that owns
        the custom model. Omit the parameter to use the specified voice with no
        customization.
        :param str accept: The requested format (MIME type) of the audio. You can use the
        `Accept` header or the `accept` parameter to specify the audio format. For more
        information about specifying an audio format, see **Audio formats (accept types)**
        in the method description.
        Default: `audio/ogg;codecs=opus`.
        :param dict headers: A `dict` containing the request headers
        :return: A `DetailedResponse` containing the result, headers and HTTP status code.
        :rtype: DetailedResponse
        """

        if text is None:
            raise ValueError('text must be provided')

        headers = {'Accept': accept}
        if 'headers' in kwargs:
            headers.update(kwargs.get('headers'))
        sdk_headers = get_sdk_headers('text_to_speech', 'V1', 'synthesize')
        headers.update(sdk_headers)

        params = {'voice': voice, 'customization_id': customization_id}

        data = {'text': text}

        url = '/v1/synthesize'
        response = self.request(
            method='POST',
            url=url,
            headers=headers,
            params=params,
            json=data,
            accept_json=False)
        return response