openai/openai-dotnet
Publicmirrored from https://github.com/openai/openai-dotnetAvailable
examples/Audio/Example02_SimpleTranscriptionAsync.cs
22lines · modecode
| 1 | using NUnit.Framework; |
| 2 | using OpenAI.Audio; |
| 3 | using System; |
| 4 | using System.IO; |
| 5 | using System.Threading.Tasks; |
| 6 | |
| 7 | namespace OpenAI.Examples; |
| 8 | |
| 9 | public partial class AudioExamples |
| 10 | { |
| 11 | [Test] |
| 12 | public async Task Example02_SimpleTranscriptionAsync() |
| 13 | { |
| 14 | AudioClient client = new("whisper-1", Environment.GetEnvironmentVariable("OPENAI_API_KEY")); |
| 15 | |
| 16 | string audioFilePath = Path.Combine("Assets", "audio_houseplant_care.mp3"); |
| 17 | |
| 18 | AudioTranscription transcription = await client.TranscribeAudioAsync(audioFilePath); |
| 19 | |
| 20 | Console.WriteLine($"{transcription.Text}"); |
| 21 | } |
| 22 | } |
| 23 | |