Skip to content

Commit 33d3223

Browse files
authored
Merge pull request #183 from dongri/Fix-AudioTranscriptionRequest
Add TimestampGranularity
2 parents 0b3171c + c1edf2f commit 33d3223

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/v1/audio.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ use crate::impl_builder_methods;
55

66
pub const WHISPER_1: &str = "whisper-1";
77

8+
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
9+
#[serde(rename_all = "lowercase")]
10+
pub enum TimestampGranularity {
11+
Word,
12+
Segment,
13+
}
14+
815
#[derive(Debug, Serialize, Clone)]
916
pub struct AudioTranscriptionRequest {
1017
pub model: String,
@@ -19,6 +26,8 @@ pub struct AudioTranscriptionRequest {
1926
pub temperature: Option<f32>,
2027
#[serde(skip_serializing_if = "Option::is_none")]
2128
pub language: Option<String>,
29+
#[serde(skip_serializing_if = "Option::is_none")]
30+
pub timestamp_granularities: Option<Vec<TimestampGranularity>>,
2231
}
2332

2433
impl AudioTranscriptionRequest {
@@ -31,6 +40,7 @@ impl AudioTranscriptionRequest {
3140
response_format: None,
3241
temperature: None,
3342
language: None,
43+
timestamp_granularities: None,
3444
}
3545
}
3646

@@ -43,6 +53,7 @@ impl AudioTranscriptionRequest {
4353
response_format: None,
4454
temperature: None,
4555
language: None,
56+
timestamp_granularities: None,
4657
}
4758
}
4859
}
@@ -52,7 +63,8 @@ impl_builder_methods!(
5263
prompt: String,
5364
response_format: String,
5465
temperature: f32,
55-
language: String
66+
language: String,
67+
timestamp_granularities: Vec<TimestampGranularity>
5668
);
5769

5870
#[derive(Debug, Deserialize, Serialize)]

0 commit comments

Comments
 (0)