Skip to content

Commit 8233648

Browse files
committed
parametrize sample rate of file conversion methods
1 parent c387675 commit 8233648

File tree

3 files changed

+153
-224
lines changed

3 files changed

+153
-224
lines changed

maestro_worker_python/convert_files.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class FileToConvert:
2424
file_format: str
2525
output_file_path: str = None
2626
max_duration: int = 1200
27+
sr: int = 44100
2728

2829

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

9192

92-
def _convert_to_wav(input_file_path, output_file_path, max_duration):
93+
def _convert_to_wav(input_file_path, output_file_path, max_duration, sr=44100):
9394
_run_subprocess(
9495
[
9596
"ffmpeg",
@@ -102,13 +103,13 @@ def _convert_to_wav(input_file_path, output_file_path, max_duration):
102103
"-i",
103104
str(input_file_path),
104105
"-ar",
105-
"44100",
106+
str(sr),
106107
str(output_file_path),
107108
]
108109
)
109110

110111

111-
def _convert_to_m4a(input_file_path, output_file_path, max_duration):
112+
def _convert_to_m4a(input_file_path, output_file_path, max_duration, sr=44100):
112113
_run_subprocess(
113114
[
114115
"ffmpeg",
@@ -125,7 +126,7 @@ def _convert_to_m4a(input_file_path, output_file_path, max_duration):
125126
"-b:a",
126127
"192k",
127128
"-ar",
128-
"44100",
129+
str(sr),
129130
"-movflags",
130131
"+faststart",
131132
str(output_file_path),

0 commit comments

Comments
 (0)