Skip to content

Transcription

This example assumes using RevAI; is in scope and apiKey contains your RevAI API key.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
var apiKey =
    Environment.GetEnvironmentVariable("REVAI_API_KEY") is { Length: > 0 } value
        ? value
        : throw new AssertInconclusiveException("REVAI_API_KEY environment variable is not found.");

using var client = new RevAIClient(apiKey);

// Submit a transcription job by providing a URL to an audio file.
var job = await client.TranscriptionJobs.SubmitTranscriptionJobAsync(
    mediaUrl: "https://www.rev.ai/FTC_Sample_1.mp3");

// The job runs asynchronously. Poll until it completes.
while (job.Status == TranscriptionJobStatus.InProgress)
{
    await Task.Delay(TimeSpan.FromSeconds(5));
    job = await client.TranscriptionJobs.GetTranscriptionJobByIdAsync(id: job.Id!);
}

// Retrieve the transcript once the job is complete.
var transcript = await client.Transcript.GetTranscriptAsync(id: job.Id!);

Console.WriteLine($"Transcript has {transcript.Monologues.Count} monologues");