aadnk commited on
Commit
c963436
1 Parent(s): 4711ad3

Adding example useage in whisperProgressHook

Browse files
Files changed (1) hide show
  1. src/hooks/whisperProgressHook.py +15 -3
src/hooks/whisperProgressHook.py CHANGED
@@ -111,9 +111,21 @@ def unregister_thread_local_progress_listener(progress_listener: ProgressListene
111
  def create_progress_listener_handle(progress_listener: ProgressListener):
112
  return ProgressListenerHandle(progress_listener)
113
 
 
114
  if __name__ == '__main__':
115
- with create_progress_listener_handle(ProgressListener()) as listener:
116
- # Call model.transcribe here
117
- pass
 
 
 
 
 
 
 
 
 
 
 
118
 
119
  print("Done")
 
111
  def create_progress_listener_handle(progress_listener: ProgressListener):
112
  return ProgressListenerHandle(progress_listener)
113
 
114
+ # Example usage
115
  if __name__ == '__main__':
116
+ class PrintingProgressListener:
117
+ def on_progress(self, current: Union[int, float], total: Union[int, float]):
118
+ print(f"Progress: {current}/{total}")
119
+
120
+ def on_finished(self):
121
+ print("Finished")
122
+
123
+ import whisper
124
+ model = whisper.load_model("medium")
125
+
126
+ with create_progress_listener_handle(PrintingProgressListener()) as listener:
127
+ # Set verbose to None to disable the progress bar, as we are using our own
128
+ result = model.transcribe("J:\\Dev\\OpenAI\\whisper\\tests\\Noriko\\out.mka", language="Japanese", fp16=False, verbose=None)
129
+ print(result)
130
 
131
  print("Done")