VerboseTranscription

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using var api = GetAuthenticatedClient();

OneOf<CreateTranscriptionResponseJson, CreateTranscriptionResponseVerboseJson> response = await api.Audio.CreateTranscriptionAsync(
    file: H.Resources.audio_houseplant_care_mp3.AsBytes(),
    filename: H.Resources.audio_houseplant_care_mp3.FileName,
    model: CreateTranscriptionRequestModel.Whisper1,
    responseFormat: AudioResponseFormat.VerboseJson,
    timestampGranularities: [
        CreateTranscriptionRequestTimestampGranularitie.Word,
        CreateTranscriptionRequestTimestampGranularitie.Segment
    ]);

response.Value2.Should().NotBeNull();

Console.WriteLine("Transcription:");
Console.WriteLine($"{response.Value2!.Text}");

Console.WriteLine();
Console.WriteLine($"Words:");
foreach (TranscriptionWord word in response.Value2.Words ?? [])
{
    Console.WriteLine($"  {word.Word,15} : {word.Start * 1000,5:0} - {word.End * 1000,5:0}");
}

Console.WriteLine();
Console.WriteLine($"Segments:");
foreach (TranscriptionSegment segment in response.Value2.Segments ?? [])
{
    Console.WriteLine($"  {segment.Text,90} : {segment.Start * 1000,5:0} - {segment.End * 1000,5:0}");
}