Audacity Spectrum Generation and Python

Hi Everybody \m/

First of, I want to say thank you for all the effort you have put into creating Audacity. I learned a great deal, in a very short amount of time with the help of all your efforts.

This year, I was working on a DSP project that required me to write a program in Python to plot the spectrum of recordings obtained using Audacity.

I basically used Audacity to record sound with a normal microphone → laptop setup. Then my Python program would read it, and use existing libraries (such as to generate a spectrum and look at different frequency bands.

In the end, everything worked out, but I could never get the same spectrum plot as Audacity… I am unsure of whether my analysis was faulty, or my windowing, or if Audacity does some smoothing that I could not get behind. I was wondering if it is possible to pipe the spectrum data from Audacity to Python?

If not, can someone point me in a direction where I can figure out what I did wrong?

I am unsure of what I should provide here to be helped… but I will be more than willing to supply any needed info.


Are you referring to “Plot Sectrum” (
If so, you can export the data as a text file (see link above for details)

Yes, I am referring to “Plot Spectrum”…

But instead of having to export the data, since that has to be done manually as far as I know, I want to automate the process :slight_smile:

record → analyze recording → plot spectrum (generate spectrum data) → python for analysis

Audacity does not have that feature built in, but some options are:

  • Use AutoKey, Sikuli or similar to automate Audacity via its GUI.

  • Build Audacity from the sourcecode and enable “mod-script-pipe” (Some of the documentation may be out of date as I don’t think anyone has worked on this “experimental” feature for quite a while:

  • Perform the FFT analysis directly in Python.

Thanks for the advice.

I will explore the “mod-script-pipe” and AutoKey avenues and report back.

Regarding the FFT in Python… this is what I did do, but my FFT analyses does not output the same graphs (guessing its either my smoothing or windowing methods that are faulty) as Audacity and subsequently I do not get the correct peak values. That is why I thought that maybe I can somehow access (or pipe) the data that Audacity generates :slight_smile:

Are you comparing the (text) data, or just the (graphic) graph?
The text data from Audacity is “scientifically” accurate, but how the graph is drawn is in part a matter of interpretation. There are many ways to interpolate / extrapolate, and the methods used by Audacity are just one choice. Different methods can look significantly different.

well, I saw that if I take the text from the exported file, and plot it in Excel (for instance) then I get the same graph as Audacity…

So I figured I needed this data, plot the graph in Python, and then analyze the graph itself for max, min, turning points, etc…

The whole point of all of this is automation in the end.

I’ve been trying to remember the name of the automation tool I used a while back (to automate a job in Audacity) - just remembered :slight_smile:
Actionaz (
Ubuntu and Debian both have it in their repositories.


Will give it a try as soon as I can, and let you know :slight_smile:

Thank you for all the advice.