I am trying to make a Python (Anaconda, Spyder, Python 3.8) script that uses audacity noise reduction. Since I am not very skilled programmer i am not able to deduce the correct syntax from the commands list (https://alphamanual.audacityteam.org/man/Scripting_Reference).
Moreover, i have found that this particular function is currently not available for scripting.
I would therefore like to ask you for a little push (like minimal working example or something) in the right direction.
thanks for the tip, I have no experience with the macro tools, but I will try it. The situation will be as you write - predefined “silence” file and other file to apply it to.
The thing is, that I need to do some preparations in Python anyway, so I it would be very comfortable to create a full automat O:-)
One thing that you can do with Python that you can’t do with macros is to launch Audacity (for example, with Python’s “Popen” command), which can be useful in the case of Noise Reduction as it allows you to ensure that you are starting without a noise profile.
It looks like you have some experience with the Python-Audacity scripting. Could you please give me a code example of the noise reduction? I really am a beginner, so I need to see the syntax.
Thank you for the links, but there are of no help for me. I tried to understand them, but it is just too many new things at once.
Could you please complete the following?
### what do i need to import? ###
### creating some random data ###
import numpy as np
N = 1000
x = np.zeros(N)
for i in range(N):
x[i] = random.random()
###creating the audio file ###
import soundfile as sf
sf.write( "randomnoise.wav", x, 100)
### getting noise profile ###
audacity -> get noise profile(randomnoise.wav,start = 0 s, end = 2 s)
### lowering the noise ###
audacity -> lower the noise (randomnoise.wav, start = 0 s, end = 10 s, 10dB, sensitivity = 6, bands = 3)
Are you able to run commands using the pipeclient.py command-line interface?
Can you import a file into Audacity using the pipeclient.py command-line interface?
Can you create a noise profile using the pipeclient.py command-line interface?
Can you apply Noise Reduction using the pipeclient.py command-line interface?
I really appreciate your effort of educating me, but I really already got through all of this. The pipe_test.py is working (I need to restart Audacity after every call, but that is a minor problem), I can see see that the command is called through a series of functions, but no, I have not been able to get the logic behind
as a derivative from the hierarchy Extra: Scriptables II → GetInfo: (enum Type (default:Commands) …)
Moreover I still don’t know if the command is even working for the scripting at all.
I understand that it is all clear for an experienced programmer, but I really am a beginner. Could you please PLEASE just finish the code I proposed? That would save me many days (maybe months) of time.
I’m not a Python expert, but this works for me.
“pipeclient.py” must be in the same location as this script so that it can be imported.
Note that I’m on Linux, so you will need to make some adjustments for Windows.
You will also need to adjust file paths and file names to suit your machine.
# -*- coding: utf-8 -*
from os.path import join
# Check that we're using a recent Python
assert sys.version_info >= (3, 6)
# Path to Audacity executable
# (I'm using a development version on Linux)
audacity = "..path../audacity/build/bin/Release/audacity"
# Path to audio file folder
# noise sample
noise_sample = join(folder, "noise.wav")
# file to be processed
process_file = join(folder, "myfile.wav")
# output file
processed = join(folder, "output.wav")
# Launch Audacity
# Allow enough time for Audacity to open
# Create a client object
client = pipeclient.PipeClient()
# Import the noise sample
# Get the noise profile
# Undo the import
# Get the file to process
# Apply Noise Reduction
# Export the processed file