本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
使用 Amazon SDK for .NET 的 Amazon Transcribe 示例
以下代码示例演示如何将 Amazon SDK for .NET 与 Amazon Transcribe 结合使用来执行操作和实现常见场景。
操作是大型程序的代码摘录,必须在上下文中运行。您可以通过操作了解如何调用单个服务函数,还可以通过函数相关场景和跨服务示例的上下文查看操作。
场景是指显示如何通过在同一服务中调用多个函数来完成特定任务的代码示例。
每个示例都包含一个指向的链接 GitHub,您可以在其中找到有关如何在上下文中设置和运行代码的说明。
主题
操作
以下代码示例演示如何创建自定义 Amazon Transcribe 词汇表。
- Amazon SDK for .NET
-
注意
还有更多相关信息 GitHub。在 Amazon 代码示例存储库
中查找完整示例,了解如何进行设置和运行。 /// <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; }
-
有关 API 的详细信息,请参阅 Amazon SDK for .NETAPI 参考CreateVocabulary中的。
-
以下代码示例演示如何删除自定义 Amazon Transcribe 词汇表。
- Amazon SDK for .NET
-
注意
还有更多相关信息 GitHub。在 Amazon 代码示例存储库
中查找完整示例,了解如何进行设置和运行。 /// <summary> /// Delete an existing custom vocabulary. /// </summary> /// <param name="vocabularyName">Name of the vocabulary to delete.</param> /// <returns>True if successful.</returns> public async Task<bool> DeleteCustomVocabulary(string vocabularyName) { var response = await _amazonTranscribeService.DeleteVocabularyAsync( new DeleteVocabularyRequest { VocabularyName = vocabularyName }); return response.HttpStatusCode == HttpStatusCode.OK; }
-
有关 API 的详细信息,请参阅 Amazon SDK for .NETAPI 参考DeleteVocabulary中的。
-
以下代码示例演示如何删除 Amazon Transcribe Medical 转录任务。
- Amazon SDK for .NET
-
注意
还有更多相关信息 GitHub。在 Amazon 代码示例存储库
中查找完整示例,了解如何进行设置和运行。 /// <summary> /// Delete a medical transcription job. Also deletes the transcript associated with the job. /// </summary> /// <param name="jobName">Name of the medical transcription job to delete.</param> /// <returns>True if successful.</returns> public async Task<bool> DeleteMedicalTranscriptionJob(string jobName) { var response = await _amazonTranscribeService.DeleteMedicalTranscriptionJobAsync( new DeleteMedicalTranscriptionJobRequest() { MedicalTranscriptionJobName = jobName }); return response.HttpStatusCode == HttpStatusCode.OK; }
-
有关 API 的详细信息,请参阅 Amazon SDK for .NETAPI 参考DeleteMedicalTranscriptionJob中的。
-
以下代码示例演示如何删除 Amazon Transcribe 转录任务。
- Amazon SDK for .NET
-
注意
还有更多相关信息 GitHub。在 Amazon 代码示例存储库
中查找完整示例,了解如何进行设置和运行。 /// <summary> /// Delete a transcription job. Also deletes the transcript associated with the job. /// </summary> /// <param name="jobName">Name of the transcription job to delete.</param> /// <returns>True if successful.</returns> public async Task<bool> DeleteTranscriptionJob(string jobName) { var response = await _amazonTranscribeService.DeleteTranscriptionJobAsync( new DeleteTranscriptionJobRequest() { TranscriptionJobName = jobName }); return response.HttpStatusCode == HttpStatusCode.OK; }
-
有关 API 的详细信息,请参阅 Amazon SDK for .NETAPI 参考DeleteTranscriptionJob中的。
-
以下代码示例演示如何获取自定义 Amazon Transcribe 词汇表。
- Amazon SDK for .NET
-
注意
还有更多相关信息 GitHub。在 Amazon 代码示例存储库
中查找完整示例,了解如何进行设置和运行。 /// <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 的详细信息,请参阅 Amazon SDK for .NETAPI 参考GetVocabulary中的。
-
以下代码示例演示如何获取 Amazon Transcribe 转录任务。
- Amazon SDK for .NET
-
注意
还有更多相关信息 GitHub。在 Amazon 代码示例存储库
中查找完整示例,了解如何进行设置和运行。 /// <summary> /// Get details about a transcription job. /// </summary> /// <param name="jobName">A unique name for the transcription job.</param> /// <returns>A TranscriptionJob instance with information on the requested job.</returns> public async Task<TranscriptionJob> GetTranscriptionJob(string jobName) { var response = await _amazonTranscribeService.GetTranscriptionJobAsync( new GetTranscriptionJobRequest() { TranscriptionJobName = jobName }); return response.TranscriptionJob; }
-
有关 API 的详细信息,请参阅 Amazon SDK for .NETAPI 参考GetTranscriptionJob中的。
-
以下代码示例演示如何列出自定义 Amazon Transcribe 词汇表。
- Amazon SDK for .NET
-
注意
还有更多相关信息 GitHub。在 Amazon 代码示例存储库
中查找完整示例,了解如何进行设置和运行。 /// <summary> /// List custom vocabularies for the current account. Optionally specify a name /// filter and a specific state to filter the vocabularies list. /// </summary> /// <param name="nameContains">Optional string the vocabulary name must contain.</param> /// <param name="stateEquals">Optional state of the vocabulary.</param> /// <returns>List of information about the vocabularies.</returns> public async Task<List<VocabularyInfo>> ListCustomVocabularies(string? nameContains = null, VocabularyState? stateEquals = null) { var response = await _amazonTranscribeService.ListVocabulariesAsync( new ListVocabulariesRequest() { NameContains = nameContains, StateEquals = stateEquals }); return response.Vocabularies; }
-
有关 API 的详细信息,请参阅 Amazon SDK for .NETAPI 参考ListVocabularies中的。
-
以下代码示例演示如何列出 Amazon Transcribe Medical 转录任务。
- Amazon SDK for .NET
-
注意
还有更多相关信息 GitHub。在 Amazon 代码示例存储库
中查找完整示例,了解如何进行设置和运行。 /// <summary> /// List medical transcription jobs, optionally with a name filter. /// </summary> /// <param name="jobNameContains">Optional name filter for the medical transcription jobs.</param> /// <returns>A list of summaries about medical transcription jobs.</returns> public async Task<List<MedicalTranscriptionJobSummary>> ListMedicalTranscriptionJobs( string? jobNameContains = null) { var response = await _amazonTranscribeService.ListMedicalTranscriptionJobsAsync( new ListMedicalTranscriptionJobsRequest() { JobNameContains = jobNameContains }); return response.MedicalTranscriptionJobSummaries; }
-
有关 API 的详细信息,请参阅 Amazon SDK for .NETAPI 参考ListMedicalTranscriptionJobs中的。
-
以下代码示例演示如何列出 Amazon Transcribe 转录任务。
- Amazon SDK for .NET
-
注意
还有更多相关信息 GitHub。在 Amazon 代码示例存储库
中查找完整示例,了解如何进行设置和运行。 /// <summary> /// List transcription jobs, optionally with a name filter. /// </summary> /// <param name="jobNameContains">Optional name filter for the transcription jobs.</param> /// <returns>A list of transcription job summaries.</returns> public async Task<List<TranscriptionJobSummary>> ListTranscriptionJobs(string? jobNameContains = null) { var response = await _amazonTranscribeService.ListTranscriptionJobsAsync( new ListTranscriptionJobsRequest() { JobNameContains = jobNameContains }); return response.TranscriptionJobSummaries; }
-
有关 API 的详细信息,请参阅 Amazon SDK for .NETAPI 参考ListTranscriptionJobs中的。
-
以下代码示例演示如何启动 Amazon Transcribe Medical 转录任务。
- Amazon SDK for .NET
-
注意
还有更多相关信息 GitHub。在 Amazon 代码示例存储库
中查找完整示例,了解如何进行设置和运行。 /// <summary> /// Start a medical transcription job for a media file. This method returns /// as soon as the job is started. /// </summary> /// <param name="jobName">A unique name for the medical transcription job.</param> /// <param name="mediaFileUri">The URI of the media file, typically an Amazon S3 location.</param> /// <param name="mediaFormat">The format of the media file.</param> /// <param name="outputBucketName">Location for the output, typically an Amazon S3 location.</param> /// <param name="transcriptionType">Conversation or dictation transcription type.</param> /// <returns>A MedicalTransactionJob instance with information on the new job.</returns> public async Task<MedicalTranscriptionJob> StartMedicalTranscriptionJob( string jobName, string mediaFileUri, MediaFormat mediaFormat, string outputBucketName, Amazon.TranscribeService.Type transcriptionType) { var response = await _amazonTranscribeService.StartMedicalTranscriptionJobAsync( new StartMedicalTranscriptionJobRequest() { MedicalTranscriptionJobName = jobName, Media = new Media() { MediaFileUri = mediaFileUri }, MediaFormat = mediaFormat, LanguageCode = LanguageCode .EnUS, // The value must be en-US for medical transcriptions. OutputBucketName = outputBucketName, OutputKey = jobName, // The value is a key used to fetch the output of the transcription. Specialty = Specialty.PRIMARYCARE, // The value PRIMARYCARE must be set. Type = transcriptionType }); return response.MedicalTranscriptionJob; }
-
有关 API 的详细信息,请参阅 Amazon SDK for .NETAPI 参考StartMedicalTranscriptionJob中的。
-
以下代码示例演示如何启动 Amazon Transcribe 转录任务。
- Amazon SDK for .NET
-
注意
还有更多相关信息 GitHub。在 Amazon 代码示例存储库
中查找完整示例,了解如何进行设置和运行。 /// <summary> /// Start a transcription job for a media file. This method returns /// as soon as the job is started. /// </summary> /// <param name="jobName">A unique name for the transcription job.</param> /// <param name="mediaFileUri">The URI of the media file, typically an Amazon S3 location.</param> /// <param name="mediaFormat">The format of the media file.</param> /// <param name="languageCode">The language code of the media file, such as en-US.</param> /// <param name="vocabularyName">Optional name of a custom vocabulary.</param> /// <returns>A TranscriptionJob instance with information on the new job.</returns> public async Task<TranscriptionJob> StartTranscriptionJob(string jobName, string mediaFileUri, MediaFormat mediaFormat, LanguageCode languageCode, string? vocabularyName) { var response = await _amazonTranscribeService.StartTranscriptionJobAsync( new StartTranscriptionJobRequest() { TranscriptionJobName = jobName, Media = new Media() { MediaFileUri = mediaFileUri }, MediaFormat = mediaFormat, LanguageCode = languageCode, Settings = vocabularyName != null ? new Settings() { VocabularyName = vocabularyName } : null }); return response.TranscriptionJob; }
-
有关 API 的详细信息,请参阅 Amazon SDK for .NETAPI 参考StartTranscriptionJob中的。
-
以下代码示例演示如何更新自定义 Amazon Transcribe 词汇表。
- Amazon SDK for .NET
-
注意
还有更多相关信息 GitHub。在 Amazon 代码示例存储库
中查找完整示例,了解如何进行设置和运行。 /// <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; }
-
有关 API 的详细信息,请参阅 Amazon SDK for .NETAPI 参考UpdateVocabulary中的。
-