lib/ibm_watson/speech_to_text_v1.rb
def add_audio(customization_id:, audio_name:, audio_resource:, contained_content_type: nil, allow_overwrite: nil, content_type: nil)
      raise ArgumentError.new("customization_id must be provided") if customization_id.nil?

      raise ArgumentError.new("audio_name must be provided") if audio_name.nil?

      raise ArgumentError.new("audio_resource must be provided") if audio_resource.nil?

      headers = {
        "Contained-Content-Type" => contained_content_type,
        "Content-Type" => content_type
      }
      sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "add_audio")
      headers.merge!(sdk_headers)

      params = {
        "allow_overwrite" => allow_overwrite
      }

      data = audio_resource

      method_url = "/v1/acoustic_customizations/%s/audio/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(audio_name)]

      request(
        method: "POST",
        url: method_url,
        headers: headers,
        params: params,
        data: data,
        accept_json: true
      )
      nil
    end
def add_audio(customization_id:, audio_name:, audio_resource:, contained_content_type: nil, allow_overwrite: nil, content_type: nil)
      raise ArgumentError.new("customization_id must be provided") if customization_id.nil?

      raise ArgumentError.new("audio_name must be provided") if audio_name.nil?

      raise ArgumentError.new("audio_resource must be provided") if audio_resource.nil?

      headers = {
        "Contained-Content-Type" => contained_content_type,
        "Content-Type" => content_type
      }
      sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "add_audio")
      headers.merge!(sdk_headers)

      params = {
        "allow_overwrite" => allow_overwrite
      }

      data = audio_resource

      method_url = "/v1/acoustic_customizations/%s/audio/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(audio_name)]

      request(
        method: "POST",
        url: method_url,
        headers: headers,
        params: params,
        data: data,
        accept_json: true
      )
      nil
    end
