fix: FlashSR device handling and remove unused tmp_out
Use device="auto" for audiosr.build_model — safer than passing a device string that may not be accepted in all audiosr versions. Remove unused tmp_out temp file that was created but never written to. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -138,9 +138,7 @@ class SelvaFlashSR:
|
|||||||
|
|
||||||
# AudioSR works on files — write to temp, process, read back
|
# AudioSR works on files — write to temp, process, read back
|
||||||
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as f:
|
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as f:
|
||||||
tmp_in = Path(f.name)
|
tmp_in = Path(f.name)
|
||||||
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as f:
|
|
||||||
tmp_out = Path(f.name)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
wav_np = wav.float().numpy() # [C, T]
|
wav_np = wav.float().numpy() # [C, T]
|
||||||
@@ -150,8 +148,7 @@ class SelvaFlashSR:
|
|||||||
wav_np = wav_np.T # [T, C]
|
wav_np = wav_np.T # [T, C]
|
||||||
sf.write(str(tmp_in), wav_np, sr)
|
sf.write(str(tmp_in), wav_np, sr)
|
||||||
|
|
||||||
device = str(comfy.model_management.get_torch_device())
|
model = audiosr.build_model(model_name="basic", device="auto")
|
||||||
model = audiosr.build_model(model_name="basic", device=device)
|
|
||||||
result = audiosr.super_resolution(
|
result = audiosr.super_resolution(
|
||||||
model,
|
model,
|
||||||
str(tmp_in),
|
str(tmp_in),
|
||||||
@@ -170,7 +167,6 @@ class SelvaFlashSR:
|
|||||||
|
|
||||||
finally:
|
finally:
|
||||||
tmp_in.unlink(missing_ok=True)
|
tmp_in.unlink(missing_ok=True)
|
||||||
tmp_out.unlink(missing_ok=True)
|
|
||||||
|
|
||||||
print(f"[FlashSR] Done guidance={guidance_scale} steps={ddim_steps}", flush=True)
|
print(f"[FlashSR] Done guidance={guidance_scale} steps={ddim_steps}", flush=True)
|
||||||
return ({"waveform": wav_out, "sample_rate": out_sr},)
|
return ({"waveform": wav_out, "sample_rate": out_sr},)
|
||||||
|
|||||||
Reference in New Issue
Block a user