Merge pull request #20 from AustinMroz/main
Simplify audio_for_vhs output
This commit is contained in:
@@ -289,38 +289,6 @@ class TangoFluxVAEDecodeAndPlay:
|
||||
log.warning("OOM encountered. Falling back to tiled decoding.")
|
||||
return self.decode_tiled(vae, latents, tile_size)
|
||||
|
||||
def load_audio_for_vhs(self, file, sample_rate):
|
||||
try:
|
||||
from imageio_ffmpeg import get_ffmpeg_exe
|
||||
ffmpeg_path = get_ffmpeg_exe()
|
||||
except:
|
||||
pass
|
||||
|
||||
ffmpeg_path = shutil.which("ffmpeg")
|
||||
if not ffmpeg_path:
|
||||
if os.path.isfile("ffmpeg"):
|
||||
ffmpeg_path = os.path.abspath("ffmpeg")
|
||||
elif os.path.isfile("ffmpeg.exe"):
|
||||
ffmpeg_path = os.path.abspath("ffmpeg.exe")
|
||||
|
||||
if not ffmpeg_path:
|
||||
log.error("No valid ffmpeg found")
|
||||
return None
|
||||
|
||||
args = [ffmpeg_path, "-i", file]
|
||||
|
||||
try:
|
||||
res = subprocess.run(args + ["-f", "f32le", "-"],
|
||||
capture_output=True, check=True)
|
||||
audio = torch.frombuffer(bytearray(res.stdout), dtype=torch.float32)
|
||||
except subprocess.CalledProcessError:
|
||||
log.error("Couldn't export audio")
|
||||
return None
|
||||
|
||||
audio = audio.reshape((-1, 2)).transpose(0, 1).unsqueeze(0)
|
||||
|
||||
return {"waveform": audio, "sample_rate": sample_rate}
|
||||
|
||||
def play(
|
||||
self,
|
||||
vae,
|
||||
@@ -381,8 +349,7 @@ class TangoFluxVAEDecodeAndPlay:
|
||||
|
||||
pbar.update(1)
|
||||
|
||||
first_file = os.path.join(full_output_folder, audios[0]["filename"])
|
||||
audio_for_vhs = self.load_audio_for_vhs(first_file, 44100)
|
||||
audio_for_vhs = {"waveform": waves[:1], "sample_rate": 44100}
|
||||
|
||||
return {
|
||||
"ui": {"audios": audios},
|
||||
|
||||
Reference in New Issue
Block a user