ggerganov commited on
Commit
fc6989a
·
unverified ·
1 Parent(s): 51d2d34

whisper.objc : disable timestamps for real-time transcription

Browse files
examples/whisper.objc/whisper.objc/ViewController.m CHANGED
@@ -206,6 +206,7 @@ void AudioInputCallback(void * inUserData,
206
  params.offset_ms = 0;
207
  params.no_context = true;
208
  params.single_segment = self->stateInp.isRealtime;
 
209
 
210
  CFTimeInterval startTime = CACurrentMediaTime();
211
 
 
206
  params.offset_ms = 0;
207
  params.no_context = true;
208
  params.single_segment = self->stateInp.isRealtime;
209
+ params.no_timestamps = params.single_segment;
210
 
211
  CFTimeInterval startTime = CACurrentMediaTime();
212
 
examples/whisper.swiftui/whisper.cpp.swift/LibWhisper.swift CHANGED
@@ -8,15 +8,15 @@ enum WhisperError: Error {
8
  // Meet Whisper C++ constraint: Don't access from more than one thread at a time.
9
  actor WhisperContext {
10
  private var context: OpaquePointer
11
-
12
  init(context: OpaquePointer) {
13
  self.context = context
14
  }
15
-
16
  deinit {
17
  whisper_free(context)
18
  }
19
-
20
  func fullTranscribe(samples: [Float]) {
21
  // Leave 2 processors free (i.e. the high-efficiency cores).
22
  let maxThreads = max(1, min(8, cpuCount() - 2))
@@ -24,17 +24,17 @@ actor WhisperContext {
24
  var params = whisper_full_default_params(WHISPER_SAMPLING_GREEDY)
25
  "en".withCString { en in
26
  // Adapted from whisper.objc
27
- params.print_realtime = true
28
- params.print_progress = false
29
  params.print_timestamps = true
30
- params.print_special = false
31
- params.translate = false
32
- params.language = en
33
- params.n_threads = Int32(maxThreads)
34
- params.offset_ms = 0
35
- params.no_context = true
36
- params.single_segment = false
37
-
38
  whisper_reset_timings(context)
39
  print("About to run whisper_full")
40
  samples.withUnsafeBufferPointer { samples in
@@ -46,7 +46,7 @@ actor WhisperContext {
46
  }
47
  }
48
  }
49
-
50
  func getTranscription() -> String {
51
  var transcription = ""
52
  for i in 0..<whisper_full_n_segments(context) {
@@ -54,7 +54,7 @@ actor WhisperContext {
54
  }
55
  return transcription
56
  }
57
-
58
  static func createContext(path: String) throws -> WhisperContext {
59
  var params = whisper_context_default_params()
60
  #if targetEnvironment(simulator)
 
8
  // Meet Whisper C++ constraint: Don't access from more than one thread at a time.
9
  actor WhisperContext {
10
  private var context: OpaquePointer
11
+
12
  init(context: OpaquePointer) {
13
  self.context = context
14
  }
15
+
16
  deinit {
17
  whisper_free(context)
18
  }
19
+
20
  func fullTranscribe(samples: [Float]) {
21
  // Leave 2 processors free (i.e. the high-efficiency cores).
22
  let maxThreads = max(1, min(8, cpuCount() - 2))
 
24
  var params = whisper_full_default_params(WHISPER_SAMPLING_GREEDY)
25
  "en".withCString { en in
26
  // Adapted from whisper.objc
27
+ params.print_realtime = true
28
+ params.print_progress = false
29
  params.print_timestamps = true
30
+ params.print_special = false
31
+ params.translate = false
32
+ params.language = en
33
+ params.n_threads = Int32(maxThreads)
34
+ params.offset_ms = 0
35
+ params.no_context = true
36
+ params.single_segment = false
37
+
38
  whisper_reset_timings(context)
39
  print("About to run whisper_full")
40
  samples.withUnsafeBufferPointer { samples in
 
46
  }
47
  }
48
  }
49
+
50
  func getTranscription() -> String {
51
  var transcription = ""
52
  for i in 0..<whisper_full_n_segments(context) {
 
54
  }
55
  return transcription
56
  }
57
+
58
  static func createContext(path: String) throws -> WhisperContext {
59
  var params = whisper_context_default_params()
60
  #if targetEnvironment(simulator)