1 """Convert "arbitrary" sound files to AIFF (Apple and SGI's audio format).
3 Input may be compressed.
4 Uncompressed file type may be AIFF, WAV, VOC, 8SVX, NeXT/Sun, and others.
5 An exception is raised if the file is not of a recognized type.
6 Returned filename is either the input filename or a temporary filename;
7 in the latter case the caller must ensure that it is removed.
8 Other temporary files used are removed by the function.
16 __all__ = [
"error",
"toaiff"]
21 t.append(
'sox -t au - -t aiff -r 8000 -',
'--')
31 t.append(
'sox -t hcom - -t aiff -r 22050 -',
'--')
35 t.append(
'sox -t voc - -t aiff -r 11025 -',
'--')
39 t.append(
'sox -t wav - -t aiff -',
'--')
43 t.append(
'sox -t 8svx - -t aiff -r 16000 -',
'--')
47 t.append(
'sox -t sndt - -t aiff -r 16000 -',
'--')
51 t.append(
'sox -t sndr - -t aiff -r 16000 -',
'--')
55 uncompress.append(
'uncompress',
'--')
65 ret = _toaiff(filename, temps)
76 def _toaiff(filename, temps):
77 if filename[-2:] ==
'.Z':
80 sts = uncompress.copy(filename, fname)
82 raise error, filename +
': uncompress failed'
90 if type(msg) == type(())
and len(msg) == 2
and \
91 type(msg[0]) == type(0)
and type(msg[1]) == type(
''):
93 if type(msg) != type(
''):
95 raise error, filename +
': ' + msg
98 if ftype
is None or not table.has_key(ftype):
100 filename +
': unsupported audio file type ' + `ftype`
103 sts = table[ftype].
copy(fname, temp)
105 raise error, filename +
': conversion to aiff failed'