Skip to content

Commit 3365421

Browse files
authored
record audio node (comfyanonymous#8716)
* record audio node * sf
1 parent e211d08 commit 3365421

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

comfy_extras/nodes_audio.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,24 @@ def VALIDATE_INPUTS(s, audio):
346346
return "Invalid audio file: {}".format(audio)
347347
return True
348348

349+
class RecordAudio:
350+
@classmethod
351+
def INPUT_TYPES(s):
352+
return {"required": {"audio": ("AUDIO_RECORD", {})}}
353+
354+
CATEGORY = "audio"
355+
356+
RETURN_TYPES = ("AUDIO", )
357+
FUNCTION = "load"
358+
359+
def load(self, audio):
360+
audio_path = folder_paths.get_annotated_filepath(audio)
361+
362+
waveform, sample_rate = torchaudio.load(audio_path)
363+
audio = {"waveform": waveform.unsqueeze(0), "sample_rate": sample_rate}
364+
return (audio, )
365+
366+
349367
NODE_CLASS_MAPPINGS = {
350368
"EmptyLatentAudio": EmptyLatentAudio,
351369
"VAEEncodeAudio": VAEEncodeAudio,
@@ -356,6 +374,7 @@ def VALIDATE_INPUTS(s, audio):
356374
"LoadAudio": LoadAudio,
357375
"PreviewAudio": PreviewAudio,
358376
"ConditioningStableAudio": ConditioningStableAudio,
377+
"RecordAudio": RecordAudio,
359378
}
360379

361380
NODE_DISPLAY_NAME_MAPPINGS = {
@@ -367,4 +386,5 @@ def VALIDATE_INPUTS(s, audio):
367386
"SaveAudio": "Save Audio (FLAC)",
368387
"SaveAudioMP3": "Save Audio (MP3)",
369388
"SaveAudioOpus": "Save Audio (Opus)",
389+
"RecordAudio": "Record Audio",
370390
}

0 commit comments

Comments
 (0)