Skip to content

Commit

Permalink
Refactor of language detection functions (#1146)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
MahmoudAshraf97 authored Nov 16, 2024
1 parent 53bbe54 commit a6f8fba
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 337 deletions.
11 changes: 0 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,6 @@ segments, _ = model.transcribe("audio.mp3")
segments = list(segments) # The transcription will actually run here.
```

### Multi-Segment Language Detection

To directly use the model for improved language detection, the following code snippet can be used:

```python
from faster_whisper import WhisperModel

model = WhisperModel("turbo", device="cuda", compute_type="float16")
language_info = model.detect_language_multi_segment("audio.mp3")
```

### Batched Transcription
The following code snippet illustrates how to run batched transcription on an example audio file. `BatchedInferencePipeline.transcribe` is a drop-in replacement for `WhisperModel.transcribe`

Expand Down
Loading

0 comments on commit a6f8fba

Please sign in to comment.