[Nodes][Added] More audio information
mean, std and peak
This commit is contained in:
@@ -155,6 +155,9 @@ workflows, especially when dealing with multiple audio inputs or outputs.
|
||||
- `channels` (INT): Number of audio channels (1 mono, 2 stereo)
|
||||
- `num_samples` (INT): How many samples contains the audio. Duratio [s] = `num_samples` / `sample_rate`
|
||||
- `sample_rate` (INT): Sampling frequency, how many samples per second.
|
||||
- `mean` (TORCH_TENSOR): Mean value for each waveform in the batch.
|
||||
- `std` (TORCH_TENSOR): Standard deviation for each waveform in the batch.
|
||||
- `peak` (TORCH_TENSOR): Peak value (absolute) for each waveform in the batch.
|
||||
|
||||
### 8. Audio Cut
|
||||
- **Display Name:** `Audio Cut`
|
||||
|
||||
@@ -372,8 +372,8 @@ class AudioInfo:
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("AUDIO", "INT", "INT", "INT", "INT")
|
||||
RETURN_NAMES = ("audio_bypass", "batch_size", "channels", "num_samples", "sample_rate")
|
||||
RETURN_TYPES = ("AUDIO", "INT", "INT", "INT", "INT", "TORCH_TENSOR", "TORCH_TENSOR", "TORCH_TENSOR")
|
||||
RETURN_NAMES = ("audio_bypass", "batch_size", "channels", "num_samples", "sample_rate", "mean", "std", "peak")
|
||||
FUNCTION = "show_info"
|
||||
CATEGORY = BASE_CATEGORY + "/" + CONV_CATEGORY
|
||||
DESCRIPTION = "Shows information about the audio."
|
||||
@@ -383,7 +383,15 @@ class AudioInfo:
|
||||
def show_info(self, audio: dict):
|
||||
wav = audio['waveform'] # (B, C, T)
|
||||
sample_rate = audio['sample_rate']
|
||||
return audio, wav.shape[0], wav.shape[1], wav.shape[2], sample_rate
|
||||
|
||||
ref = wav.mean(1, keepdim=True)
|
||||
mean = ref.mean(dim=2, keepdim=True)
|
||||
std = ref.std(dim=2, keepdim=True)
|
||||
|
||||
max_val, _ = torch.max(torch.abs(wav), dim=2, keepdim=True)
|
||||
max_val, _ = torch.max(max_val, dim=1, keepdim=True) # (B, 1, 1)
|
||||
|
||||
return audio, wav.shape[0], wav.shape[1], wav.shape[2], sample_rate, mean.squeeze(), std.squeeze(), max_val.squeeze()
|
||||
|
||||
|
||||
class AudioForceChannels:
|
||||
|
||||
Reference in New Issue
Block a user