Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ruokolt committed Feb 2, 2024
1 parent c3cd8b8 commit 1bf6457
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/speech2text.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@ def load_whisperx_model(
device = "cuda" if torch.cuda.is_available() else "cpu"

if name not in settings.available_whisper_models:
logger.warning(f"Specified model '{name}' not among available models: {settings.available_whisper_models}. Opting to use the default model '{settings.default_whisper_model}' instead")
logger.warning(
f"Specified model '{name}' not among available models: {settings.available_whisper_models}. Opting to use the default model '{settings.default_whisper_model}' instead"
)
name = settings.default_whisper_model

compute_type = "float16" if device == "cuda" else "int8"
Expand Down Expand Up @@ -267,6 +269,7 @@ def transcribe(
) -> TranscriptionResult:
batch_size = calculate_max_batch_size()
model = load_whisperx_model(model_name)

try:
segs, _ = model.transcribe(
file, batch_size=batch_size, language=language
Expand Down Expand Up @@ -335,7 +338,13 @@ def main():
# Check language if given
language = args.SPEECH2TEXT_LANGUAGE
if language and language.lower() in settings.supported_languages:
# Language is given in long form: convert to short form (two-letter abbreviation)
language = settings.supported_languages[language.lower()]
elif language and language not in settings.supported_languages.values():
logger.warning(
f"Given language '{language}' not found among supported languages: {' '.join([lang for lang in settings.supported_languages.keys()])}. Opting to detect language automatically."
)
language = None

with mp.Manager() as manager:
shared_dict = manager.dict()
Expand Down

0 comments on commit 1bf6457

Please sign in to comment.