CorentinJ/Real-Time-Voice-Cloning · error · ValueError
Unsupported wave file format
Error message
Unsupported wave file format
What it means
First of the two 'Unsupported wave file format' ValueErrors in utils/logmmse.py, raised by to_float() when the input array's dtype is none of float64/float32/uint8/int16/int32. to_float normalizes PCM samples to float64 for log-MMSE denoising; any other dtype (int8, int24 stored wider, float16, complex) falls through all branches and is rejected. The accepted set mirrors the dtypes libsoundfile/scipy wave readers commonly produce.
Source
Thrown at utils/logmmse.py:232
#
# vad[k:k + len2] = vad_decision >= eta
#
# vad = np.pad(vad, (0, len(wav) - len(vad)), mode="constant")
# return vad
def to_float(_input):
if _input.dtype == np.float64:
return _input, _input.dtype
elif _input.dtype == np.float32:
return _input.astype(np.float64), _input.dtype
elif _input.dtype == np.uint8:
return (_input - 128) / 128., _input.dtype
elif _input.dtype == np.int16:
return _input / 32768., _input.dtype
elif _input.dtype == np.int32:
return _input / 2147483648., _input.dtype
raise ValueError('Unsupported wave file format')
def from_float(_input, dtype):
if dtype == np.float64:
return _input, np.float64
elif dtype == np.float32:
return _input.astype(np.float32)
elif dtype == np.uint8:
return ((_input * 128) + 128).astype(np.uint8)
elif dtype == np.int16:
return (_input * 32768).astype(np.int16)
elif dtype == np.int32:
print(_input)
return (_input * 2147483648).astype(np.int32)
raise ValueError('Unsupported wave file format')
View on GitHub (pinned to 890f3a0318)
Solutions
- Convert before calling: wav.astype(np.float32) for floats, or np.int16 / np.int32 for PCM — to_float accepts those.
- Load with a standard reader that returns int16/float32, e.g. librosa.load(..., sr=None) or soundfile.read(..., dtype='float32').
- If you own the data, re-encode the source audio to 16-bit PCM wav.
Example fix
# before wav, sr = load_some_reader(file) # dtype == np.int8 logmmse(wav, sr) # ValueError: Unsupported wave file format # after wav = wav.astype(np.float32) / 32768.0 if wav.dtype == np.int16 else wav.astype(np.float32) logmmse(wav, sr)
Defensive patterns
Strategy: type-guard
Validate before calling
import numpy as np
SUPPORTED = (np.float64, np.float32, np.uint8, np.int16, np.int32)
def dtype_supported(arr: np.ndarray) -> bool:
return arr.dtype.type in SUPPORTED Type guard
import numpy as np
def is_supported_pcm_dtype(a) -> bool:
return isinstance(a, np.ndarray) and a.dtype.type in (np.float64, np.float32, np.uint8, np.int16, np.int32) Try / catch
try:
denoised = logmmse(wav, sr)
except ValueError as e:
if "Unsupported wave file format" in str(e):
wav = wav.astype(np.int16 if wav.dtype.kind == 'i' else np.float32)
denoised = logmmse(wav, sr)
else:
raise Prevention
- Always load audio with a reader returning int16 or float32 (librosa, soundfile defaults).
- Validate dtype at your pipeline's trust boundary, before denoising.
- Standardize on 16-bit PCM wav for user-supplied recordings.
When it happens
Trigger: Calling logmmse/logmmse_from_file (utils/logmmse.py) with wav data loaded by a reader that yields an unsupported dtype — e.g. soundfile with dtype='float16' (not typical but possible), manually constructed int8 arrays, or a 24-bit PCM file read as raw bytes and reshaped.
Common situations: User-supplied recordings in exotic formats fed to the toolbox's noise reduction; preprocessing pipelines that pass pre-normalized or non-standard arrays; scipy.io.wavfile.read on 24-bit wavs (rare, returns int32 but some forks differ); arrays coming from another library's float16 pipeline.
Related errors
AI-assisted analysis of CorentinJ/Real-Time-Voice-Cloning@890f3a0318 (2026-08-15).
Data as JSON: /api/errors/d7fe5d135d5139ad.
Report an issue: GitHub.