Merge pull request #4 from shahules786/dev-hawk
fix write output feature
This commit is contained in:
commit
9648a3fc0f
|
|
@ -84,10 +84,15 @@ class Inference:
|
||||||
|
|
||||||
if isinstance(filename,str):
|
if isinstance(filename,str):
|
||||||
filename = Path(filename)
|
filename = Path(filename)
|
||||||
|
|
||||||
|
parent, name = filename.parent, "cleaned_"+filename.name
|
||||||
|
filename = parent/Path(name)
|
||||||
if filename.is_file():
|
if filename.is_file():
|
||||||
raise FileExistsError(f"file {filename} already exists")
|
raise FileExistsError(f"file {filename} already exists")
|
||||||
else:
|
else:
|
||||||
wavfile.write(filename,rate=sr,data=waveform.detach().cpu())
|
if isinstance(waveform,torch.Tensor):
|
||||||
|
waveform = waveform.detach().cpu().squeeze().numpy()
|
||||||
|
wavfile.write(filename,rate=sr,data=waveform)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def prepare_output(waveform:torch.Tensor, model_sampling_rate:int,
|
def prepare_output(waveform:torch.Tensor, model_sampling_rate:int,
|
||||||
|
|
|
||||||
|
|
@ -249,7 +249,7 @@ class Model(pl.LightningModule):
|
||||||
else:
|
else:
|
||||||
waveform = Inference.prepare_output(waveform, model_sampling_rate,
|
waveform = Inference.prepare_output(waveform, model_sampling_rate,
|
||||||
audio, sampling_rate)
|
audio, sampling_rate)
|
||||||
return waveform
|
return waveform
|
||||||
@property
|
@property
|
||||||
def valid_monitor(self):
|
def valid_monitor(self):
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue