Skip to content

Commit

Permalink
Convert float arguments to int on Python side
Browse files Browse the repository at this point in the history
  • Loading branch information
Bentroen committed Apr 5, 2022
1 parent 4029b4d commit 2f5dad9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions datafiles/Data/Python/audio_export.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import subprocess
from typing import Dict, Sequence, Union


def patch_arguments(function, **patched_kwargs):
Expand All @@ -9,13 +10,22 @@ def decorate_name(*args, **kwargs):
return decorate_name


def convert_to_int(kwargs: Dict[str, Union[float, int]], fields: Sequence[str]):
for field in fields:
kwargs[field] = int(kwargs[field])
return kwargs


def main(*args, **kwargs):

# Monkey-patch to avoid ffmpeg/ffprobe calls opening console window
subprocess.Popen = patch_arguments(
subprocess.Popen, creationflags=subprocess.CREATE_NO_WINDOW
)

# Convert float arguments to int
kwargs = convert_to_int(kwargs, ["sample_rate", "channels"])

import nbswave

nbswave.render_audio(*args, **kwargs)
Expand Down

0 comments on commit 2f5dad9

Please sign in to comment.