[ Add, Edit ] added example part for audio transcriptions timestamp granularities, made example file loading in testing group

This commit is contained in:
Anas Fikhi
2024-02-21 23:03:03 +01:00
parent 878b602486
commit a9f107694b
2 changed files with 8 additions and 1 deletions

View File

@ -17,11 +17,13 @@ Future<void> main() async {
'https://www.cbvoiceovers.com/wp-content/uploads/2017/05/Commercial-showreel.mp3',
),
model: "whisper-1",
responseFormat: OpenAIAudioResponseFormat.text,
responseFormat: OpenAIAudioResponseFormat.verbose_json,
timestamp_granularities: [OpenAIAudioTimestampGranularity.segment],
);
// print the transcription.
print(transcription.text);
print(transcription.segments?.map((e) => e.end));
}
Future<File> getFileFromUrl(String networkUrl) async {

View File

@ -393,6 +393,11 @@ void main() async {
});
test("create transcription with timestamp granularity", () async {
final audioExampleFile = await getFileFromUrl(
"https://www.cbvoiceovers.com/wp-content/uploads/2017/05/Commercial-showreel.mp3",
fileExtension: "mp3",
);
final transcription = await OpenAI.instance.audio.createTranscription(
file: audioExampleFile,
model: "whisper-1",