0

I have .wav files sampled at 192kHz and want to split them based on time to many smaller files while keeping the same sample rate.

To start with I thought I would just open and re-save the wav file using pydub in order to learn how to do this. However when I save it it appears to resave at a much lower file size, I'm not sure why, perhaps the sample rate is lower? and I also can't open the new file with the audio analysis program I usually use (Song scope).

So I had two questions: - How to open, read, copy and resave a wav file using pydub without changing it? (Sorry I know this is probably easy I just can't find it yet).

Whether Python and Pydub are a sensible choice for what I am trying to do? Or maybe there is a much simpler way.
what I am exactly trying to do is: Split about 10 high sample frequency wav files (~ 1GB each) into many (about 100) small wave files. (I plan to make a list of start and end times for each of the smaller wav files needed then get Python to open copy and resave the wav file data between those times).

I assume it is possible since I've seen questions for lower frequency wav files, but if you know otherwise or know of a simpler way please let me know. Thanks!!

My code so far is as follows:

from pydub import AudioSegment


# Input audio file to be sliced 
audio = AudioSegment.from_wav("20190212_164446.wav") 

audio.export("newWavFile.wav")

(I put the wav file and ffmpeg into the same directory as the Python file to save time since was having a lot of trouble getting pydub to find ffmpeg).

In case it's relevant the files are of bat calls, these bats make calls between around 1kHz and 50kHz which is quite low frequency for bats. I'm trying to crop out the actual calls from some very long files.

I know this is a basic question, I just couldn't find the answer yet, please also feel free to direct me to the answer if it's a duplicate.

thanks!!

Shara
  • 121
  • 2
  • 10
  • You can probably just use the built-in, slightly lower level `wavfile` library for this. – AKX Jul 10 '19 at 04:08
  • @AKX ok, thanks will have a look :) – Shara Jul 10 '19 at 04:26
  • maybe with [python-ffmpeg](https://github.com/kkroening/ffmpeg-python) or [MoviePy](https://zulko.github.io/moviepy/) which also uses `ffmpeg`. But I never tried – furas Jul 10 '19 at 04:38

0 Answers0