forked from yondonfu/comfystream
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: combine audio and video streams
- Loading branch information
1 parent
49deb2f
commit 415c387
Showing
12 changed files
with
260 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,36 @@ | ||
import numpy as np | ||
|
||
from comfystream import tensor_cache | ||
|
||
class LoadAudioTensor: | ||
CATEGORY = "audio_utils" | ||
RETURN_TYPES = ("AUDIO",) | ||
FUNCTION = "execute" | ||
|
||
def __init__(self): | ||
self.audio_buffer = np.array([]) | ||
|
||
@classmethod | ||
def INPUT_TYPES(s): | ||
return {} | ||
return { | ||
"required": { | ||
"buffer_size": ("FLOAT", {"default": 500.0}) | ||
} | ||
} | ||
|
||
@classmethod | ||
def IS_CHANGED(): | ||
return float("nan") | ||
|
||
def execute(self): | ||
audio = tensor_cache.audio_inputs.pop() | ||
return (audio,) | ||
def execute(self, buffer_size): | ||
audio = tensor_cache.audio_inputs.get(block=True) | ||
self.audio_buffer = np.concatenate((self.audio_buffer, audio)) | ||
|
||
buffer_size_samples = int(buffer_size * 48) | ||
|
||
if self.audio_buffer.size >= buffer_size_samples: | ||
buffered_audio = self.audio_buffer[:buffer_size_samples] | ||
self.audio_buffer = self.audio_buffer[buffer_size_samples:] | ||
return (buffered_audio,) | ||
else: | ||
return (None,) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.