fixed permission issue in windows

This commit is contained in:
Abubakar Abid 2021-01-23 15:54:28 -06:00
parent 9847fb087b
commit 5bf6486198
3 changed files with 4 additions and 4 deletions

View File

@ -645,7 +645,7 @@ class Image(InputComponent):
elif self.type == "numpy":
return np.array(im)
elif self.type == "file":
file_obj = tempfile.NamedTemporaryFile(suffix=("."+fmt.lower() if fmt is not None else ".png"))
file_obj = tempfile.NamedTemporaryFile(delete=False, suffix=("."+fmt.lower() if fmt is not None else ".png"))
im.save(file_obj.name)
return file_obj
else:
@ -789,7 +789,7 @@ class Audio(InputComponent):
leave_one_out_data = np.copy(data)
start, stop = boundaries[index], boundaries[index + 1]
leave_one_out_data[start:stop] = 0
file = tempfile.NamedTemporaryFile()
file = tempfile.NamedTemporaryFile(delete=False)
scipy.io.wavfile.write(file, sample_rate, leave_one_out_data)
out_data = processing_utils.encode_file_to_base64(file.name, type="audio", ext="wav")
leave_one_out_sets.append(out_data)

View File

@ -286,7 +286,7 @@ class Audio(OutputComponent):
def postprocess(self, y):
if self.type in ["numpy", "file", "auto"]:
if self.type == "numpy" or (self.type == "auto" and isinstance(y, tuple)):
file = tempfile.NamedTemporaryFile()
file = tempfile.NamedTemporaryFile(delete=False)
scipy.io.wavfile.write(file, y[0], y[1])
y = file.name
return processing_utils.encode_file_to_base64(y, type="audio", ext="wav")

View File

@ -73,7 +73,7 @@ def decode_base64_to_binary(encoding):
def decode_base64_to_file(encoding):
file_obj = tempfile.NamedTemporaryFile()
file_obj = tempfile.NamedTemporaryFile(delete=False)
file_obj.write(decode_base64_to_binary(encoding))
file_obj.flush()
return file_obj