From c139902ba60104e744411bc7a520702989bb9ecd Mon Sep 17 00:00:00 2001 From: CrescentonC Date: Fri, 10 Apr 2020 01:53:22 +0800 Subject: [PATCH] should fix the problem when there are spaces in the file path --- pysndfx/dsp.py | 4 ++-- pysndfx/sndfiles.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pysndfx/dsp.py b/pysndfx/dsp.py index 4968acd..dca8f01 100644 --- a/pysndfx/dsp.py +++ b/pysndfx/dsp.py @@ -3,7 +3,7 @@ import shlex from io import BufferedReader, BufferedWriter from subprocess import PIPE, Popen - +import platform import numpy as np from .sndfiles import ( @@ -523,7 +523,7 @@ def __call__( infile.cmd_prefix if infile is not None else '-d', outfile.cmd_suffix if outfile is not None else '-d', ] + list(map(str, self.command))), - posix=False, + posix=(True if (platform.system() == 'Windows') else False), ) logger.debug("Running command : %s" % cmd) diff --git a/pysndfx/sndfiles.py b/pysndfx/sndfiles.py index b0b25f1..e87c1c7 100644 --- a/pysndfx/sndfiles.py +++ b/pysndfx/sndfiles.py @@ -2,7 +2,7 @@ import shlex import wave from subprocess import PIPE, Popen - +import platform import numpy as np ENCODINGS_MAPPING = { @@ -28,7 +28,7 @@ def __init__(self, filepath): super(FilePathInput, self).__init__() info_cmd = 'sox --i -c ' + filepath logger.debug("Running info command : %s" % info_cmd) - stdout, stderr = Popen(shlex.split(info_cmd, posix=False), stdout=PIPE, stderr=PIPE).communicate() + stdout, stderr = Popen(shlex.split(info_cmd, posix=(True if (platform.system() == 'Windows') else False)), stdout=PIPE, stderr=PIPE).communicate() self.channels = int(stdout) self.cmd_prefix = filepath