

auto language detection #56
@a02417664aca568aa2ca2dea722f32f12cad2e51
--- whisper_online.py
+++ whisper_online.py
... | ... | @@ -30,7 +30,10 @@ |
30 | 30 |
self.logfile = logfile |
31 | 31 |
|
32 | 32 |
self.transcribe_kargs = {} |
33 |
- self.original_language = lan |
|
33 |
+ if lan == "auto": |
|
34 |
+ self.original_language = None |
|
35 |
+ else: |
|
36 |
+ self.original_language = lan |
|
34 | 37 |
|
35 | 38 |
self.model = self.load_model(modelsize, cache_dir, model_dir) |
36 | 39 |
|
... | ... | @@ -118,8 +121,11 @@ |
118 | 121 |
return model |
119 | 122 |
|
120 | 123 |
def transcribe(self, audio, init_prompt=""): |
124 |
+ |
|
121 | 125 |
# tested: beam_size=5 is faster and better than 1 (on one 200 second document from En ESIC, min chunk 0.01) |
122 | 126 |
segments, info = self.model.transcribe(audio, language=self.original_language, initial_prompt=init_prompt, beam_size=5, word_timestamps=True, condition_on_previous_text=True, **self.transcribe_kargs) |
127 |
+ #print(info) # info contains language detection result |
|
128 |
+ |
|
123 | 129 |
return list(segments) |
124 | 130 |
|
125 | 131 |
def ts_words(self, segments): |
... | ... | @@ -451,7 +457,7 @@ |
451 | 457 |
parser.add_argument('--model', type=str, default='large-v2', choices="tiny.en,tiny,base.en,base,small.en,small,medium.en,medium,large-v1,large-v2,large-v3,large".split(","),help="Name size of the Whisper model to use (default: large-v2). The model is automatically downloaded from the model hub if not present in model cache dir.") |
452 | 458 |
parser.add_argument('--model_cache_dir', type=str, default=None, help="Overriding the default model cache dir where models downloaded from the hub are saved") |
453 | 459 |
parser.add_argument('--model_dir', type=str, default=None, help="Dir where Whisper model.bin and other files are saved. This option overrides --model and --model_cache_dir parameter.") |
454 |
- parser.add_argument('--lan', '--language', type=str, default='en', help="Language code for transcription, e.g. en,de,cs.") |
|
460 |
+ parser.add_argument('--lan', '--language', type=str, default='en', help="Source language code, e.g. en,de,cs, or 'auto' for language detection.") |
|
455 | 461 |
parser.add_argument('--task', type=str, default='transcribe', choices=["transcribe","translate"],help="Transcribe or translate.") |
456 | 462 |
parser.add_argument('--backend', type=str, default="faster-whisper", choices=["faster-whisper", "whisper_timestamped"],help='Load only this backend for Whisper processing.') |
457 | 463 |
parser.add_argument('--vad', action="store_true", default=False, help='Use VAD = voice activity detection, with the default parameters.') |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?