如何将 Azure OpenAI SDK 与 Whisper 结合使用进行语音到文本翻译

问题描述 投票:0回答:1

使用:

<PackageReference Include="Azure.AI.OpenAI" Version="2.0.0-beta.2" />

我有这个简单的代码:

var client = new OpenAIClient(
    new ApiKeyCredential(apiKey),
    new OpenAIClientOptions { Endpoint = new Uri(apiEndPoint) }
    );

var transcriptionOptions = new AudioTranscriptionOptions() { ResponseFormat = AudioTranscriptionFormat.Simple };

var audioClient = client.GetAudioClient(deploymentId);
var bytes = File.ReadAllBytes(filePath);
var stream = new MemoryStream(bytes);

var result = await audioClient.TranscribeAudioAsync(stream, fileName, transcriptionOptions);

我收到 404 错误。

端点和 API 密钥是直接从 Playground 快速启动窗口获取的,所以应该没问题:

enter image description here

我错过了什么?

azure azure-openai openai-whisper
1个回答
0
投票

明白了 - 只需使用正确的类型/类即可:

var client = new AzureOpenAIClient(
    new Uri(apiEndPoint),
    new ApiKeyCredential(apiKey)
    );

var audioClient = client.GetAudioClient(deploymentId);
var bytes = File.ReadAllBytes(filePath);
var stream = new MemoryStream(bytes);

var transcriptionOptions = new AudioTranscriptionOptions() { ResponseFormat = AudioTranscriptionFormat.Simple };
var result = await audioClient.TranscribeAudioAsync(stream, fileName, transcriptionOptions);
© www.soinside.com 2019 - 2024. All rights reserved.