Inspect the authenticated account, current team plan, and billing usage.
1 2 3 4 5 6 7 8 910111213141516171819202122232425
usingvarclient=newResembleAIClient(apiKey);// Load the signed-in account profile.varaccount=awaitclient.SubpackageAccount.GetAccountAsync();varemail=account.Item?.Email;// Load the first team record returned by the account API.varteam=awaitGetFirstTeamAsync(client);varteamName=team.Name;varteamPlan=team.Plan;// Load the default project to confirm project management responses are typed.varproject=awaitGetFirstProjectAsync(client);varprojectName=project.Name;varprojectUuid=project.Uuid;// Inspect current usage buckets reported by the billing endpoint.varbillingUsage=awaitclient.SubpackageAccount.GetBillingUsageAsync();varsynthesisUsage=billingUsage.Items?.Synth;vardetectionUsage=billingUsage.Items?.Detect;Console.WriteLine($"Email: {email}");Console.WriteLine($"Team: {teamName} ({teamPlan})");Console.WriteLine($"Project: {projectName} [{projectUuid}]");Console.WriteLine($"Usage: synth={synthesisUsage}, detect={detectionUsage}");
List voices
List ready-to-use voices and pick one that supports both sync and streaming TTS.
1234567
usingvarclient=newResembleAIClient(apiKey);// Fetch the first page of available voices from the management API.varvoices=awaitclient.SubpackageVoices.ListVoicesAsync(page:1,pageSize:10);varselectedVoice=awaitGetReadyVoiceAsync(client);Console.WriteLine($"Selected voice: {selectedVoice.Name} ({selectedVoice.Uuid})");
Text to speech
Synthesize a short WAV clip and save it to disk using one of the ready voices.
1 2 3 4 5 6 7 8 910111213141516171819202122
usingvarclient=newResembleAIClient(apiKey);varselectedVoice=awaitGetReadyVoiceAsync(client);try{// Synthesize a short clip to WAV audio.varresponse=awaitclient.SubpackageTextToSpeech.SynthesizeAsync(voiceUuid:selectedVoice.Uuid,data:"Hello from the Resemble AI SDK integration tests.",title:"resembleai-sync-sample",outputFormat:SynthesizePostRequestBodyContentApplicationJsonSchemaOutputFormat.Wav,sampleRate:SynthesizePostRequestBodyContentApplicationJsonSchemaSampleRate.x22050);// Persist the decoded audio payload to disk.awaitFile.WriteAllBytesAsync("resembleai-sync.wav",response.AudioContent!);Console.WriteLine($"Saved {response.AudioContent?.Length ?? 0} bytes using {selectedVoice.Name}.");}catch(ApiExceptionex){AssertFeatureAvailable(ex,"text-to-speech");}
Streaming text to speech
Stream a short WAV response and save the resulting bytes to disk.
1 2 3 4 5 6 7 8 910111213141516171819
usingvarclient=newResembleAIClient(apiKey);varselectedVoice=awaitGetReadyVoiceAsync(client);try{// Stream synthesized audio as a WAV byte buffer.varaudioBytes=awaitclient.SubpackageTextToSpeech.StreamSynthesizeAsync(voiceUuid:selectedVoice.Uuid,data:"This is a streaming text to speech check for the Resemble AI SDK.",sampleRate:StreamPostRequestBodyContentApplicationJsonSchemaSampleRate.x22050);awaitFile.WriteAllBytesAsync("resembleai-stream.wav",audioBytes);Console.WriteLine($"Saved {audioBytes.Length} streamed bytes using {selectedVoice.Name}.");}catch(ApiExceptionex){AssertFeatureAvailable(ex,"streaming text-to-speech");}
Speech to text from a file
Upload a local WAV file, poll until the transcript completes, and print the recognized text.
1 2 3 4 5 6 7 8 9101112131415161718192021
usingvarclient=newResembleAIClient(apiKey);varfixture=GetPrimaryAudioFixture();varaudioBytes=awaitLoadAudioFixtureAsync(fixture);try{// Submit a small local WAV file for transcription.varcreatedTranscript=awaitclient.SubpackageSpeechToText.CreateTranscriptAsync(file:audioBytes,filename:fixture.FileName);// Poll the transcript until it reaches a terminal state.vartranscript=awaitWaitForTranscriptCompletionAsync(client,createdTranscript.Item!.Uuid!.Value);Console.WriteLine(transcript.Item?.Text);AssertTranscriptLooksReasonable(transcript.Item?.Text,fixture);}catch(ApiExceptionex){AssertFeatureAvailable(ex,"speech-to-text");}
Audio edit
Replace part of a short WAV clip by submitting the original and target transcript text.
1 2 3 4 5 6 7 8 910111213141516171819202122
usingvarclient=newResembleAIClient(apiKey);varfixture=GetPrimaryAudioFixture();varselectedVoice=awaitGetEditableVoiceAsync(client);varaudioBytes=awaitLoadAudioFixtureAsync(fixture);try{// Submit an edit request that replaces the spoken text with new content.varaudioEdit=awaitclient.SubpackageAudioEdit.CreateAudioEditAsync(inputAudio:audioBytes,inputAudioname:fixture.FileName,originalTranscript:fixture.Transcript,targetTranscript:fixture.EditedTranscript,voiceUuid:selectedVoice.Uuid);Console.WriteLine($"Audio edit job: {audioEdit.Item?.Uuid}");}catch(ApiExceptionex){AssertFeatureAvailable(ex,"audio edit");}