Spaces:
Running
Running
go : add SetInitialPrompt method to bindings (#1753)
Browse files
bindings/go/params.go
CHANGED
|
@@ -123,6 +123,11 @@ func (p *Params) SetAudioCtx(n int) {
|
|
| 123 |
p.audio_ctx = C.int(n)
|
| 124 |
}
|
| 125 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
///////////////////////////////////////////////////////////////////////////////
|
| 127 |
// PRIVATE METHODS
|
| 128 |
|
|
@@ -147,6 +152,7 @@ func (p *Params) String() string {
|
|
| 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 |
}
|
|
|
|
| 123 |
p.audio_ctx = C.int(n)
|
| 124 |
}
|
| 125 |
|
| 126 |
+
// Set initial prompt
|
| 127 |
+
func (p *Params) SetInitialPrompt(prompt string) {
|
| 128 |
+
p.initial_prompt = C.CString(prompt)
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
///////////////////////////////////////////////////////////////////////////////
|
| 132 |
// PRIVATE METHODS
|
| 133 |
|
|
|
|
| 152 |
str += fmt.Sprintf(" offset_ms=%d", p.offset_ms)
|
| 153 |
str += fmt.Sprintf(" duration_ms=%d", p.duration_ms)
|
| 154 |
str += fmt.Sprintf(" audio_ctx=%d", p.audio_ctx)
|
| 155 |
+
str += fmt.Sprintf(" initial_prompt=%s", C.GoString(p.initial_prompt))
|
| 156 |
if p.translate {
|
| 157 |
str += " translate"
|
| 158 |
}
|
bindings/go/pkg/whisper/context.go
CHANGED
|
@@ -130,6 +130,11 @@ 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()
|
|
|
|
| 130 |
context.params.SetAudioCtx(int(n))
|
| 131 |
}
|
| 132 |
|
| 133 |
+
// Set initial prompt
|
| 134 |
+
func (context *context) SetInitialPrompt(prompt string) {
|
| 135 |
+
context.params.SetInitialPrompt(prompt)
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
// ResetTimings resets the mode timings. Should be called before processing
|
| 139 |
func (context *context) ResetTimings() {
|
| 140 |
context.model.ctx.Whisper_reset_timings()
|
bindings/go/pkg/whisper/interface.go
CHANGED
|
@@ -38,17 +38,18 @@ type Context interface {
|
|
| 38 |
IsMultilingual() bool // Return true if the model is multilingual.
|
| 39 |
Language() string // Get language
|
| 40 |
|
| 41 |
-
SetOffset(time.Duration)
|
| 42 |
-
SetDuration(time.Duration)
|
| 43 |
-
SetThreads(uint)
|
| 44 |
-
SetSpeedup(bool)
|
| 45 |
-
SetSplitOnWord(bool)
|
| 46 |
-
SetTokenThreshold(float32)
|
| 47 |
-
SetTokenSumThreshold(float32)
|
| 48 |
-
SetMaxSegmentLength(uint)
|
| 49 |
-
SetTokenTimestamps(bool)
|
| 50 |
-
SetMaxTokensPerSegment(uint)
|
| 51 |
-
SetAudioCtx(uint)
|
|
|
|
| 52 |
|
| 53 |
// Process mono audio data and return any errors.
|
| 54 |
// If defined, newly generated segments are passed to the
|
|
|
|
| 38 |
IsMultilingual() bool // Return true if the model is multilingual.
|
| 39 |
Language() string // Get language
|
| 40 |
|
| 41 |
+
SetOffset(time.Duration) // Set offset
|
| 42 |
+
SetDuration(time.Duration) // Set duration
|
| 43 |
+
SetThreads(uint) // Set number of threads to use
|
| 44 |
+
SetSpeedup(bool) // Set speedup flag
|
| 45 |
+
SetSplitOnWord(bool) // Set split on word flag
|
| 46 |
+
SetTokenThreshold(float32) // Set timestamp token probability threshold
|
| 47 |
+
SetTokenSumThreshold(float32) // Set timestamp token sum probability threshold
|
| 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 |
+
SetInitialPrompt(prompt string) // Set initial prompt
|
| 53 |
|
| 54 |
// Process mono audio data and return any errors.
|
| 55 |
// If defined, newly generated segments are passed to the
|