Skip to content

Commit

Permalink
parametrize sample rate of file conversion methods
Browse files Browse the repository at this point in the history
  • Loading branch information
alvesfelipe committed Mar 5, 2024
1 parent c387675 commit 8233648
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 224 deletions.
9 changes: 5 additions & 4 deletions maestro_worker_python/convert_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class FileToConvert:
file_format: str
output_file_path: str = None
max_duration: int = 1200
sr: int = 44100


def convert_files(convert_files: List[FileToConvert]):
Expand Down Expand Up @@ -89,7 +90,7 @@ def convert_files_manager(*convert_files: FileToConvert) -> None | str | list[st
obj.close()


def _convert_to_wav(input_file_path, output_file_path, max_duration):
def _convert_to_wav(input_file_path, output_file_path, max_duration, sr=44100):
_run_subprocess(
[
"ffmpeg",
Expand All @@ -102,13 +103,13 @@ def _convert_to_wav(input_file_path, output_file_path, max_duration):
"-i",
str(input_file_path),
"-ar",
"44100",
str(sr),
str(output_file_path),
]
)


def _convert_to_m4a(input_file_path, output_file_path, max_duration):
def _convert_to_m4a(input_file_path, output_file_path, max_duration, sr=44100):
_run_subprocess(
[
"ffmpeg",
Expand All @@ -125,7 +126,7 @@ def _convert_to_m4a(input_file_path, output_file_path, max_duration):
"-b:a",
"192k",
"-ar",
"44100",
str(sr),
"-movflags",
"+faststart",
str(output_file_path),
Expand Down
Loading

0 comments on commit 8233648

Please sign in to comment.