View a markdown version of this page

Amazon Transcribe examples using SDK for .NET - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Amazon Transcribe examples using SDK for .NET

The following code examples show you how to perform actions and implement common scenarios by using the AWS 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.

Each example includes a link to the complete source code, 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.

SDK for .NET
Note

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

/// /// Create a custom vocabulary using a list of phrases. Custom vocabularies /// improve transcription accuracy for one or more specific words. /// /// The language code of the vocabulary. /// Phrases to use in the vocabulary. /// Name for the vocabulary. /// The state of the custom vocabulary. public async Task CreateCustomVocabulary(LanguageCode languageCode, List 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.

SDK for .NET
Note

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

/// /// Delete a medical transcription job. Also deletes the transcript associated with the job. /// /// Name of the medical transcription job to delete. /// True if successful. public async Task 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.

SDK for .NET
Note

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

/// /// Delete a transcription job. Also deletes the transcript associated with the job. /// /// Name of the transcription job to delete. /// True if successful. public async Task 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.

SDK for .NET
Note

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

/// /// Delete an existing custom vocabulary. /// /// Name of the vocabulary to delete. /// True if successful. public async Task 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.

SDK for .NET
Note

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

/// /// Get details about a transcription job. /// /// A unique name for the transcription job. /// A TranscriptionJob instance with information on the requested job. public async Task GetTranscriptionJob(string jobName) { var response = await _amazonTranscribeService.GetTranscriptionJobAsync( new GetTranscriptionJobRequest() { TranscriptionJobName = jobName }); return response.TranscriptionJob; }

The following code example shows how to use GetVocabulary.

SDK for .NET
Note

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

/// /// Get information about a custom vocabulary. /// /// Name of the vocabulary. /// The state of the custom vocabulary. public async Task GetCustomVocabulary(string vocabularyName) { var response = await _amazonTranscribeService.GetVocabularyAsync( new GetVocabularyRequest() { VocabularyName = vocabularyName }); return response.VocabularyState; }
  • For API details, see GetVocabulary in AWS SDK for .NET API Reference.

The following code example shows how to use ListMedicalTranscriptionJobs.

SDK for .NET
Note

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

/// /// List medical transcription jobs, optionally with a name filter. /// /// Optional name filter for the medical transcription jobs. /// A list of summaries about medical transcription jobs. public async Task> 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.

SDK for .NET
Note

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

/// /// List transcription jobs, optionally with a name filter. /// /// Optional name filter for the transcription jobs. /// A list of transcription job summaries. public async Task> 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.

SDK for .NET
Note

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

/// /// List custom vocabularies for the current account. Optionally specify a name /// filter and a specific state to filter the vocabularies list. /// /// Optional string the vocabulary name must contain. /// Optional state of the vocabulary. /// List of information about the vocabularies. public async Task> 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.

SDK for .NET
Note

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

/// /// Start a medical transcription job for a media file. This method returns /// as soon as the job is started. /// /// A unique name for the medical transcription job. /// The URI of the media file, typically an Amazon S3 location. /// The format of the media file. /// Location for the output, typically an Amazon S3 location. /// Conversation or dictation transcription type. /// A MedicalTransactionJob instance with information on the new job. public async Task 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.

SDK for .NET
Note

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

/// /// Start a transcription job for a media file. This method returns /// as soon as the job is started. /// /// A unique name for the transcription job. /// The URI of the media file, typically an Amazon S3 location. /// The format of the media file. /// The language code of the media file, such as en-US. /// Optional name of a custom vocabulary. /// A TranscriptionJob instance with information on the new job. public async Task 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.

SDK for .NET
Note

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

/// /// Update a custom vocabulary with new values. Update overwrites all existing information. /// /// The language code of the vocabulary. /// Phrases to use in the vocabulary. /// Name for the vocabulary. /// The state of the custom vocabulary. public async Task UpdateCustomVocabulary(LanguageCode languageCode, List phrases, string vocabularyName) { var response = await _amazonTranscribeService.UpdateVocabularyAsync( new UpdateVocabularyRequest() { LanguageCode = languageCode, Phrases = phrases, VocabularyName = vocabularyName }); return response.VocabularyState; }