0

I'm trying to export an audio file with pydub. I did it in a mp3 format, however it was really slow. Then I found out that using a wav format can make the process faster, but the size of the output file will be bigger.

audio.export("C:/Users/me/audio.wav", format="wav")

I am using a 64 bit version of python, so pydub can export 1 hour long audio files. But I need to export 10 hours long audio file. Here it says "MemoryError".

How can i make pydub export a 10 hours long audio file? Or maybe there are some alternatives to pydub that will let you export a 10 hours long audio file?

Edit:

The problem isn't in export. The problem is in AudioSegment. When I try to open a new large file (10 hours long audio), a 'MemoryError' appears.

audio = AudioSegment.from_wav('C:/Users/me/audio.wav')

How can I solve this problem?

Karp
  • 431
  • 1
  • 6
  • 16
  • I think it's currently not possible to create a 10 hour audio file in wav format because of this issue [Add Support for large audio files ( > 2GB) · Issue #135 · jiaaro/pydub](https://github.com/jiaaro/pydub/issues/135 "Add Support for large audio files ( > 2GB) · Issue #135 · jiaaro/pydub"). One hour of uncompressed audio at 16bit, Stereo, 44100 Hz takes 635 MB, see [Audio File Size Calculator](https://www.colincrawley.com/audio-file-size-calculator/ "Audio File Size Calculator"). – Wolf Mar 17 '21 at 13:10
  • Maybe this question can help you though https://stackoverflow.com/q/66398978/2932052 – Wolf Mar 17 '21 at 13:16
  • Maybe there is a way to create a large audio file not in a wav format? But I want it to export not so slowly as mp3. – Karp Mar 17 '21 at 13:24
  • The question linked to in my last comment seems to have an answer concerning this – Wolf Mar 17 '21 at 13:26
  • @Wolf sorry I can't understand where is the answer to my question. I believe it is in a github post (link in a Ajay's answer) but can you please explain it for me – Karp Mar 17 '21 at 13:43
  • it's the hint to install `simpleaudio` – Wolf Mar 17 '21 at 13:46
  • @Wolf ok, thank you. I’ll try this – Karp Mar 17 '21 at 13:51
  • @Wolf I installed simpleaudio but it doesn't seem to help. Do I need to do something else (for example import it) to make it work. Also I edited a question. The problem isn't in export. It is in AudioSegment. It throws an error when I make this variable too big (when the input file is large). – Karp Mar 17 '21 at 14:10
  • What actually are you trying to do (programmatically)? Could it maybe be done with an existing tool like audacity? – Wolf Mar 19 '21 at 13:20
  • BTW: WAV will only allow 6.8 hours: https://en.wikipedia.org/wiki/WAV#Limitations – Wolf Mar 19 '21 at 13:24
  • The already mentioned Audacity has no size limit for recording: https://manual.audacityteam.org/man/recording_length.html - so I guess you can also work on large files, see for example https://www.audacityteam.org/about/features/editing/ and https://www.audacityteam.org/about/features/effects/ – Wolf Mar 19 '21 at 13:30
  • @Wolf ok, thank you – Karp Mar 19 '21 at 13:46

0 Answers0