Skip to content

Commit

Permalink
Adding turbo models (#967)
Browse files Browse the repository at this point in the history
  • Loading branch information
raivisdejus authored Nov 1, 2024
1 parent 7650992 commit 807b43f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 24 deletions.
12 changes: 6 additions & 6 deletions buzz/model_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ def get_local_model_path(self) -> Optional[str]:
"large-v1": "7d99f41a10525d0206bddadd86760181fa920438b6b33237e3118ff6c83bb53d",
"large-v2": "9a423fe4d40c82774b6af34115b8b935f34152246eb19e80e376071d3f999487",
"large-v3": "64d182b440b98d5203c4f9bd541544d84c605196c4f7b845dfa11fb23594d1e2",
"large-v3-turbo": "1fc70f774d38eb169993ac391eea357ef47c88757ef72ee5943879b7e8e2bc69",
"custom": None,
}

Expand Down Expand Up @@ -383,19 +384,18 @@ def download_faster_whisper_model(
size = model.whisper_model_size.to_faster_whisper_model_size()
custom_repo_id = model.hugging_face_model_id

if size != WhisperModelSize.CUSTOM and size not in faster_whisper.utils._MODELS:
raise ValueError(
"Invalid model size '%s', expected one of: %s"
% (size, ", ".join(faster_whisper.utils._MODELS))
)

if size == WhisperModelSize.CUSTOM and custom_repo_id == "":
raise ValueError("Custom model id is not provided")

if size == WhisperModelSize.CUSTOM:
repo_id = custom_repo_id
elif size == WhisperModelSize.LARGEV3:
repo_id = "Systran/faster-whisper-large-v3"
# Maybe switch to 'mobiuslabsgmbh/faster-whisper-large-v3-turbo', seems to be used in
# faster-whisper code https://github.com/SYSTRAN/faster-whisper/blob/master/faster_whisper/utils.py#L29
# If so changes needed also in whisper_file_transcriber.py
elif size == WhisperModelSize.LARGEV3TURBO:
repo_id = "deepdml/faster-whisper-large-v3-turbo-ct2"
else:
repo_id = "guillaumekln/faster-whisper-%s" % size

Expand Down
2 changes: 2 additions & 0 deletions buzz/transcriber/whisper_file_transcriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ def transcribe_hugging_face(cls, task: FileTranscriptionTask) -> List[Segment]:
def transcribe_faster_whisper(cls, task: FileTranscriptionTask) -> List[Segment]:
if task.transcription_options.model.whisper_model_size == WhisperModelSize.CUSTOM:
model_size_or_path = task.transcription_options.model.hugging_face_model_id
elif task.transcription_options.model.whisper_model_size == WhisperModelSize.LARGEV3TURBO:
model_size_or_path = "deepdml/faster-whisper-large-v3-turbo-ct2"
else:
model_size_or_path = task.transcription_options.model.whisper_model_size.to_faster_whisper_model_size()

Expand Down
5 changes: 0 additions & 5 deletions buzz/widgets/preferences_dialog/models_preferences_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,6 @@ def reset(self):
model_size == WhisperModelSize.CUSTOM):
continue

# Skip turbo model for Faste Whisper and Whisper.cpp
if (self.model.model_type in {ModelType.FASTER_WHISPER, ModelType.WHISPER_CPP} and
model_size == WhisperModelSize.LARGEV3TURBO):
continue

model = TranscriptionModel(
model_type=self.model.model_type,
whisper_model_size=WhisperModelSize(model_size),
Expand Down
14 changes: 1 addition & 13 deletions buzz/widgets/transcriber/transcription_options_group_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(

self.whisper_model_size_combo_box = QComboBox(self)
self.whisper_model_size_combo_box.addItems(
[size.value.title() for size in WhisperModelSize if size not in {WhisperModelSize.CUSTOM, WhisperModelSize.LARGEV3TURBO}]
[size.value.title() for size in WhisperModelSize if size not in {WhisperModelSize.CUSTOM}]
)
self.whisper_model_size_combo_box.currentTextChanged.connect(
self.on_whisper_model_size_changed
Expand Down Expand Up @@ -142,24 +142,12 @@ def reset_visible_rows(self):
and whisper_model_size == WhisperModelSize.CUSTOM),
)

# Add turbo model size for whisper
if model_type == ModelType.WHISPER:
if self.whisper_model_size_combo_box.findText(WhisperModelSize.LARGEV3TURBO.value.title()) == -1:
self.whisper_model_size_combo_box.addItem(WhisperModelSize.LARGEV3TURBO.value.title())

# Remove custom model size for whisper
custom_model_index = (self.whisper_model_size_combo_box
.findText(WhisperModelSize.CUSTOM.value.title()))
if model_type == ModelType.WHISPER and custom_model_index != -1:
self.whisper_model_size_combo_box.removeItem(custom_model_index)

# Remove turbo model size for whisper_cpp and faster_whisper
turbo_model_index = (self.whisper_model_size_combo_box
.findText(WhisperModelSize.LARGEV3TURBO.value.title()))
if ((model_type == ModelType.WHISPER_CPP or model_type == ModelType.FASTER_WHISPER)
and turbo_model_index != -1):
self.whisper_model_size_combo_box.removeItem(turbo_model_index)

# Add custom model size for whisper_cpp
custom_model_index = (self.whisper_model_size_combo_box
.findText(WhisperModelSize.CUSTOM.value.title()))
Expand Down

0 comments on commit 807b43f

Please sign in to comment.