Skip to content

SpeechToText

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

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

// Create a Speechmatics client that implements ISpeechToTextClient.
using var client = new SpeechmaticsClient(apiKey);
ISpeechToTextClient sttClient = client;

// Verify the client provides proper metadata.
var metadata = sttClient.GetService<SpeechToTextClientMetadata>();

// The client can also be retrieved via GetService.
var self = sttClient.GetService<SpeechmaticsClient>();