microsoft/VibeVoice · error · ValueError

Audio should be 1D or 2D, got shape: {audio.shape}

Error message

Audio should be 1D or 2D, got shape: {audio.shape}

What it means

The mono-conversion helper only handles 1D (time,) and 2D arrays. Any array with 3 or more dimensions — (batch, channels, time), (batch, time, 1), etc. — hits the outer else and is rejected. Batch/channel handling is the caller's job (__call__ accepts a list of arrays for batching), so a 3D array means the batching convention was violated.

Source

Thrown at vibevoice/processor/vibevoice_tokenizer_processor.py:91

            np.ndarray: Mono audio array
        """
        if len(audio.shape) == 1:
            return audio
        elif len(audio.shape) == 2:
            if audio.shape[0] == 2:  # (2, time)
                return np.mean(audio, axis=0)
            elif audio.shape[1] == 2:  # (time, 2)
                return np.mean(audio, axis=1)
            else:
                # If one dimension is 1, squeeze it
                if audio.shape[0] == 1:
                    return audio.squeeze(0)
                elif audio.shape[1] == 1:
                    return audio.squeeze(1)
                else:
                    raise ValueError(f"Unexpected audio shape: {audio.shape}")
        else:
            raise ValueError(f"Audio should be 1D or 2D, got shape: {audio.shape}")
    
    def _process_single_audio(self, audio: Union[np.ndarray, List[float]]) -> np.ndarray:
        """
        Process a single audio array.
        
        Args:
            audio: Single audio input
            
        Returns:
            np.ndarray: Processed audio
        """
        # Convert to numpy array
        if not isinstance(audio, np.ndarray):
            audio = np.array(audio, dtype=np.float32)
        else:
            audio = audio.astype(np.float32)
        
        # Ensure mono

View on GitHub (pinned to 94da20d98b)

Solutions

  1. Unbatch before calling: pass [a[0] for a in arr] or arr[:, 0, :] reduced per-sample as a list of 1D arrays.
  2. Squeeze channel dims per sample: audio = audio.reshape(audio.shape[0], -1) only if channels are genuinely 1.
  3. Keep individual samples 1D (time,) and let the processor's list handling do batching.

Example fix

# before
enc = processor(audio=batched_np)  # shape (4, 1, 24000) -> ValueError

# after
enc = processor(audio=[s.squeeze() for s in batched_np])
Defensive patterns

Strategy: validation

Validate before calling

import numpy as np
def as_audio_list(a):
    a = np.asarray(a)
    if a.ndim == 1:
        return [a]
    if a.ndim in (2, 3) and a.shape[0] > 1:  # treat leading dim as batch
        return [np.asarray(s).reshape(-1) for s in a]
    return [a.reshape(-1)]
enc = processor(audio=as_audio_list(raw))

Type guard

def is_1d_or_2d_audio(a) -> bool:
    import numpy as np
    return np.asarray(a).ndim <= 2

Try / catch

try:
    enc = processor(audio=raw)
except ValueError as e:
    if '1D or 2D' in str(e):
        enc = processor(audio=[np.asarray(s).squeeze() for s in raw])  # unbatch
    else:
        raise

Prevention

When it happens

Trigger: Passing a batched tensor-style array of shape (B, T) squeezed from (B, 1, T), or (B, C, T) multi-channel batches, directly as a single audio input.

Common situations: Converting a torch tensor of shape (B, 1, T) with .numpy() and feeding it unchanged; datasets that yield (clip, channel, time) containers; voice-cloning code that stacks prompt + target audio into one ndarray.

Related errors


AI-assisted analysis of microsoft/VibeVoice@94da20d98b (2026-08-15). Data as JSON: /api/errors/dcc534ce74bc9f1d. Report an issue: GitHub.