]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
go : added wrappers to reset and print timings (#436)
authorLukas Rist <redacted>
Wed, 25 Jan 2023 16:57:30 +0000 (17:57 +0100)
committerGitHub <redacted>
Wed, 25 Jan 2023 16:57:30 +0000 (18:57 +0200)
.gitignore
bindings/go/examples/go-whisper/process.go
bindings/go/pkg/whisper/context.go
bindings/go/pkg/whisper/interface.go

index 2f998a62acd9701964dd9bcf378daadeca235743..f9a12783d65e54b44144c99f40126d8e475f4669 100644 (file)
@@ -1,4 +1,5 @@
 *.o
+*.a
 .cache/
 .vs/
 .vscode/
index aacdc6965be9617c97c3ec346f9c3f53d7494daf..d4913be447dea836134f1693a54e47cd66ad1f45 100644 (file)
@@ -64,10 +64,13 @@ func Process(model whisper.Model, path string, flags *Flags) error {
 
        // Process the data
        fmt.Fprintf(flags.Output(), "  ...processing %q\n", path)
+       context.ResetTimings()
        if err := context.Process(data, cb); err != nil {
                return err
        }
 
+       context.PrintTimings()
+
        // Print out the results
        switch {
        case flags.GetOut() == "srt":
index 5dda57e97e63c91ccfdfd960c564f7bb0f4853a7..a4496b88a71724d69ef4248a88eb8d3117e1d01a 100644 (file)
@@ -107,6 +107,16 @@ func (context *context) SetMaxTokensPerSegment(n uint) {
        context.params.SetMaxTokensPerSegment(int(n))
 }
 
+// ResetTimings resets the mode timings. Should be called before processing
+func (context *context) ResetTimings() {
+       context.model.ctx.Whisper_reset_timings()
+}
+
+// PrintTimings prints the model timings to stdout.
+func (context *context) PrintTimings() {
+       context.model.ctx.Whisper_print_timings()
+}
+
 // Process new sample data and return any errors
 func (context *context) Process(data []float32, cb SegmentCallback) error {
        if context.model.ctx == nil {
index 5ca913a8f721defbc984c0d977917a52d8900c65..c587df936731f1afd0b4858792766820e401fd67 100644 (file)
@@ -60,6 +60,9 @@ type Context interface {
        IsNOT(Token) bool          // Test for "No timestamps" token
        IsLANG(Token, string) bool // Test for token associated with a specific language
        IsText(Token) bool         // Test for text token
+
+       PrintTimings()
+       ResetTimings()
 }
 
 // Segment is the text result of a speech recognition.