使用:
<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 快速启动窗口获取的,所以应该没问题:
我错过了什么?
明白了 - 只需使用正确的类型/类即可:
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);