GetVocabulary与 AWS SDK 或 CLI 配合使用 - Amazon Transcribe

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

GetVocabulary与 AWS SDK 或 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 开发人员指南》中的自定义词汇表

  • 有关 API 的详细信息,请参阅AWS CLI 命令参考GetVocabulary中的。

Python
适用于 Python 的 SDK(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 的详细信息,请参阅适用GetVocabularyPython 的AWS SDK (Boto3) API 参考

有关 S AWS DK 开发者指南和代码示例的完整列表,请参阅将此服务与 AWS SDK 配合使用。本主题还包括有关入门的信息以及有关先前的 SDK 版本的详细信息。