Lukas Rist commited on
Commit
89e8314
·
unverified ·
1 Parent(s): 4f14c97

go : added wrappers to reset and print timings (#436)

Browse files
.gitignore CHANGED
@@ -1,4 +1,5 @@
1
  *.o
 
2
  .cache/
3
  .vs/
4
  .vscode/
 
1
  *.o
2
+ *.a
3
  .cache/
4
  .vs/
5
  .vscode/
bindings/go/examples/go-whisper/process.go CHANGED
@@ -64,10 +64,13 @@ func Process(model whisper.Model, path string, flags *Flags) error {
64
 
65
  // Process the data
66
  fmt.Fprintf(flags.Output(), " ...processing %q\n", path)
 
67
  if err := context.Process(data, cb); err != nil {
68
  return err
69
  }
70
 
 
 
71
  // Print out the results
72
  switch {
73
  case flags.GetOut() == "srt":
 
64
 
65
  // Process the data
66
  fmt.Fprintf(flags.Output(), " ...processing %q\n", path)
67
+ context.ResetTimings()
68
  if err := context.Process(data, cb); err != nil {
69
  return err
70
  }
71
 
72
+ context.PrintTimings()
73
+
74
  // Print out the results
75
  switch {
76
  case flags.GetOut() == "srt":
bindings/go/pkg/whisper/context.go CHANGED
@@ -107,6 +107,16 @@ func (context *context) SetMaxTokensPerSegment(n uint) {
107
  context.params.SetMaxTokensPerSegment(int(n))
108
  }
109
 
 
 
 
 
 
 
 
 
 
 
110
  // Process new sample data and return any errors
111
  func (context *context) Process(data []float32, cb SegmentCallback) error {
112
  if context.model.ctx == nil {
 
107
  context.params.SetMaxTokensPerSegment(int(n))
108
  }
109
 
110
+ // ResetTimings resets the mode timings. Should be called before processing
111
+ func (context *context) ResetTimings() {
112
+ context.model.ctx.Whisper_reset_timings()
113
+ }
114
+
115
+ // PrintTimings prints the model timings to stdout.
116
+ func (context *context) PrintTimings() {
117
+ context.model.ctx.Whisper_print_timings()
118
+ }
119
+
120
  // Process new sample data and return any errors
121
  func (context *context) Process(data []float32, cb SegmentCallback) error {
122
  if context.model.ctx == nil {
bindings/go/pkg/whisper/interface.go CHANGED
@@ -60,6 +60,9 @@ type Context interface {
60
  IsNOT(Token) bool // Test for "No timestamps" token
61
  IsLANG(Token, string) bool // Test for token associated with a specific language
62
  IsText(Token) bool // Test for text token
 
 
 
63
  }
64
 
65
  // Segment is the text result of a speech recognition.
 
60
  IsNOT(Token) bool // Test for "No timestamps" token
61
  IsLANG(Token, string) bool // Test for token associated with a specific language
62
  IsText(Token) bool // Test for text token
63
+
64
+ PrintTimings()
65
+ ResetTimings()
66
  }
67
 
68
  // Segment is the text result of a speech recognition.