Spaces:
Running
Running
binding : Expose the audio_ctx param through the Go binding (#1368)
Browse files* expose the audio_ctx param through the go binding
* expose the audio_ctx param to the go binding context
bindings/go/params.go
CHANGED
|
@@ -118,6 +118,11 @@ func (p *Params) SetMaxTokensPerSegment(n int) {
|
|
| 118 |
p.max_tokens = C.int(n)
|
| 119 |
}
|
| 120 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
///////////////////////////////////////////////////////////////////////////////
|
| 122 |
// PRIVATE METHODS
|
| 123 |
|
|
@@ -141,6 +146,7 @@ func (p *Params) String() string {
|
|
| 141 |
str += fmt.Sprintf(" n_max_text_ctx=%d", p.n_max_text_ctx)
|
| 142 |
str += fmt.Sprintf(" offset_ms=%d", p.offset_ms)
|
| 143 |
str += fmt.Sprintf(" duration_ms=%d", p.duration_ms)
|
|
|
|
| 144 |
if p.translate {
|
| 145 |
str += " translate"
|
| 146 |
}
|
|
|
|
| 118 |
p.max_tokens = C.int(n)
|
| 119 |
}
|
| 120 |
|
| 121 |
+
// Set audio encoder context
|
| 122 |
+
func (p *Params) SetAudioCtx(n int) {
|
| 123 |
+
p.audio_ctx = C.int(n)
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
///////////////////////////////////////////////////////////////////////////////
|
| 127 |
// PRIVATE METHODS
|
| 128 |
|
|
|
|
| 146 |
str += fmt.Sprintf(" n_max_text_ctx=%d", p.n_max_text_ctx)
|
| 147 |
str += fmt.Sprintf(" offset_ms=%d", p.offset_ms)
|
| 148 |
str += fmt.Sprintf(" duration_ms=%d", p.duration_ms)
|
| 149 |
+
str += fmt.Sprintf(" audio_ctx=%d", p.audio_ctx)
|
| 150 |
if p.translate {
|
| 151 |
str += " translate"
|
| 152 |
}
|
bindings/go/pkg/whisper/context.go
CHANGED
|
@@ -82,7 +82,7 @@ func (context *context) SetSpeedup(v bool) {
|
|
| 82 |
}
|
| 83 |
|
| 84 |
func (context *context) SetSplitOnWord(v bool) {
|
| 85 |
-
|
| 86 |
}
|
| 87 |
|
| 88 |
// Set number of threads to use
|
|
@@ -125,6 +125,11 @@ func (context *context) SetMaxTokensPerSegment(n uint) {
|
|
| 125 |
context.params.SetMaxTokensPerSegment(int(n))
|
| 126 |
}
|
| 127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
// ResetTimings resets the mode timings. Should be called before processing
|
| 129 |
func (context *context) ResetTimings() {
|
| 130 |
context.model.ctx.Whisper_reset_timings()
|
|
|
|
| 82 |
}
|
| 83 |
|
| 84 |
func (context *context) SetSplitOnWord(v bool) {
|
| 85 |
+
context.params.SetSplitOnWord(v)
|
| 86 |
}
|
| 87 |
|
| 88 |
// Set number of threads to use
|
|
|
|
| 125 |
context.params.SetMaxTokensPerSegment(int(n))
|
| 126 |
}
|
| 127 |
|
| 128 |
+
// Set audio encoder context
|
| 129 |
+
func (context *context) SetAudioCtx(n uint) {
|
| 130 |
+
context.params.SetAudioCtx(int(n))
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
// ResetTimings resets the mode timings. Should be called before processing
|
| 134 |
func (context *context) ResetTimings() {
|
| 135 |
context.model.ctx.Whisper_reset_timings()
|
bindings/go/pkg/whisper/interface.go
CHANGED
|
@@ -48,6 +48,7 @@ type Context interface {
|
|
| 48 |
SetMaxSegmentLength(uint) // Set max segment length in characters
|
| 49 |
SetTokenTimestamps(bool) // Set token timestamps flag
|
| 50 |
SetMaxTokensPerSegment(uint) // Set max tokens per segment (0 = no limit)
|
|
|
|
| 51 |
|
| 52 |
// Process mono audio data and return any errors.
|
| 53 |
// If defined, newly generated segments are passed to the
|
|
|
|
| 48 |
SetMaxSegmentLength(uint) // Set max segment length in characters
|
| 49 |
SetTokenTimestamps(bool) // Set token timestamps flag
|
| 50 |
SetMaxTokensPerSegment(uint) // Set max tokens per segment (0 = no limit)
|
| 51 |
+
SetAudioCtx(uint) // Set audio encoder context
|
| 52 |
|
| 53 |
// Process mono audio data and return any errors.
|
| 54 |
// If defined, newly generated segments are passed to the
|