Skip to content

Commit

Permalink
Merge branch 'main' of github.com:abdeladim-s/subsai
Browse files Browse the repository at this point in the history
  • Loading branch information
abdeladim-s committed May 3, 2023
2 parents f2bac63 + 8f236c5 commit b23add3
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,5 @@ dmypy.json

.idea
_docs
assets
assets
.vscode
2 changes: 1 addition & 1 deletion src/subsai/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def main():
"string)")
parser.add_argument('-f', '--format', '--subtitles-format', default='srt',
help=f"Output subtitles format, available "
f"formats {available_subs_formats()}")
f"formats {available_subs_formats(include_extensions=False)}")
parser.add_argument('-df', '--destination-folder', default=None,
help='The directory where the subtitles will be stored, default to the same folder where '
'the media file(s) is stored.')
Expand Down
4 changes: 1 addition & 3 deletions src/subsai/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,9 @@ def available_translation_languages(model: Union[str, TranslationModel]) -> list
:return: list of available languages
"""
if type(model) == str:
translation_model = Tools.create_translation_model(model)
langs = translation_model.available_languages()
langs = Tools.create_translation_model(model).available_languages()
else:
langs = model.available_languages()
del translation_model
return langs

@staticmethod
Expand Down
19 changes: 19 additions & 0 deletions src/subsai/models/faster_whisper_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,25 @@ class FasterWhisperModel(AbstractModel):
'options': None,
'default': "\"'.。,,!!??::”)]}、"
},
'vad_filter': {
'type': bool,
'description': 'If True, use the integrated Silero VAD model to filter out parts of the audio without speech.',
'options': None,
'default': False
},
'vad_parameters': {
'type': dict,
'description': 'Parameters for splitting long audios into speech chunks using silero VAD.',
'options': None,
'default': {
'threshold': 0.5,
'min_speech_duration_ms': 250,
'max_speech_duration_s': float('inf'),
'min_silence_duration_ms': 2000,
'window_size_samples': 1024,
'speech_pad_ms': 400
}
},
}

def __init__(self, model_config):
Expand Down
13 changes: 11 additions & 2 deletions src/subsai/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,20 @@ def available_translation_models() -> list:
return models


def available_subs_formats():
def available_subs_formats(include_extensions=True):
"""
Returns available subtitle formats
from :attr:`pysubs2.FILE_EXTENSION_TO_FORMAT_IDENTIFIER`
:param include_extensions: include the dot separator in file extensions
:return: list of subtitle formats
"""
return list(FILE_EXTENSION_TO_FORMAT_IDENTIFIER.keys())

extensions = list(FILE_EXTENSION_TO_FORMAT_IDENTIFIER.keys())

if include_extensions:
return extensions
else:
# remove the '.' separator from extension names
return [ext.split('.')[1] for ext in extensions]

0 comments on commit b23add3

Please sign in to comment.