Skip to content

Speech to text from a file

Upload a local WAV file, poll until the transcript completes, and print the recognized text.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
using var client = new ResembleAIClient(apiKey);
var fixture = GetPrimaryAudioFixture();
var audioBytes = await LoadAudioFixtureAsync(fixture);

try
{
    // Submit a small local WAV file for transcription.
    var createdTranscript = await client.SubpackageSpeechToText.CreateTranscriptAsync(
        file: audioBytes,
        filename: fixture.FileName);

    // Poll the transcript until it reaches a terminal state.
    var transcript = await WaitForTranscriptCompletionAsync(client, createdTranscript.Item!.Uuid!.Value);
    Console.WriteLine(transcript.Item?.Text);

    AssertTranscriptLooksReasonable(transcript.Item?.Text, fixture);
}
catch (ApiException ex)
{
    AssertFeatureAvailable(ex, "speech-to-text");
}