Chop a WAV into segments triggered by PowerShell

Hello out there!

For every incoming call on a dedicated landline number answering machine my router sends an e-mail to my MS Outlook. Detecting a registered caller ID Outlook takes a VBA script to forward the attached WAV-file to a local folder. It shows up with a modified filename in a pattern like [YYYY-MM-DD]-[HH-MM]-[Caller ID].wav. Now PowerShell triggers audacity to do its job.

The registered caller is sending DTMF codes to be converted in TXT-data and published on a webserver. The conversion and the publishing to TXT is handled by VBA in MS Excel 2019 (and works already).

Audacity’s job is to chop the incoming call into the contained 1 to 15 pulses, do a plot spectrum export to files named as above plus -[Segment-ID] for example “2021-04-30-Bon Jovi-1…15”

The execution of following procedure shall be triggered by a Command Line / PowerShell script:
1.) open a WAV file
Cut all unneeded frequencies:

  • high pass filter 650 Hz and above
  • low pass filter 1500 Hz and below ’ frequencies from 650 to 1500 Hz must remain
  • noise gate threshold -65 dB ’ only louder segments should be processed
    2.) find all pulses greater than 1,5 seconds
  • chop into selections
  • plot a spectrum (Spectrum / Blackman-Harris) of the selection / segment and export to [path/]2021-04-30-Bon Jovi-1…15.txt
    3.) close Audacity without saving

Now it’s VBA’s job to continue.

My problem is that I’ve got no idea how to implement this procedure in Audacity. I found some information about macros and Nyquist but that’s all far away of my knowledge.

If we -you and me- can make it run, I’ll publish here a free DTMF decoder without any Linux help. Windows can do too …

THX a lot 'n more! for any help


You can probably do this using “named pipes” (see: Windows PowerShell and Named Pipes | Keith Hill's Blog)

Most of the documentation for controlling Audacity through named pipes use Python as the programming language, but the commands are the same for any language. The prerequisite is that the language being used must support named pipes.

See here for an introduction to scripting Audacity through named pipes: Scripting - Audacity Manual

See here for the list of available commands: Scripting Reference - Audacity Manual

Because the commands used are the same for scripting and for Macros, you can test the commands by creating a macro.
(See: Macros - Audacity Manual)

Unfortunately there is currently no way to export the spectral data using scripting commands.
One possible workaround might be to open “Plot Spectrum” with the scripting command “PlotSpectrum:”, and then emulate keystrokes to perform the export. I don’t know if PowerShell can do that. There are a number of libraries available for Python to emulate keystrokes, but the ones that I’ve seen are platform dependent.

Hi Steve,

thx a lot for this detailed information. I’m sure it will help me to do the next steps. If it’s not PowerShell it’s VBA to emulate keystrokes, so I guess the described difficulties can be solved at the end.

Thank you so much!!


Hey Henning,
did you find a solution for Powershell? I was wondering how to start and export recordings :frowning: