Converting RAW audio data to WAV with scripting

后端 未结 7 1739
梦毁少年i
梦毁少年i 2020-12-15 18:43

I have a large number of .RAW audio files (unsigned 8-bit PCM with no-endianness) which I want to convert to .WAV files. What command-line tool (windows or linux) can I use

7条回答
  •  死守一世寂寞
    2020-12-15 19:13

    If you have a file name.txt which contains all the raw audio file names, then with python you can convert a batch of raw files to batch of wav.

    from subprocess import call
    file = "name.txt"
    with open(file,'rU') as f:
         for name in f:
            name = name[:len(name)-4]
            name1 = './'+name+'raw' #input 
            name2 = './'+name+'wav' #output
            call(["sox","-r","48000", "-t", "sw", "-e", "signed", "-c", "1", "-b", "16", name1, name2])
    

    sample rate 48K,mono channel, precision 16 bit.

提交回复
热议问题