UpdateVocabularyÚselo con un AWS SDKo CLI - Amazon Transcribe

Las traducciones son generadas a través de traducción automática. En caso de conflicto entre la traducción y la version original de inglés, prevalecerá la version en inglés.

UpdateVocabularyÚselo con un AWS SDKo CLI

En los siguientes ejemplos de código, se muestra cómo utilizar UpdateVocabulary.

Los ejemplos de acciones son extractos de código de programas más grandes y deben ejecutarse en contexto. Puede ver esta acción en contexto en el siguiente ejemplo de código:

.NET
AWS SDK for .NET
nota

Hay más información GitHub. Consulta el ejemplo completo y aprende a configurarlo y a ejecutarlo en AWS Repositorio de ejemplos de código.

/// <summary> /// Update a custom vocabulary with new values. Update overwrites all existing information. /// </summary> /// <param name="languageCode">The language code of the vocabulary.</param> /// <param name="phrases">Phrases to use in the vocabulary.</param> /// <param name="vocabularyName">Name for the vocabulary.</param> /// <returns>The state of the custom vocabulary.</returns> public async Task<VocabularyState> UpdateCustomVocabulary(LanguageCode languageCode, List<string> phrases, string vocabularyName) { var response = await _amazonTranscribeService.UpdateVocabularyAsync( new UpdateVocabularyRequest() { LanguageCode = languageCode, Phrases = phrases, VocabularyName = vocabularyName }); return response.VocabularyState; }
  • Para API obtener más información, consulte UpdateVocabularyen AWS SDK for .NET APIReferencia.

CLI
AWS CLI

Para actualizar un vocabulario personalizado con términos nuevos

En el siguiente ejemplo de update-vocabulary se sobrescriben los términos utilizados para crear un vocabulario personalizado con los nuevos que proporcione. Requisito previo: para sustituir los términos de un vocabulario personalizado, necesita un archivo con términos nuevos.

aws transcribe update-vocabulary \ --vocabulary-file-uri s3://DOC-EXAMPLE-BUCKET/Amazon-S3-Prefix/custom-vocabulary.txt \ --vocabulary-name custom-vocabulary \ --language-code language-code

Salida:

{ "VocabularyName": "custom-vocabulary", "LanguageCode": "language", "VocabularyState": "PENDING" }

Para obtener más información, consulte Vocabularios personalizados en la Guía para desarrolladores de Amazon Transcribe.

  • Para API obtener más información, consulte UpdateVocabularyen AWS CLI Referencia de comandos.

Python
SDKpara Python (Boto3)
nota

Hay más información. GitHub Consulta el ejemplo completo y aprende a configurarlo y a ejecutarlo en AWS Repositorio de ejemplos de código.

def update_vocabulary( vocabulary_name, language_code, transcribe_client, phrases=None, table_uri=None ): """ Updates an existing custom vocabulary. The entire vocabulary is replaced with the contents of the update. :param vocabulary_name: The name of the vocabulary to update. :param language_code: The language code of the vocabulary. :param transcribe_client: The Boto3 Transcribe client. :param phrases: A list of comma-separated phrases to include in the vocabulary. :param table_uri: A table of phrases and pronunciation hints to include in the vocabulary. """ try: vocab_args = {"VocabularyName": vocabulary_name, "LanguageCode": language_code} if phrases is not None: vocab_args["Phrases"] = phrases elif table_uri is not None: vocab_args["VocabularyFileUri"] = table_uri response = transcribe_client.update_vocabulary(**vocab_args) logger.info("Updated custom vocabulary %s.", response["VocabularyName"]) except ClientError: logger.exception("Couldn't update custom vocabulary %s.", vocabulary_name) raise
  • Para API obtener más información, consulte UpdateVocabularyen AWS SDKpara referencia de Python (Boto3). API

Para obtener una lista completa de AWS SDKguías para desarrolladores y ejemplos de código, consulteUso de este servicio con un SDK AWS. En este tema también se incluye información sobre cómo empezar y detalles sobre SDK las versiones anteriores.