Skip to content

Commit 3714bd2

Browse files
committed
[ added ] added docs and example for audio methods
1 parent 9552c35 commit 3714bd2

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

lib/src/instance/audio/audio.dart

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,30 @@ class OpenAIAudio implements OpenAIAudioBase {
2222
OpenAILogger.logEndpoint(endpoint);
2323
}
2424

25-
25+
/// Creates a transcription for a given audio file.
26+
///
27+
/// [file] is the [File] audio which is the audio file to be transcribed.
28+
///
29+
/// [model] is the model which to use for the transcription.
30+
///
31+
/// [prompt] is an optional text to guide the model's style or continue a previous audio segment. The prompt should be in English.
32+
///
33+
/// [responseFormat] is an optional format for the transcription. The default is [OpenAIAudioResponseFormat.json].
34+
///
35+
/// [temperature] is the sampling temperature for the request.
36+
///
37+
/// [language] is the language of the input audio. Supplying the input language in **ISO-639-1** format will improve accuracy and latency.
38+
///
39+
/// Example:
40+
/// ```dart
41+
/// final transcription = await openai.audio.createTranscription(
42+
/// file: File("audio.mp3"),
43+
/// model: "whisper-1",
44+
/// prompt: "This is a prompt",
45+
/// responseFormat: OpenAIAudioResponseFormat.srt,
46+
/// temperature: 0.5,
47+
/// );
48+
/// ```
2649
@override
2750
Future<OpenAIAudioModel> createTranscription({
2851
required File file,
@@ -48,6 +71,27 @@ class OpenAIAudio implements OpenAIAudioBase {
4871
);
4972
}
5073

74+
/// Creates a translation for a given audio file.
75+
///
76+
/// [file] is the [File] audio which is the audio file to be transcribed.
77+
///
78+
/// [model] is the model which to use for the transcription.
79+
///
80+
/// [prompt] is an optional text to guide the model's style or continue a previous audio segment. The prompt should be in English.
81+
///
82+
/// [responseFormat] is an optional format for the transcription. The default is [OpenAIAudioResponseFormat.json].
83+
///
84+
/// [temperature] is the sampling temperature for the request.
85+
///
86+
/// Example:
87+
/// ```dart
88+
/// final translation = await openai.audio.createTranslation(
89+
/// file: File("audio.mp3"),
90+
/// model: "whisper-1",
91+
/// prompt: "This is a prompt",
92+
/// responseFormat: OpenAIAudioResponseFormat.text,
93+
/// );
94+
/// ```
5195
@override
5296
Future<OpenAIAudioModel> createTranslation({
5397
required File file,

0 commit comments

Comments
 (0)