WOLFRAM

Enable JavaScript to interact with content and submit forms on Wolfram websites. Learn how
Wolfram Language & System Documentation Center

InverseSpectrogram [data]

reconstructs the signal from the magnitude spectrogram data.

InverseSpectrogram [img]

reconstructs the signal, assuming that the image img is the magnitude spectrogram.

InverseSpectrogram [input,n]

assumes the spectrogram data was computed with partitions of length n.

InverseSpectrogram [input,n,d]

assumes partitions with offset d.

InverseSpectrogram [input,n,d,wfun]

assumes a smoothing window wfun was applied to each partition.

Details and Options
Details and Options Details and Options
Examples  
Basic Examples  
Scope  
Options  
MaxIterations  
Method  
Applications  
Properties & Relations  
Possible Issues  
See Also
Related Guides
History
Cite this Page

InverseSpectrogram [data]

reconstructs the signal from the magnitude spectrogram data.

InverseSpectrogram [img]

reconstructs the signal, assuming that the image img is the magnitude spectrogram.

InverseSpectrogram [input,n]

assumes the spectrogram data was computed with partitions of length n.

InverseSpectrogram [input,n,d]

assumes partitions with offset d.

InverseSpectrogram [input,n,d,wfun]

assumes a smoothing window wfun was applied to each partition.

Details and Options

  • InverseSpectrogram approximates an inverse of the magnitude spectrogram.
  • To compute the short-time Fourier transform of lists and audio signals, use ShortTimeFourier .
  • InverseSpectrogram assumes that real matrix input is a magnitude spectrogram without the redundant part. This means that the window size used was 2(size-1), where size is the second dimension of the input matrix.
  • The inverse spectrogram can be computed from the spectrogram if the offset d is smaller than half the size of the partition length n.
  • The following options can be given:
  • FourierParameters {1,-1} Fourier parameters to be used
    MaxIterations Automatic maximum number of iterations
    Method Automatic the method to use
  • Possible method settings include:
  • Automatic uses automatic method
    "GriffinLim" iteratively approximates the phase
    "SPSI" uses single-pass spectrogram inversion
    "Hybrid" uses the SPSI as the inital phase for GriffinLim
  • The "Hybrid" method is used by default.

Examples

open all close all

Basic Examples  (3)

Generate an audio signal, assuming a cellular automaton evolution to be the magnitude spectrum:

Wolfram Language code: data = CellularAutomaton[60, {{1}, 0}, 255]; ArrayPlot[data]
Wolfram Language code: Audio[InverseSpectrogram[data], SampleRate -> 8000]

Reconstruct a signal from a magnitude spectrum:

Wolfram Language code: InverseSpectrogram[{...}]
Wolfram Language code: Spectrogram[%]

Construct an Audio object from an Image :

Wolfram Language code: InverseSpectrogram[[image]]//Audio

Compute the spectrogram of the resulting signal:

Wolfram Language code: Spectrogram[%, PlotRange -> All, AspectRatio -> 1]

Scope  (3)

The partition size must match the value inferred from the input data:

Wolfram Language code: data = List[...];

The inferred partition size is 2×(size-1), where size is the second dimension of the input matrix:

Wolfram Language code: size = Dimensions[data][[2]]
Wolfram Language code: InverseSpectrogram[data, 2(size - 1)]//Spectrogram

By default, the partition offset is of the inferred partition size:

Wolfram Language code: data = List[...];
Wolfram Language code: InverseShortTimeFourier[data]//Spectrogram

Specify a different partition offset:

Wolfram Language code: InverseSpectrogram[data, Automatic, 40]//Spectrogram

Specify a smoothing window:

Wolfram Language code: data = List[...];
Wolfram Language code: InverseShortTimeFourier[data, Automatic, Automatic, DirichletWindow]//Spectrogram

Options  (2)

MaxIterations  (1)

Use the MaxIterations option to control the quality of the result and the speed of the operation:

