I've found pyDub, and it seems like just what I need:
http://pydub.com/
The only issue is with generating silence. Can pyDub do this?
Essentially the workflow I want is:
Is this possible? I realize I could create a WAV of silence and do it that way (spacer GIF flashback, anyone?), but I'd prefer to generate the silence programmatically, because I may want to experiment with the duration of silence and/or the bitrate of the MP3.
I greatly appreciate any responses.
For accessing input Sound files click here. Let’s see the code for some functionalities of pydub library: 1) Playing Audio File: This is done using play () method. Use Up/Down Arrow keys to increase or decrease volume. 2) Knowing about .wav file: for this we will use attributes of audio file object.
Following are some functionalities that can be performed by pydub: Playing audio file. We can get certain information of file like length channels. Increase/Decrease volume of given .wav file. Merging two or more audio files. Exporting an audio file. Splitting an audio file.
now second_of_silence would be an AudioSegement just like song in the example and could be manipulated, composed, etc. with no blank audio files needed. @Jiaaro As someone who has just been made aware of pydub, allow me to complement you on the clarity of the API; it makes me wish I had audio compositing to do.
pydub.AudioSegment = class AudioSegment (__builtin__.object) | AudioSegments are *immutable* objects representing segments of audio | that can be manipulated using python code. … | silent (cls, duration=1000) from __builtin__.type | Generate a silent audio segment. | duration specified in milliseconds (default: 1000ms).
The pydub sequences are composed of pydub.AudioSegment
instances. The pydub quickstart documentation only shows how to create AudioSegments from files.
However, reading the source, or even more easily, running pydoc pydub.AudioSequence
reveals
pydub.AudioSegment = class AudioSegment(__builtin__.object)
| AudioSegments are *immutable* objects representing segments of audio
| that can be manipulated using python code.
…
| silent(cls, duration=1000) from __builtin__.type
| Generate a silent audio segment.
| duration specified in milliseconds (default: 1000ms).
which would be called like (following the usage in the quick start guide):
from pydub import AudioSegment
second_of_silence = AudioSegment.silent() # use default
second_of_silence = AudioSegment.silent(duration=1000) # or be explicit
now second_of_silence
would be an AudioSegement just like song
in the example
song = AudioSegment.from_wav("never_gonna_give_you_up.wav")
and could be manipulated, composed, etc. with no blank audio files needed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With