-
Notifications
You must be signed in to change notification settings - Fork 14
Transcription
Zoltan Juhasz edited this page May 2, 2023
·
1 revision
Speech-to-text, transcript audio
More info: https://platform.openai.com/docs/guides/speech-to-text/speech-to-text-beta
static async Task Main(string[] args)
{
using var host = Host.CreateDefaultBuilder(args)
.ConfigureServices((builder, services) =>
{
services.AddForgeOpenAI(options => {
options.AuthenticationInfo = builder.Configuration["OpenAI:ApiKey"]!;
});
})
.Build();
IOpenAIService openAi = host.Services.GetService<IOpenAIService>()!;
TranscriptionRequest request = new TranscriptionRequest();
request.AudioFile = new BinaryContentData()
{
ContentName = "audio.mp3",
SourceStream = File.OpenRead("audio.mp3")
};
HttpOperationResult<TranscriptionResponse> response =
await openAi.TranscriptionService
.GetAsync(request, CancellationToken.None)
.ConfigureAwait(false);
if (response.IsSuccess)
{
Console.WriteLine(response.Result?.Text);
}
else
{
Console.WriteLine(response);
}
}