mazesmazes commited on
Commit
0629e74
·
verified ·
1 Parent(s): 712d971

Update custom model files, README, and requirements

Browse files
Files changed (2) hide show
  1. asr_pipeline.py +6 -5
  2. requirements.txt +1 -2
asr_pipeline.py CHANGED
@@ -489,11 +489,11 @@ class ASRPipeline(transformers.AutomaticSpeechRecognitionPipeline):
489
  text = text.lower()
490
 
491
  # 2. REMOVE REPETITIVE LOOPS
492
- # If the model repeats the same phrase more than twice, cut it off.
493
  words = text.split()
494
  if len(words) > 10:
495
- # Check for repeating n-grams (1 to 4 words long)
496
- for n in range(1, 5):
497
  last_sequence = words[-n:]
498
  repeat_count = 0
499
  idx = len(words) - n
@@ -501,9 +501,10 @@ class ASRPipeline(transformers.AutomaticSpeechRecognitionPipeline):
501
  repeat_count += 1
502
  idx -= n
503
 
504
- # If more than 2 exact repetitions at the end, truncate
505
  if repeat_count > 2:
506
- text = " ".join(words[: idx + n])
 
507
  break
508
 
509
  # 3. STRIP WHITESPACE
 
489
  text = text.lower()
490
 
491
  # 2. REMOVE REPETITIVE LOOPS
492
+ # If the model repeats the same phrase more than twice, remove all repetitions.
493
  words = text.split()
494
  if len(words) > 10:
495
+ # Check for repeating n-grams (1 to 5 words long)
496
+ for n in range(1, 6):
497
  last_sequence = words[-n:]
498
  repeat_count = 0
499
  idx = len(words) - n
 
501
  repeat_count += 1
502
  idx -= n
503
 
504
+ # If more than 2 exact repetitions at the end, remove all of them
505
  if repeat_count > 2:
506
+ words = words[:idx]
507
+ text = " ".join(words)
508
  break
509
 
510
  # 3. STRIP WHITESPACE
requirements.txt CHANGED
@@ -2,5 +2,4 @@
2
  # This file is pushed to HuggingFace for model repository
3
 
4
  # Transformers - main library for model loading and inference
5
- transformers>=4.57.0
6
- truecase
 
2
  # This file is pushed to HuggingFace for model repository
3
 
4
  # Transformers - main library for model loading and inference
5
+ transformers>=4.57.0