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