Skip to content

Commit

Permalink
refactor(audio): use nullable list for words
Browse files Browse the repository at this point in the history
  • Loading branch information
aallam committed Apr 1, 2024
1 parent e78654d commit 6527123
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### Added

- **Audio**: add `timestampGranularities`
- **Audio**: add `timestampGranularities` (thanks @mxwell)

## 3.7.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ internal class AudioApi(val requester: HttpRequester) : Audio {
request.temperature?.let { append(key = "temperature", value = it) }
request.language?.let { append(key = "language", value = it) }
if (request.responseFormat == AudioResponseFormat.VerboseJson) {
for (timestampGranularity in request.timestampGranularities) {
for (timestampGranularity in request.timestampGranularities.orEmpty()) {
append(key = "timestamp_granularities[]", value = timestampGranularity.value)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.aallam.openai.api.audio

import com.aallam.openai.api.BetaOpenAI
import com.aallam.openai.api.OpenAIDsl
import com.aallam.openai.api.file.FileSource
import com.aallam.openai.api.model.ModelId
Expand Down Expand Up @@ -46,11 +45,11 @@ public class TranscriptionRequest(

/**
* The timestamp granularities to populate for this transcription.
* responseFormat must be set verbose_json to use timestamp granularities.
* Either or both of these options are supported: word, or segment.
* [responseFormat] must be set [AudioResponseFormat.VerboseJson] to use timestamp granularities.
* Either or both of these options are supported: [TimestampGranularity.Word], or [TimestampGranularity.Segment].
* Note: There is no additional latency for segment timestamps, but generating word timestamps incurs additional latency.
*/
public val timestampGranularities: List<TimestampGranularity> = emptyList(),
public val timestampGranularities: List<TimestampGranularity>? = null,
)

/**
Expand Down Expand Up @@ -104,7 +103,7 @@ public class TranscriptionRequestBuilder {
* Either or both of these options are supported: word, or segment.
* Note: There is no additional latency for segment timestamps, but generating word timestamps incurs additional latency.
*/
public var timestampGranularities: List<TimestampGranularity> = emptyList()
public var timestampGranularities: List<TimestampGranularity>? = null

/**
* Builder of [TranscriptionRequest] instances.
Expand Down

0 comments on commit 6527123

Please sign in to comment.