Python open raw audio data file

前端 未结 3 1281
抹茶落季
抹茶落季 2020-12-18 03:19

I have these files with the extension \".adc\". They are simply raw data files. I can open them with Audacity using File->Import->Raw data with encoding \"Signed 16 bit\" an

3条回答
  •  天命终不由人
    2020-12-18 03:32

    Thanx a lot I was able to do the following:

    def play_data(filename, first_sec, second_sec):
      import ao
      from ao import AudioDevice 
      dev = AudioDevice(2, bits=16, rate=16000,channels=1)
      f = open(filename, 'r')
      data_len = (second_sec-first_sec)*32000
      f.seek(32000*first_sec)
      data = f.read(data_len)
      dev.play(data)
      f.close()
    
    play_data('AR001_3.adc', 2.5, 5)
    

提交回复
热议问题