Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small improvements #39

Merged
merged 4 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions io_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,24 @@ def validate_data_dirs() -> bool: # TODO: perhaps add model dir
return False

# make sure the input and output dirs are there
try:
os.makedirs(i_dir, 0o755)
logger.info("created input dir: {}".format(i_dir))
except FileExistsError as e:
logger.info(e)
input_dir_created = create_directory(i_dir)
output_dir_created = create_directory(o_dir)

try:
os.makedirs(o_dir, 0o755)
logger.info("created output dir: {}".format(o_dir))
except FileExistsError as e:
logger.info(e)
return input_dir_created and output_dir_created


return True
def create_directory(path: Path) -> bool:
"""Create a directory if it doesn't exist."""
if path.exists():
logger.info(f"Directory already exists: {path}")
return True
try:
os.makedirs(path, mode=0o755)
logger.info(f"Created directory: {path}")
return True
except Exception as e:
logger.error(f"Failed to create directory {path}: {e}")
return False


# for each OutputType a subdir is created inside the base output dir
Expand Down
5 changes: 1 addition & 4 deletions whisper.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ def run_whisper(
"Failed to apply model (WHISPER_ASR_SETTINGS.MODEL not configured correctly)",
)

if (
cfg.WHISPER_ASR_SETTINGS.DEVICE != "cuda"
or cfg.WHISPER_ASR_SETTINGS.DEVICE != "cpu"
):
if cfg.WHISPER_ASR_SETTINGS.DEVICE not in ["cuda", "cpu"]:
return WhisperASROutput(
500,
"Failed to apply model (WHISPER_ASR_SETTINGS.DEVICE not configured correctly)",
Expand Down
Loading