Skip to content

RevAI

Nuget package dotnet License: MIT Discord

Features 🔥

  • Fully generated C# SDK based on official RevAI OpenAPI specification using AutoSDK
  • Same day update to support new features
  • Updated and supported automatically if there are no breaking changes
  • All modern .NET features - nullability, trimming, NativeAOT, etc.
  • Support .Net Framework/.Net Standard 2.0

Usage

1
2
3
using RevAI;

using var client = new RevAIClient(apiKey);

MeaiTools

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
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);

// Create tools for transcription, job status, and job listing.
var transcribeTool = client.AsTranscribeUrlTool(defaultLanguage: "en");
var getJobStatusTool = client.AsGetJobStatusTool();
var listJobsTool = client.AsListJobsTool(defaultLimit: 5);

// These tools can be passed to any IChatClient that supports function calling.
var tools = new[] { transcribeTool, getJobStatusTool, listJobsTool };

SpeechToText

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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);
ISpeechToTextClient sttClient = client;

// Provide an audio URL via RawRepresentationFactory.
var options = new SpeechToTextOptions
{
    SpeechLanguage = "en",
    RawRepresentationFactory = _ => new SubmitTranscriptionJobRequest
    {
        MediaUrl = "https://www.rev.ai/FTC_Sample_1.mp3",
    },
};

// Get the transcription result.
var response = await sttClient.GetTextAsync(
    audioSpeechStream: Stream.Null,
    options: options);

Console.WriteLine($"Transcript: {response.Text[..Math.Min(200, response.Text.Length)]}...");

Transcription

 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");

Generate

Basic example showing how to create a client and make a request.

1
using var client = new RevAIClient(apiKey);

Support

Priority place for bugs: https://github.com/tryAGI/RevAI/issues
Priority place for ideas and general questions: https://github.com/tryAGI/RevAI/discussions
Discord: https://discord.gg/Ca2xhfBf3v

Acknowledgments

JetBrains logo

This project is supported by JetBrains through the Open Source Support Program.