Wolfram Language code: AbsoluteTiming[res = InverseSpectrogram[List[...], Method -> "GriffinLim", MaxIterations -> 1];][[1]] Spectrogram[res]
Wolfram Language code: AbsoluteTiming[res = InverseSpectrogram[List[...], Method -> "GriffinLim", MaxIterations -> 10000];][[1]] Spectrogram[res]

Method  (1)

The "Griffin-Lim" method uses an iterative algorithm to approximate the original signal:

Wolfram Language code: data = List[...];
Wolfram Language code: InverseSpectrogram[data, Method -> "GriffinLim"]//Spectrogram

The "SPSI" method approximates the signal in a non-iterative way, which is relatively fast:

Wolfram Language code: InverseSpectrogram[data, Method -> "SPSI"]//Spectrogram

The "Hybrid" method uses the result of the "SPSI" method as the starting guess for iterative method "Griffin-Lim", which may converge faster:

Wolfram Language code: InverseSpectrogram[data, Method -> "Hybrid"]//Spectrogram

Applications  (2)

Reconstruct an Audio object from its magnitude spectrum:

Wolfram Language code: sp = List[...]; MatrixPlot[Log[sp]]
Wolfram Language code: Audio[InverseSpectrogram[sp, 1024, 256, HannWindow], SampleRate -> 16000]

Construct an Audio object from image data:

Wolfram Language code: img = [image];

Convert the image to grayscale and rotate appropriately:

Wolfram Language code: data = ColorConvert[ImageRotate[img, -Pi / 2], "Grayscale"]//ImageData;

Reconstruct the signal with the assumption that the image was its spectrogram:

Wolfram Language code: InverseSpectrogram[img]//Audio

Compute the spectrogram of the resulting signal:

Wolfram Language code: Spectrogram[%, PlotRange -> All, AspectRatio -> 1]

Properties & Relations  (1)

Compute the spectrogram of a signal and its approximate inverse:

Wolfram Language code: data = Table[Cos[( i/4) + ((i/20))^2], {i, 2000}]; Spectrogram[data]

Compute the short-time Fourier transform:

Wolfram Language code: stft = SpectrogramArray[data];

Discard the redundant part and take the absolute value to get the magnitude spectrogram:

Wolfram Language code: spectrogram = Abs[stft[[All, 1 ;; Floor[Last[Dimensions[stft]] / 2 + 1]]]];

Use InverseSpectrogram to compute the approximated inverse of the spectrogram:

Wolfram Language code: InverseSpectrogram[spectrogram]//Spectrogram

Possible Issues  (1)

The partition size must match the value inferred for the input data:

Wolfram Language code: data = List[...]; Dimensions[data]

The inferred partition size is 2×(size-1), where size is the second dimension of the input matrix:

Wolfram Language code: InverseSpectrogram[data, 2(127 - 1)]//Head

Signal reconstruction cannot be done with other partition sizes:

Wolfram Language code: InverseSpectrogram[data, 80]//Head
Wolfram Research (2019), InverseSpectrogram, Wolfram Language function, https://reference.wolfram.com/language/ref/InverseSpectrogram.html.

Text

Wolfram Research (2019), InverseSpectrogram, Wolfram Language function, https://reference.wolfram.com/language/ref/InverseSpectrogram.html.

CMS

Wolfram Language. 2019. "InverseSpectrogram." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/InverseSpectrogram.html.

APA

Wolfram Language. (2019). InverseSpectrogram. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/InverseSpectrogram.html

BibTeX

@misc{reference.wolfram_2026_inversespectrogram, author="Wolfram Research", title="{InverseSpectrogram}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/InverseSpectrogram.html}", note=[Accessed: 14-August-2026]}

BibLaTeX

@online{reference.wolfram_2026_inversespectrogram, organization={Wolfram Research}, title={InverseSpectrogram}, year={2019}, url={https://reference.wolfram.com/language/ref/InverseSpectrogram.html}, note=[Accessed: 14-August-2026]}

Top [フレーム]

AltStyle によって変換されたページ (->オリジナル) /