Custom audio resources


 @!method add_audio(customization_id:, audio_name:, audio_resource:, contained_content_type: nil, allow_overwrite: nil, content_type: nil)
 Add an audio resource.
 Adds an audio resource to a custom acoustic model. Add audio content that reflects
   the acoustic characteristics of the audio that you plan to transcribe. You must
   use credentials for the instance of the service that owns a model to add an audio
   resource to it. Adding audio data does not affect the custom acoustic model until
   you train the model for the new data by using the **Train a custom acoustic
   model** method.

   You can add individual audio files or an archive file that contains multiple audio
   files. Adding multiple audio files via a single archive file is significantly more
   efficient than adding each file individually. You can add audio resources in any
   format that the service supports for speech recognition.

   You can use this method to add any number of audio resources to a custom model by
   calling the method once for each audio or archive file. But the addition of one
   audio resource must be fully complete before you can add another. You must add a
   minimum of 10 minutes and a maximum of 100 hours of audio that includes speech,
   not just silence, to a custom acoustic model before you can train it. No audio
   resource, audio- or archive-type, can be larger than 100 MB. To add an audio
   resource that has the same name as an existing audio resource, set the
   `allow_overwrite` parameter to `true`; otherwise, the request fails.

   The method is asynchronous. It can take several seconds to complete depending on
   the duration of the audio and, in the case of an archive file, the total number of
   audio files being processed. The service returns a 201 response code if the audio
   is valid. It then asynchronously analyzes the contents of the audio file or files
   and automatically extracts information about the audio such as its length,
   sampling rate, and encoding. You cannot submit requests to add additional audio
   resources to a custom acoustic model, or to train the model, until the service's
   analysis of all audio files for the current request completes.

   To determine the status of the service's analysis of the audio, use the **Get an
   audio resource** method to poll the status of the audio. The method accepts the
   customization ID of the custom model and the name of the audio resource, and it
   returns the status of the resource. Use a loop to check the status of the audio
   every few seconds until it becomes `ok`.

   **See also:** [Add audio to the custom acoustic
   model](https://cloud.ibm.com/docs/services/speech-to-text/acoustic-create.html#addAudio).


   ### Content types for audio-type resources

    You can add an individual audio file in any format that the service supports for
   speech recognition. For an audio-type resource, use the `Content-Type` parameter
   to specify the audio format (MIME type) of the audio file, including specifying
   the sampling rate, channels, and endianness where indicated.
   * `audio/alaw` (Specify the sampling rate (`rate`) of the audio.)
   * `audio/basic` (Use only with narrowband models.)
   * `audio/flac`
   * `audio/g729` (Use only with narrowband models.)
   * `audio/l16` (Specify the sampling rate (`rate`) and optionally the number of
   channels (`channels`) and endianness (`endianness`) of the audio.)
   * `audio/mp3`
   * `audio/mpeg`
   * `audio/mulaw` (Specify the sampling rate (`rate`) of the audio.)
   * `audio/ogg` (The service automatically detects the codec of the input audio.)
   * `audio/ogg;codecs=opus`
   * `audio/ogg;codecs=vorbis`
   * `audio/wav` (Provide audio with a maximum of nine channels.)
   * `audio/webm` (The service automatically detects the codec of the input audio.)
   * `audio/webm;codecs=opus`
   * `audio/webm;codecs=vorbis`

   The sampling rate of an audio file must match the sampling rate of the base model
   for the custom model: for broadband models, at least 16 kHz; for narrowband
   models, at least 8 kHz. If the sampling rate of the audio is higher than the
   minimum required rate, the service down-samples the audio to the appropriate rate.
   If the sampling rate of the audio is lower than the minimum required rate, the
   service labels the audio file as `invalid`.

    **See also:** [Audio
   formats](https://cloud.ibm.com/docs/services/speech-to-text/audio-formats.html).

   ### Content types for archive-type resources

    You can add an archive file (**.zip** or **.tar.gz** file) that contains audio
   files in any format that the service supports for speech recognition. For an
   archive-type resource, use the `Content-Type` parameter to specify the media type
   of the archive file:
   * `application/zip` for a **.zip** file
   * `application/gzip` for a **.tar.gz** file.

   When you add an archive-type resource, the `Contained-Content-Type` header is
   optional depending on the format of the files that you are adding:
   * For audio files of type `audio/alaw`, `audio/basic`, `audio/l16`, or
   `audio/mulaw`, you must use the `Contained-Content-Type` header to specify the
   format of the contained audio files. Include the `rate`, `channels`, and
   `endianness` parameters where necessary. In this case, all audio files contained
   in the archive file must have the same audio format.
   * For audio files of all other types, you can omit the `Contained-Content-Type`
   header. In this case, the audio files contained in the archive file can have any
   of the formats not listed in the previous bullet. The audio files do not need to
   have the same format.

   Do not use the `Contained-Content-Type` header when adding an audio-type resource.


   ### Naming restrictions for embedded audio files

    The name of an audio file that is embedded within an archive-type resource must
   meet the following restrictions:
   * Include a maximum of 128 characters in the file name; this includes the file
   extension.
   * Do not include spaces, slashes, or backslashes in the file name.
   * Do not use the name of an audio file that has already been added to the custom
   model as part of an archive-type resource.
 @param customization_id [String] The customization ID (GUID) of the custom acoustic model that is to be used for
   the request. You must make the request with credentials for the instance of the
   service that owns the custom model.
 @param audio_name [String] The name of the new audio resource for the custom acoustic model. Use a localized
   name that matches the language of the custom model and reflects the contents of
   the resource.
   * Include a maximum of 128 characters in the name.
   * Do not include spaces, slashes, or backslashes in the name.
   * Do not use the name of an audio resource that has already been added to the
   custom model.
 @param audio_resource [String] The audio resource that is to be added to the custom acoustic model, an individual
   audio file or an archive file.
 @param contained_content_type [String] **For an archive-type resource,** specify the format of the audio files that are
   contained in the archive file if they are of type `audio/alaw`, `audio/basic`,
   `audio/l16`, or `audio/mulaw`. Include the `rate`, `channels`, and `endianness`
   parameters where necessary. In this case, all audio files that are contained in
   the archive file must be of the indicated type.

   For all other audio formats, you can omit the header. In this case, the audio
   files can be of multiple types as long as they are not of the types listed in the
   previous paragraph.

   The parameter accepts all of the audio formats that are supported for use with
   speech recognition. For more information, see **Content types for audio-type
   resources** in the method description.

   **For an audio-type resource,** omit the header.
 @param allow_overwrite [Boolean] If `true`, the specified audio resource overwrites an existing audio resource with
   the same name. If `false`, the request fails if an audio resource with the same
   name already exists. The parameter has no effect if an audio resource with the
   same name does not already exist.
 @param content_type [String] For an audio-type resource, the format (MIME type) of the audio. For more
   information, see **Content types for audio-type resources** in the method
   description.

   For an archive-type resource, the media type of the archive file. For more
   information, see **Content types for archive-type resources** in the method
   description.
 @return [nil]