与 AWS SDK或GetVocabulary一起使用 CLI - AWS SDK 代码示例

AWS 文档 AWS SDK示例 GitHub 存储库中还有更多SDK示例

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

与 AWS SDK或GetVocabulary一起使用 CLI

以下代码示例演示如何使用 GetVocabulary

操作示例是大型程序的代码摘录,必须在上下文中运行。在以下代码示例中,您可以查看此操作的上下文:

.NET
AWS SDK for .NET
注意

还有更多相关信息 GitHub。在 AWS 代码示例存储库中查找完整实例,了解如何进行设置和运行。

/// <summary> /// Get information about a custom vocabulary. /// </summary> /// <param name="vocabularyName">Name of the vocabulary.</param> /// <returns>The state of the custom vocabulary.</returns> public async Task<VocabularyState> GetCustomVocabulary(string vocabularyName) { var response = await _amazonTranscribeService.GetVocabularyAsync( new GetVocabularyRequest() { VocabularyName = vocabularyName }); return response.VocabularyState; }
  • 有关API详细信息,请参阅 “AWS SDK for .NET API参考 GetVocabulary” 中的。

CLI
AWS CLI

获取有关自定义词汇表的信息

以下 get-vocabulary 示例获取有关以前创建的自定义词汇表的信息。

aws transcribe get-vocabulary \ --vocabulary-name cli-vocab-1

输出:

{ "VocabularyName": "cli-vocab-1", "LanguageCode": "language-code", "VocabularyState": "READY", "LastModifiedTime": "2020-09-19T23:22:32.836000+00:00", "DownloadUri": "https://link-to-download-the-text-file-used-to-create-your-custom-vocabulary" }

有关更多信息,请参阅《Amazon Transcribe 开发人员指南》中的自定义词汇表

Python
SDK适用于 Python (Boto3)
注意

还有更多相关信息 GitHub。在 AWS 代码示例存储库中查找完整实例,了解如何进行设置和运行。

def get_vocabulary(vocabulary_name, transcribe_client): """ Gets information about a custom vocabulary. :param vocabulary_name: The name of the vocabulary to retrieve. :param transcribe_client: The Boto3 Transcribe client. :return: Information about the vocabulary. """ try: response = transcribe_client.get_vocabulary(VocabularyName=vocabulary_name) logger.info("Got vocabulary %s.", response["VocabularyName"]) except ClientError: logger.exception("Couldn't get vocabulary %s.", vocabulary_name) raise else: return response
  • 有关API详细信息,请参阅GetVocabulary中的 AWS SDKPython (Boto3) API 参考。