Reputation: 333
I am using Raspberry Pi to record audio. I tried pyaudio but it didn't work, then I tried to use the subprocess module. As the recording needs to be executed multiple times, I need to make sure that the recoding filename is different after every recording.
For example, I would like to:
filename = datetime.now().strftime("%Y-%m-%d_%H_%M_%S")+".wav"
My question is: can I pass this filename as an argument to subprocess? I checked the document, it says only string and list are supported as arguments in subprocess.
Upvotes: 0
Views: 193
Reputation: 91049
This filename is a string. So nothing prevents it from being used as one of the strings in subprocess.
Take care to use the list of strings variant with shell=False
(the default) and the string variant with shell=True
. Then everything should work as needed.
Upvotes: 1