Skip to content

Commit 54c978c

Browse files
authored
binding : Expose the audio_ctx param through the Go binding (#1368)
* expose the audio_ctx param through the go binding * expose the audio_ctx param to the go binding context
1 parent 9a7074d commit 54c978c

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

bindings/go/params.go

+6
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ func (p *Params) SetMaxTokensPerSegment(n int) {
118118
p.max_tokens = C.int(n)
119119
}
120120

121+
// Set audio encoder context
122+
func (p *Params) SetAudioCtx(n int) {
123+
p.audio_ctx = C.int(n)
124+
}
125+
121126
///////////////////////////////////////////////////////////////////////////////
122127
// PRIVATE METHODS
123128

@@ -141,6 +146,7 @@ func (p *Params) String() string {
141146
str += fmt.Sprintf(" n_max_text_ctx=%d", p.n_max_text_ctx)
142147
str += fmt.Sprintf(" offset_ms=%d", p.offset_ms)
143148
str += fmt.Sprintf(" duration_ms=%d", p.duration_ms)
149+
str += fmt.Sprintf(" audio_ctx=%d", p.audio_ctx)
144150
if p.translate {
145151
str += " translate"
146152
}

bindings/go/pkg/whisper/context.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func (context *context) SetSpeedup(v bool) {
8282
}
8383

8484
func (context *context) SetSplitOnWord(v bool) {
85-
context.params.SetSplitOnWord(v)
85+
context.params.SetSplitOnWord(v)
8686
}
8787

8888
// Set number of threads to use
@@ -125,6 +125,11 @@ func (context *context) SetMaxTokensPerSegment(n uint) {
125125
context.params.SetMaxTokensPerSegment(int(n))
126126
}
127127

128+
// Set audio encoder context
129+
func (context *context) SetAudioCtx(n uint) {
130+
context.params.SetAudioCtx(int(n))
131+
}
132+
128133
// ResetTimings resets the mode timings. Should be called before processing
129134
func (context *context) ResetTimings() {
130135
context.model.ctx.Whisper_reset_timings()

bindings/go/pkg/whisper/interface.go

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ type Context interface {
4848
SetMaxSegmentLength(uint) // Set max segment length in characters
4949
SetTokenTimestamps(bool) // Set token timestamps flag
5050
SetMaxTokensPerSegment(uint) // Set max tokens per segment (0 = no limit)
51+
SetAudioCtx(uint) // Set audio encoder context
5152

5253
// Process mono audio data and return any errors.
5354
// If defined, newly generated segments are passed to the

0 commit comments

Comments
 (0)