lib/ibm_watson/speech_to_text_v1.rb
def add_grammar(customization_id:, grammar_name:, grammar_file:, content_type:, allow_overwrite: nil)
      raise ArgumentError.new("customization_id must be provided") if customization_id.nil?

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

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

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

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

      params = {
        "allow_overwrite" => allow_overwrite
      }

      data = grammar_file

      method_url = "/v1/customizations/%s/grammars/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(grammar_name)]

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

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

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

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

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

      params = {
        "allow_overwrite" => allow_overwrite
      }

      data = grammar_file

      method_url = "/v1/customizations/%s/grammars/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(grammar_name)]

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


 @!method add_grammar(customization_id:, grammar_name:, grammar_file:, content_type:, allow_overwrite: nil)
 Add a grammar.
 Adds a single grammar file to a custom language model. Submit a plain text file in
   UTF-8 format that defines the grammar. Use multiple requests to submit multiple
   grammar files. You must use credentials for the instance of the service that owns
   a model to add a grammar to it. Adding a grammar does not affect the custom
   language model until you train the model for the new data by using the **Train a
   custom language model** method.

   The call returns an HTTP 201 response code if the grammar is valid. The service
   then asynchronously processes the contents of the grammar and automatically
   extracts new words that it finds. This can take a few seconds to complete
   depending on the size and complexity of the grammar, as well as the current load
   on the service. You cannot submit requests to add additional resources to the
   custom model or to train the model until the service's analysis of the grammar for
   the current request completes. Use the **Get a grammar** method to check the
   status of the analysis.

   The service populates the model's words resource with any word that is recognized
   by the grammar that is not found in the model's base vocabulary. These are
   referred to as out-of-vocabulary (OOV) words. You can use the **List custom
   words** method to examine the words resource and use other words-related methods
   to eliminate typos and modify how words are pronounced as needed.

   To add a grammar that has the same name as an existing grammar, set the
   `allow_overwrite` parameter to `true`; otherwise, the request fails. Overwriting
   an existing grammar causes the service to process the grammar file and extract OOV
   words anew. Before doing so, it removes any OOV words associated with the existing
   grammar from the model's words resource unless they were also added by another
   resource or they have been modified in some way with the **Add custom words** or
   **Add a custom word** method.

   The service limits the overall amount of data that you can add to a custom model
   to a maximum of 10 million total words from all sources combined. Also, you can
   add no more than 30 thousand OOV words to a model. This includes words that the
   service extracts from corpora and grammars and words that you add directly.

   **See also:**
   * [Working with grammars](https://cloud.ibm.com/docs/services/speech-to-text/)
   * [Add grammars to the custom language
   model](https://cloud.ibm.com/docs/services/speech-to-text/).
 @param customization_id [String] The customization ID (GUID) of the custom language 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 grammar_name [String] The name of the new grammar for the custom language model. Use a localized name
   that matches the language of the custom model and reflects the contents of the
   grammar.
   * 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 existing grammar or corpus that is already defined for
   the custom model.
   * Do not use the name `user`, which is reserved by the service to denote custom
   words that are added or modified by the user.
 @param grammar_file [String] A plain text file that contains the grammar in the format specified by the
   `Content-Type` header. Encode the file in UTF-8 (ASCII is a subset of UTF-8).
   Using any other encoding can lead to issues when compiling the grammar or to
   unexpected results in decoding. The service ignores an encoding that is specified
   in the header of the grammar.
 @param content_type [String] The format (MIME type) of the grammar file:
   * `application/srgs` for Augmented Backus-Naur Form (ABNF), which uses a
   plain-text representation that is similar to traditional BNF grammars.
   * `application/srgs+xml` for XML Form, which uses XML elements to represent the
   grammar.
 @param allow_overwrite [Boolean] If `true`, the specified grammar overwrites an existing grammar with the same
   name. If `false`, the request fails if a grammar with the same name already
   exists. The parameter has no effect if a grammar with the same name does not
   already exist.
 @return [nil]