Hay más ejemplos de AWS SDK disponibles en el GitHub repositorio de ejemplos de AWS Doc SDK
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.
Úselo CreateVocabulary
con un AWS SDK o una herramienta de línea de comandos
Los siguientes ejemplos de código muestran cómo utilizar CreateVocabulary
.
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 en marcha GitHub. Busque el ejemplo completo y aprenda a configurar y ejecutar en el Repositorio de ejemplos de código de AWS
. /// <summary> /// Create a custom vocabulary using a list of phrases. Custom vocabularies /// improve transcription accuracy for one or more specific words. /// </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> CreateCustomVocabulary(LanguageCode languageCode, List<string> phrases, string vocabularyName) { var response = await _amazonTranscribeService.CreateVocabularyAsync( new CreateVocabularyRequest { LanguageCode = languageCode, Phrases = phrases, VocabularyName = vocabularyName }); return response.VocabularyState; }
-
Para obtener más información sobre la API, consulta CreateVocabularyla Referencia AWS SDK for .NET de la API.
-
- CLI
-
- AWS CLI
-
Para crear un vocabulario personalizado
En el siguiente ejemplo de
create-vocabulary
se crea un vocabulario personalizado. Para crear un vocabulario personalizado, debe haber creado un archivo de texto con todos los términos que desee transcribir con mayor precisión. Para vocabulary-file-uri, especifique el URI de Amazon Simple Storage Service (Amazon S3) de ese archivo de texto. En language-code, especifique un código de idioma correspondiente al idioma del vocabulario personalizado. En vocabulary-name, especifique cómo desea llamar al vocabulario personalizado.aws transcribe create-vocabulary \ --language-code language-code \ --vocabulary-name cli-vocab-example \ --vocabulary-file-uri s3://DOC-EXAMPLE-BUCKET/Amazon-S3-prefix/the-text-file-for-the-custom-vocabulary.txt
Salida:
{ "VocabularyName": "cli-vocab-example", "LanguageCode": "language-code", "VocabularyState": "PENDING" }
Para obtener más información, consulte Vocabularios personalizados en la Guía para desarrolladores de Amazon Transcribe.
-
Para obtener más información sobre la API, consulte CreateVocabulary
la Referencia de AWS CLI comandos.
-
- Python
-
- SDK para Python (Boto3)
-
nota
Hay más información al respecto GitHub. Busque el ejemplo completo y aprenda a configurar y ejecutar en el Repositorio de ejemplos de código de AWS
. def create_vocabulary( vocabulary_name, language_code, transcribe_client, phrases=None, table_uri=None ): """ Creates a custom vocabulary that can be used to improve the accuracy of transcription jobs. This function returns as soon as the vocabulary processing is started. Call get_vocabulary to get the current status of the vocabulary. The vocabulary is ready to use when its status is 'READY'. :param vocabulary_name: The name of the custom vocabulary. :param language_code: The language code of the vocabulary. For example, en-US or nl-NL. :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. :return: Information about the newly created 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.create_vocabulary(**vocab_args) logger.info("Created custom vocabulary %s.", response["VocabularyName"]) except ClientError: logger.exception("Couldn't create custom vocabulary %s.", vocabulary_name) raise else: return response
-
Para obtener más información sobre la API, consulta CreateVocabularyla AWS Referencia de API de SDK for Python (Boto3).
-