I am programming a simple audio recorder with Audacity script-mod-pipe. I want the script to export the sound recordings in audacity when code is ran. How do I do this?
How far have you got? What specifically do you need help with?
I don’t have any code. I do know that I am running pipe_test.py and using “send_command(“Record1stChoice”)” But when I do that with export, “send_command(“Export”)” it just pulls up the export screen. I want it to export to the time and date when code is ran, but it doesn’t do that any ideas?
Use the Export2
command along with the full file path and file name and the number of channels.
(Command reference: Scripting Reference - Audacity Manual)
It’s easiest to use a forward slash (“/”) as the file path separator (even on Windows)
No, it’s supposed to export to a folder without me selecting it with the name as the date and time. What would the code be?
That will be the “ExportAudio:” command, but I’m not sure that command still works. If you get a “command not recognized” error, then you may want to report it to the developers (requires a free GitHub account): Issues · audacity/audacity · GitHub
No, that’s what I tried and it just pulls up the export screen, it doesn’t actually export.
Maybe go back to an older version of Audacity.
I have version 2.4.2. Would I do something like this to export or would I do something different because I have an older version? Code: send_command("ExportAudio: thing.mp3")
Rememeber, I have pipe_test.py so would something like this be good? Or would I scrap the .mp3
?
I use the “Export2:” command, which is what I suggested initially. There’s not much more I can tell you. The Python interface as it is now, was written by James Crook. Development of this feature stopped when muse group took over and James left the Audacity team (about 2 and a half years ago) .
What would the code be for “Export2”? Something like this: send_command("Export2 test.mp3")
or something else? What should I put?
The actual command is as described in the command reference: Scripting Reference - Audacity Manual For example:
Export2: Filename="C:/Users/Fred/Desktop/MyFile.wav" NumChannels=2
How exactly you send that command depends on your Python code. (My recommendation is to use pipeclient.py).
I have pipe_test.py so would I do something like this: send_command("Export2: Filename='home/pi/raspberrypi/Desktop/test.wav")
And I don’t want any channels so is this good?
You may need a “/” before “home”.
According to the documentation, Export2 defaults to 1 channel (mono), so if that is correct then omitting “NumChannels” will export as mono.
Try it and see what happens.
Thanks, I will try it. Quick question: is there any way to get the date as the name but still export to “Desktop”?
UPDATE: I tried the Export2 function and it worked, but it doesn’t export what’s in Audacity. I recorded something, ran the code, it exports, and when I went to hear my recording, there was nothing. What should I do to fix this?
You can get the date from Python.
Select the audio that you want to export, then export.
How would I do that? Is there like a select all audio command or or something?
See the scripting reference (links above)
Thanks for the help @steve I’ve been stuck for a long time! Thank you!