Esempi di Amazon Transcribe utilizzando AWS SDK for .NET - AWS SDK for .NET

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

Esempi di Amazon Transcribe utilizzando AWS SDK for .NET

I seguenti esempi di codice mostrano come eseguire azioni e implementare scenari comuni utilizzando Amazon Transcribe. AWS SDK for .NET

Le operazioni sono estratti di codice da programmi più grandi e devono essere eseguite nel contesto. Sebbene le azioni mostrino come richiamare le singole funzioni di servizio, puoi vedere le azioni nel loro contesto negli scenari correlati.

Ogni esempio include un collegamento al codice sorgente completo, in cui è possibile trovare istruzioni su come configurare ed eseguire il codice nel contesto.

Argomenti

Azioni

Il seguente esempio di codice mostra come utilizzareCreateVocabulary.

AWS SDK for .NET
Nota

C'è altro da fare GitHub. Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice 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; }

Il seguente esempio di codice mostra come utilizzareDeleteMedicalTranscriptionJob.

AWS SDK for .NET
Nota

C'è altro da fare GitHub. Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice 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; }

Il seguente esempio di codice mostra come utilizzareDeleteTranscriptionJob.

AWS SDK for .NET
Nota

C'è altro da fare GitHub. Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice 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; }

Il seguente esempio di codice mostra come utilizzareDeleteVocabulary.

AWS SDK for .NET
Nota

C'è altro da fare GitHub. Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice 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; }

Il seguente esempio di codice mostra come utilizzareGetTranscriptionJob.

AWS SDK for .NET
Nota

C'è altro da fare GitHub. Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice 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; }

Il seguente esempio di codice mostra come utilizzareGetVocabulary.

AWS SDK for .NET
Nota

C'è altro da fare GitHub. Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice 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; }

Il seguente esempio di codice mostra come utilizzareListMedicalTranscriptionJobs.

AWS SDK for .NET
Nota

C'è altro da fare GitHub. Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice 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; }

Il seguente esempio di codice mostra come utilizzareListTranscriptionJobs.

AWS SDK for .NET
Nota

C'è altro da fare GitHub. Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice 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; }

Il seguente esempio di codice mostra come utilizzareListVocabularies.

AWS SDK for .NET
Nota

C'è altro da fare GitHub. Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice 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; }

Il seguente esempio di codice mostra come utilizzareStartMedicalTranscriptionJob.

AWS SDK for .NET
Nota

C'è altro da fare GitHub. Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice 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; }

Il seguente esempio di codice mostra come utilizzareStartTranscriptionJob.

AWS SDK for .NET
Nota

C'è altro da fare GitHub. Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice 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; }

Il seguente esempio di codice mostra come utilizzareUpdateVocabulary.

AWS SDK for .NET
Nota

C'è altro da fare GitHub. Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice 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; }