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
123
usingRevAI;usingvarclient=newRevAIClient(apiKey);
MeaiTools
1 2 3 4 5 6 7 8 91011121314
varapiKey=Environment.GetEnvironmentVariable("REVAI_API_KEY")is{Length:>0}value?value:thrownewAssertInconclusiveException("REVAI_API_KEY environment variable is not found.");usingvarclient=newRevAIClient(apiKey);// Create tools for transcription, job status, and job listing.vartranscribeTool=client.AsTranscribeUrlTool(defaultLanguage:"en");vargetJobStatusTool=client.AsGetJobStatusTool();varlistJobsTool=client.AsListJobsTool(defaultLimit:5);// These tools can be passed to any IChatClient that supports function calling.vartools=new[]{transcribeTool,getJobStatusTool,listJobsTool};
SpeechToText
1 2 3 4 5 6 7 8 9101112131415161718192021222324
varapiKey=Environment.GetEnvironmentVariable("REVAI_API_KEY")is{Length:>0}value?value:thrownewAssertInconclusiveException("REVAI_API_KEY environment variable is not found.");usingvarclient=newRevAIClient(apiKey);ISpeechToTextClientsttClient=client;// Provide an audio URL via RawRepresentationFactory.varoptions=newSpeechToTextOptions{SpeechLanguage="en",RawRepresentationFactory=_=>newSubmitTranscriptionJobRequest{MediaUrl="https://www.rev.ai/FTC_Sample_1.mp3",},};// Get the transcription result.varresponse=awaitsttClient.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 910111213141516171819202122
varapiKey=Environment.GetEnvironmentVariable("REVAI_API_KEY")is{Length:>0}value?value:thrownewAssertInconclusiveException("REVAI_API_KEY environment variable is not found.");usingvarclient=newRevAIClient(apiKey);// Submit a transcription job by providing a URL to an audio file.varjob=awaitclient.TranscriptionJobs.SubmitTranscriptionJobAsync(mediaUrl:"https://www.rev.ai/FTC_Sample_1.mp3");// The job runs asynchronously. Poll until it completes.while(job.Status==TranscriptionJobStatus.InProgress){awaitTask.Delay(TimeSpan.FromSeconds(5));job=awaitclient.TranscriptionJobs.GetTranscriptionJobByIdAsync(id:job.Id!);}// Retrieve the transcript once the job is complete.vartranscript=awaitclient.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.