1
-
2
- use serde:: Serialize ;
3
-
1
+ use serde:: { Deserialize , Serialize } ;
4
2
5
3
#[ derive( Debug , Serialize ) ]
6
4
pub struct TranscriptionResponse {
@@ -27,3 +25,43 @@ pub struct ErrorDetail {
27
25
pub param : Option < String > ,
28
26
pub code : Option < String > ,
29
27
}
28
+
29
+ pub fn default_model ( ) -> String {
30
+ "whisper-1" . to_string ( )
31
+ }
32
+
33
+ pub fn default_response_format ( ) -> String {
34
+ "json" . to_string ( )
35
+ }
36
+
37
+ pub fn default_temperature ( ) -> f32 {
38
+ 0.0
39
+ }
40
+
41
+ #[ derive( Debug , Deserialize ) ]
42
+ pub struct TranscriptionRequest {
43
+ /// The audio file object to transcribe
44
+ /// In multipart form, this would be the file field
45
+
46
+ /// ID of the model to use. Only whisper-1 is currently available.
47
+ #[ serde( default = "default_model" ) ]
48
+ pub model : String ,
49
+
50
+ /// The language of the input audio
51
+ pub language : Option < String > ,
52
+
53
+ /// An optional text to guide the model's style or continue a previous audio segment
54
+ pub prompt : Option < String > ,
55
+
56
+ /// The format of the transcript output
57
+ #[ serde( default = "default_response_format" ) ]
58
+ pub response_format : String ,
59
+
60
+ /// The sampling temperature, between 0 and 1
61
+ #[ serde( default = "default_temperature" ) ]
62
+ pub temperature : f32 ,
63
+
64
+ /// Enable streaming response
65
+ #[ serde( default ) ]
66
+ pub stream : bool ,
67
+ }
0 commit comments