Contoh Amazon Transcribe menggunakan AWS SDK for .NET - AWS SDK for .NET

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

Contoh Amazon Transcribe menggunakan AWS SDK for .NET

Contoh kode berikut menunjukkan cara melakukan tindakan dan mengimplementasikan skenario umum menggunakan AWS SDK for .NET with Amazon Transcribe.

Tindakan adalah kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Sementara tindakan menunjukkan cara memanggil fungsi layanan individual, Anda dapat melihat tindakan dalam konteks dalam skenario terkait.

Setiap contoh menyertakan tautan ke kode sumber lengkap, di mana Anda dapat menemukan instruksi tentang cara mengatur dan menjalankan kode dalam konteks.

Tindakan

Contoh kode berikut menunjukkan cara menggunakanCreateVocabulary.

AWS SDK for .NET
catatan

Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS.

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

Contoh kode berikut menunjukkan cara menggunakanDeleteMedicalTranscriptionJob.

AWS SDK for .NET
catatan

Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS.

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

Contoh kode berikut menunjukkan cara menggunakanDeleteTranscriptionJob.

AWS SDK for .NET
catatan

Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS.

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

Contoh kode berikut menunjukkan cara menggunakanDeleteVocabulary.

AWS SDK for .NET
catatan

Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS.

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

Contoh kode berikut menunjukkan cara menggunakanGetTranscriptionJob.

AWS SDK for .NET
catatan

Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS.

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

Contoh kode berikut menunjukkan cara menggunakanGetVocabulary.

AWS SDK for .NET
catatan

Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode 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; }
  • Untuk API detailnya, lihat GetVocabularydi AWS SDK for .NET APIReferensi.

Contoh kode berikut menunjukkan cara menggunakanListMedicalTranscriptionJobs.

AWS SDK for .NET
catatan

Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS.

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

Contoh kode berikut menunjukkan cara menggunakanListTranscriptionJobs.

AWS SDK for .NET
catatan

Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS.

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

Contoh kode berikut menunjukkan cara menggunakanListVocabularies.

AWS SDK for .NET
catatan

Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS.

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

Contoh kode berikut menunjukkan cara menggunakanStartMedicalTranscriptionJob.

AWS SDK for .NET
catatan

Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS.

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

Contoh kode berikut menunjukkan cara menggunakanStartTranscriptionJob.

AWS SDK for .NET
catatan

Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS.

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

Contoh kode berikut menunjukkan cara menggunakanUpdateVocabulary.

AWS SDK for .NET
catatan

Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS.

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