Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AIFF-C file cannot be read with aifc module in python

I am trying to read a compressed .aiff file stored on my local directory. I get this;

>>>import aifc
>>>s = aifc.open('/Users/machinename/Desktop/folder/AudioTrack.aiff','r')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/aifc.py",     line 942, in open
return Aifc_read(f)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/aifc.py", line 347, in __init__
self.initfp(f)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/aifc.py", line 317, in initfp
self._read_comm_chunk(chunk)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/aifc.py", line 497, in _read_comm_chunk
raise Error, 'cannot read compressed AIFF-C files'
aifc.Error: cannot read compressed AIFF-C files
>>>

I believe there must be a workaround for this. Here you can see aifc is supports aiff-c files as well.

A simple question, yet I could not find a solution on the web.

like image 516
Bedi Egilmez Avatar asked Oct 31 '22 19:10

Bedi Egilmez


1 Answers

Old post, but... There seem to be two possible issues with this.

1 - You might need to pip install cl. If AIFC fails to import the cl module, it'll report the error you mention.

2 - There seems to be a bug in the aifc.py source (at least the one I found) where it expects uncompressed files to specify compression as 'NONE'. However some files seem to report 'raw ' (notice the extra space at the end) and AIFC does not recognize this as a compression format.

like image 80
user9340867 Avatar answered Nov 09 '22 23:11

user9340867