Skip to content

Commit

Permalink
[ Add, Edit ] added example part for audio transcriptions timestamp g…
Browse files Browse the repository at this point in the history
…ranularities, made example file loading in testing group
  • Loading branch information
anasfik committed Feb 21, 2024
1 parent 878b602 commit a9f1076
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion example/lib/create_audio_transcription.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions test/openai_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit a9f1076

Please sign in to comment.