openai/openai-dotnet
Publicmirrored from https://github.com/openai/openai-dotnetAvailable
examples/Audio/Example04_SimpleTranslationAsync.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 Example04_SimpleTranslationAsync() |
| 13 | { |
| 14 | AudioClient client = new("whisper-1", Environment.GetEnvironmentVariable("OPENAI_API_KEY")); |
| 15 | |
| 16 | string audioFilePath = Path.Combine("Assets", "audio_french.wav"); |
| 17 | |
| 18 | AudioTranslation translation = await client.TranslateAudioAsync(audioFilePath); |
| 19 | |
| 20 | Console.WriteLine($"{translation.Text}"); |
| 21 | } |
| 22 | } |
| 23 | |