* Make collect_chunks() linear in the number of chunks
collect_chunks() grew its output with np.concatenate() inside the loop,
so every chunk copied all the audio merged so far. Collect the slices
instead and join each group once, when it's complete.
Fixes#1690
* Delete tests/test_vad.py
---------
Co-authored-by: Purfview <69023953+Purfview@users.noreply.github.com>
* change language_detection_threshold type to float
Cannot be an optional parameter
* remove test edit
* apply same to BatchedInferencePipeline
---------
Co-authored-by: extrange <nicholas_leong@nuhs.edu.sg>
Co-authored-by: Purfview <69023953+Purfview@users.noreply.github.com>
* Handle empty alignments in find_alignment
ctranslate2 returns an empty alignment for a window that has no frames
left after the encoder-stride halving (num_frames < 2, e.g. a ~10ms
final VAD chunk on audio where Whisper hallucinates past the clip end;
see OpenNMT/CTranslate2#2065). find_alignment then crashed with
IndexError at time_indices[jumps] because the boolean mask is padded to
length 1 while the indexed array is empty.
Return an empty word list for such segments instead: the segment simply
carries no word timestamps.
Fixes#1342 (together with the ctranslate2 fix, which replaces the
process-killing 0xC0000094 native crash with the empty alignment this
change handles).
* Comment edit
---------
Co-authored-by: Purfview <69023953+Purfview@users.noreply.github.com>
Added clarification on chunk_length usage after noticing some unexpected uses of this argument.
Some people even use it to shorten the text segments instead of post-processing the text. :)
* Adds new VAD parameters
Adds new VAD parameters:
min_silence_at_max_speech: Minimum silence duration in ms which is used to avoid abrupt cuts when max_speech_duration_s is reached.
use_max_poss_sil_at_max_speech: Whether to use the maximum possible silence at max_speech_duration_s or not. If not, the last silence is used.
* Style
* Update doc
* change min_speech_duration_ms (0 -> 250)
* Change min_speech_duration_ms to zero
Set minimum speech duration to zero for flexibility.
---------
Co-authored-by: Mahmoud Ashraf <hassouna97.ma@gmail.com>
* Remove "local_dir_use_symlinks" from download_model()
It's deprecated since huggingface_hub v0.23.0 and produce this warning:
> /opt/hostedtoolcache/Python/3.9.24/x64/lib/python3.9/site-packages/huggingface_hub/utils/_validators.py:202: UserWarning: The `local_dir_use_symlinks` argument is deprecated and ignored in `snapshot_download`. Downloading to a local directory does not use symlinks anymore.
* Bump huggingface_hub requirement to v0.23
* Fix: Prevent <|nocaptions|> tokens in BatchedInferencePipeline
- Add nocaptions component tokens [1771, 496, 9799] to suppress_tokens list
- Add segment filtering to remove any remaining <|nocaptions|> segments
- Resolves issue where BatchedInferencePipeline would generate malformed
special tokens during periods of silence or low-confidence transcription
- Includes comprehensive tests to verify the fix
The issue occurred because while bracket tokens ('<', '|', '>') were
already suppressed, the content tokens ('no', 'ca', 'ptions') were not,
leading to partial token generation that formed complete <|nocaptions|>
tags in the output.
Files changed:
- faster_whisper/transcribe.py: Core fix implementation
- test_nocaptions_comprehensive.py: Comprehensive test suite
- tests/test_nocaptions_fix.py: Unit tests
* removed
* Fix: Prevent <|nocaptions|> tokens in BatchedInferencePipeline
* Fix: Implement proper <|nocaptions|> token suppression using single token approach
* ci: trigger tests
* fix: remove trailing whitespace from blank lines
* Update faster_whisper/transcribe.py
Co-authored-by: Mahmoud Ashraf <hassouna97.ma@gmail.com>
* Update faster_whisper/tokenizer.py
Co-authored-by: Mahmoud Ashraf <hassouna97.ma@gmail.com>
* Update faster_whisper/tokenizer.py
Co-authored-by: Mahmoud Ashraf <hassouna97.ma@gmail.com>
* Rename no_speech to no_captions in tokenizer
* nocaptions has been renamed to nospeech
* break line
* line break
* Refactor no_speech method for improved readability by adjusting line breaks
---------
Co-authored-by: Mahmoud Ashraf <hassouna97.ma@gmail.com>
Was previously named faster-whisper-server. They've decided to change the name from faster-whisper-server to speaches, as the project has evolved to support more than just ASR.
* Added test for `multilingual` option with english-german audio
* removed `output_language` argument as it is redundant, you can get the same functionality with `task="translate"`
* use the correct `encoder_output` for language detection in sequential transcription
* enabled `multilingual` functionality for batched inference
* Supported new options for batched transcriptions:
* `language_detection_threshold`
* `language_detection_segments`
* Updated `WhisperModel.detect_language` function to include the improved language detection from #732 and added docstrings, it's now used inside `transcribe` function.
* Removed the following functions as they are no longer needed:
* `WhisperModel.detect_language_multi_segment` and its test
* `BatchedInferencePipeline.get_language_and_tokenizer`
* Added tests for empty audios