-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for GPT 3.5, 4.0, and audio translations and transcript… (
#43) * Added support for GPT 3.5, 4.0, and audio translations and transcriptions. * Added tags to nuget package for gpt-3.5, gpt-4, and whisper. * Addressed null reference issues.
- Loading branch information
Showing
28 changed files
with
1,421 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Whetstone.ChatGPT.Models; | ||
using static System.Net.Mime.MediaTypeNames; | ||
|
||
namespace Whetstone.ChatGPT.Test | ||
{ | ||
public class AudioWhisperTests | ||
{ | ||
[Fact(Skip = "reduce testing costs")] | ||
public async Task TranscribeFileAsync() | ||
{ | ||
ChatGPTAudioTranscriptionRequest? uploadRequest = new ChatGPTAudioTranscriptionRequest | ||
{ | ||
File = GetAudioFileContent() | ||
}; | ||
using IChatGPTClient client = ChatGPTTestUtilties.GetClient(); | ||
|
||
ChatGPTAudioResponse? audioResponse = await client.CreateTranscriptionAsync(uploadRequest, true); | ||
|
||
string? text = audioResponse?.Text; | ||
|
||
Assert.NotNull(text); | ||
} | ||
|
||
[Fact(Skip = "reduce testing costs")] | ||
public async Task TranscribeFileToTextAsync() | ||
{ | ||
ChatGPTAudioTranscriptionRequest? uploadRequest = new ChatGPTAudioTranscriptionRequest | ||
{ | ||
File = GetAudioFileContent() | ||
}; | ||
using IChatGPTClient client = ChatGPTTestUtilties.GetClient(); | ||
|
||
string? textReponse = await client.CreateTranscriptionAsync(uploadRequest, AudioResponseFormatText.WebVtt); | ||
|
||
Assert.NotNull(textReponse); | ||
} | ||
|
||
[Fact(Skip = "reduce testing costs")] | ||
public async Task TranslateFileAsync() | ||
{ | ||
ChatGPTAudioTranslationRequest? uploadRequest = new ChatGPTAudioTranslationRequest | ||
{ | ||
File = GetAudioFileContent() | ||
}; | ||
using IChatGPTClient client = ChatGPTTestUtilties.GetClient(); | ||
|
||
ChatGPTAudioResponse? audioResponse = await client.CreateTranslationAsync(uploadRequest, true); | ||
|
||
string? text = audioResponse?.Text; | ||
|
||
Assert.NotNull(text); | ||
} | ||
|
||
[Fact(Skip = "reduce testing costs")] | ||
public async Task TranslateFileToTextAsync() | ||
{ | ||
ChatGPTAudioTranslationRequest? uploadRequest = new ChatGPTAudioTranslationRequest | ||
{ | ||
File = GetAudioFileContent() | ||
}; | ||
using IChatGPTClient client = ChatGPTTestUtilties.GetClient(); | ||
|
||
string? textReponse = await client.CreateTranslationAsync(uploadRequest, AudioResponseFormatText.WebVtt); | ||
|
||
Assert.NotNull(textReponse); | ||
} | ||
|
||
|
||
private ChatGPTFileContent GetAudioFileContent() | ||
{ | ||
string audioFile = @"audiofiles\transcriptiontest.mp3"; | ||
|
||
byte[] fileContents = File.ReadAllBytes(audioFile); | ||
ChatGPTFileContent gptFile = new ChatGPTFileContent | ||
{ | ||
FileName = audioFile, | ||
Content = fileContents | ||
}; | ||
|
||
return gptFile; | ||
} | ||
} | ||
} |
Oops, something went wrong.