Add a custom word.

        Adds a custom word to a custom language model. The service populates the words
        resource for a custom model with out-of-vocabulary (OOV) words from each corpus or
        grammar that is added to the model. You can use this method to add a word or to
        modify an existing word in the words resource. The words resource for a model can
        contain a maximum of 30 thousand custom (OOV) words. This includes words that the
        service extracts from corpora and grammars and words that you add directly.
        You must use credentials for the instance of the service that owns a model to add
        or modify a custom word for the model. Adding or modifying a custom word does not
        affect the custom model until you train the model for the new data by using the
        **Train a custom language model** method.
        Use the `word_name` parameter to specify the custom word that is to be added or
        modified. Use the `CustomWord` object to provide one or both of the optional
        `sounds_like` and `display_as` fields for the word.
        * The `sounds_like` field provides an array of one or more pronunciations for the
        word. Use the parameter to specify how the word can be pronounced by users. Use
        the parameter for words that are difficult to pronounce, foreign words, acronyms,
        and so on. For example, you might specify that the word `IEEE` can sound like `i
        triple e`. You can specify a maximum of five sounds-like pronunciations for a
        word.
        * The `display_as` field provides a different way of spelling the word in a
        transcript. Use the parameter when you want the word to appear different from its
        usual representation or from its spelling in training data. For example, you might
        indicate that the word `IBM(trademark)` is to be displayed as `IBM&trade;`.
        If you add a custom word that already exists in the words resource for the custom
        model, the new definition overwrites the existing data for the word. If the
        service encounters an error, it does not add the word to the words resource. Use
        the **List a custom word** method to review the word that you add.
        **See also:**
        * [Working with custom
        words](https://cloud.ibm.com/docs/services/speech-to-text/language-resource.html#workingWords)
        * [Add words to the custom language
        model](https://cloud.ibm.com/docs/services/speech-to-text/language-create.html#addWords).

        :param str customization_id: 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 str word_name: The custom word that is to be added to or updated in the
        custom language model. Do not include spaces in the word. Use a `-` (dash) or `_`
        (underscore) to connect the tokens of compound words. URL-encode the word if it
        includes non-ASCII characters. For more information, see [Character
        encoding](https://cloud.ibm.com/docs/services/speech-to-text/language-resource.html#charEncoding).
        :param str word: For the **Add custom words** method, you must specify the custom
        word that is to be added to or updated in the custom model. Do not include spaces
        in the word. Use a `-` (dash) or `_` (underscore) to connect the tokens of
        compound words.
        Omit this parameter for the **Add a custom word** method.
        :param list[str] sounds_like: An array of sounds-like pronunciations for the
        custom word. Specify how words that are difficult to pronounce, foreign words,
        acronyms, and so on can be pronounced by users.
        * For a word that is not in the service's base vocabulary, omit the parameter to
        have the service automatically generate a sounds-like pronunciation for the word.
        * For a word that is in the service's base vocabulary, use the parameter to
        specify additional pronunciations for the word. You cannot override the default
        pronunciation of a word; pronunciations you add augment the pronunciation from the
        base vocabulary.
        A word can have at most five sounds-like pronunciations. A pronunciation can
        include at most 40 characters not including spaces.
        :param str display_as: An alternative spelling for the custom word when it appears
        in a transcript. Use the parameter when you want the word to have a spelling that
        is different from its usual representation or from its spelling in corpora
        training data.
        :param dict headers: A `dict` containing the request headers
        :return: A `DetailedResponse` containing the result, headers and HTTP status code.
        :rtype: DetailedResponse

def add_word(self,
                 customization_id,
                 word_name,
                 word=None,
                 sounds_like=None,
                 display_as=None,
                 **kwargs):
        """
        Add a custom word.

        Adds a custom word to a custom language model. The service populates the words
        resource for a custom model with out-of-vocabulary (OOV) words from each corpus or
        grammar that is added to the model. You can use this method to add a word or to
        modify an existing word in the words resource. The words resource for a model can
        contain a maximum of 30 thousand custom (OOV) words. This includes words that the
        service extracts from corpora and grammars and words that you add directly.
        You must use credentials for the instance of the service that owns a model to add
        or modify a custom word for the model. Adding or modifying a custom word does not
        affect the custom model until you train the model for the new data by using the
        **Train a custom language model** method.
        Use the `word_name` parameter to specify the custom word that is to be added or
        modified. Use the `CustomWord` object to provide one or both of the optional
        `sounds_like` and `display_as` fields for the word.
        * The `sounds_like` field provides an array of one or more pronunciations for the
        word. Use the parameter to specify how the word can be pronounced by users. Use
        the parameter for words that are difficult to pronounce, foreign words, acronyms,
        and so on. For example, you might specify that the word `IEEE` can sound like `i
        triple e`. You can specify a maximum of five sounds-like pronunciations for a
        word.
        * The `display_as` field provides a different way of spelling the word in a
        transcript. Use the parameter when you want the word to appear different from its
        usual representation or from its spelling in training data. For example, you might
        indicate that the word `IBM(trademark)` is to be displayed as `IBM&trade;`.
        If you add a custom word that already exists in the words resource for the custom
        model, the new definition overwrites the existing data for the word. If the
        service encounters an error, it does not add the word to the words resource. Use
        the **List a custom word** method to review the word that you add.
        **See also:**
        * [Working with custom
        words](https://cloud.ibm.com/docs/services/speech-to-text/language-resource.html#workingWords)
        * [Add words to the custom language
        model](https://cloud.ibm.com/docs/services/speech-to-text/language-create.html#addWords).

        :param str customization_id: 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 str word_name: The custom word that is to be added to or updated in the
        custom language model. Do not include spaces in the word. Use a `-` (dash) or `_`
        (underscore) to connect the tokens of compound words. URL-encode the word if it
        includes non-ASCII characters. For more information, see [Character
        encoding](https://cloud.ibm.com/docs/services/speech-to-text/language-resource.html#charEncoding).
        :param str word: For the **Add custom words** method, you must specify the custom
        word that is to be added to or updated in the custom model. Do not include spaces
        in the word. Use a `-` (dash) or `_` (underscore) to connect the tokens of
        compound words.
        Omit this parameter for the **Add a custom word** method.
        :param list[str] sounds_like: An array of sounds-like pronunciations for the
        custom word. Specify how words that are difficult to pronounce, foreign words,
        acronyms, and so on can be pronounced by users.
        * For a word that is not in the service's base vocabulary, omit the parameter to
        have the service automatically generate a sounds-like pronunciation for the word.
        * For a word that is in the service's base vocabulary, use the parameter to
        specify additional pronunciations for the word. You cannot override the default
        pronunciation of a word; pronunciations you add augment the pronunciation from the
        base vocabulary.
        A word can have at most five sounds-like pronunciations. A pronunciation can
        include at most 40 characters not including spaces.
        :param str display_as: An alternative spelling for the custom word when it appears
        in a transcript. Use the parameter when you want the word to have a spelling that
        is different from its usual representation or from its spelling in corpora
        training data.
        :param dict headers: A `dict` containing the request headers
        :return: A `DetailedResponse` containing the result, headers and HTTP status code.
        :rtype: DetailedResponse
        """

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

        headers = {}
        if 'headers' in kwargs:
            headers.update(kwargs.get('headers'))
        sdk_headers = get_sdk_headers('speech_to_text', 'V1', 'add_word')
        headers.update(sdk_headers)

        data = {
            'word': word,
            'sounds_like': sounds_like,
            'display_as': display_as
        }

        url = '/v1/customizations/{0}/words/{1}'.format(
            *self._encode_path_vars(customization_id, word_name))
        response = self.request(
            method='PUT', url=url, headers=headers, json=data, accept_json=True)
        return response