@@ -11,19 +11,28 @@ Future<void> main() async {
1111// Set the OpenAI API key from the .env file.
1212 OpenAI .apiKey = Env .apiKey;
1313
14+ final textAudioFile =
15+ "https://www.cbvoiceovers.com/wp-content/uploads/2017/05/Commercial-showreel.mp3" ;
16+
1417// create the audio transcription.
1518 final transcription = await OpenAI .instance.audio.createTranscription (
16- file: await getFileFromUrl (
17- 'https://www.cbvoiceovers.com/wp-content/uploads/2017/05/Commercial-showreel.mp3' ,
18- ),
1919 model: "whisper-1" ,
20+ file: await getFileFromUrl (textAudioFile),
21+ include: ["logprobs" ],
2022 responseFormat: OpenAIAudioResponseFormat .verbose_json,
21- timestampGranularities: [OpenAIAudioTimestampGranularity .segment],
23+ language: "en" ,
24+ prompt: "transcribe this audio with 0.5x speed" ,
2225 );
2326
24- // print the transcription.
25- print (transcription.text);
26- print (transcription.segments? .map ((e) => e.end));
27+ if (transcription is OpenAITranscriptionModel ) {
28+ print (transcription.logprobs);
29+ print (transcription.text);
30+ print (transcription.usage);
31+ } else if (transcription is OpenAITranscriptionVerboseModel ) {
32+ // print the transcription.
33+ print (transcription.text);
34+ print (transcription.segments? .map ((e) => e.end));
35+ }
2736}
2837
2938Future <File > getFileFromUrl (String networkUrl) async {
0 commit comments