Amazon Transcribe examples using Amazon SDK for .NET - Amazon SDK for .NET
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Amazon Transcribe examples using Amazon SDK for .NET

The following code examples show you how to perform actions and implement common scenarios by using the Amazon SDK for .NET with Amazon Transcribe.

Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios and cross-service examples.

Scenarios are code examples that show you how to accomplish a specific task by calling multiple functions within the same service.

Each example includes a link to GitHub, where you can find instructions on how to set up and run the code in context.

Topics

Actions

The following code example shows how to use CreateVocabulary.

Amazon SDK for .NET
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository.

/// <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; }

The following code example shows how to use DeleteMedicalTranscriptionJob.

Amazon SDK for .NET
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository.

/// <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; }

The following code example shows how to use DeleteTranscriptionJob.

Amazon SDK for .NET
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository.

/// <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; }

The following code example shows how to use DeleteVocabulary.

Amazon SDK for .NET
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository.

/// <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; }

The following code example shows how to use GetTranscriptionJob.

Amazon SDK for .NET
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository.

/// <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; }

The following code example shows how to use GetVocabulary.

Amazon SDK for .NET
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository.

/// <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; }
  • For API details, see GetVocabulary in Amazon SDK for .NET API Reference.

The following code example shows how to use ListMedicalTranscriptionJobs.

Amazon SDK for .NET
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository.

/// <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; }

The following code example shows how to use ListTranscriptionJobs.

Amazon SDK for .NET
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository.

/// <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; }

The following code example shows how to use ListVocabularies.

Amazon SDK for .NET
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository.

/// <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; }

The following code example shows how to use StartMedicalTranscriptionJob.

Amazon SDK for .NET
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository.

/// <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; }

The following code example shows how to use StartTranscriptionJob.

Amazon SDK for .NET
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository.

/// <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; }

The following code example shows how to use UpdateVocabulary.

Amazon SDK for .NET
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository.

/// <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; }