store an audio file to storage dir

        :param src: audio file path
        :return: checksum value
162287
def add(self, src):
        
        if not audio.get_type(src):
            raise TypeError('The type of this file is not supported.')

        return super().add(src)
1299526
def match_file(apikey, path, metadata=None):
    
    import audioread
    with audioread.audio_open(path) as f:
        return match(apikey, iter(f), f.samplerate, int(f.duration),
                     f.channels, metadata)
312187
def is_wav(origin, filepath, fileobj, *args, **kwargs):
    
    # pylint: disable=unused-argument
    if origin == 'read' and fileobj is not None:
        loc = fileobj.tell()
        fileobj.seek(0)
        try:
            riff, _, fmt = struct.unpack('<4sI4s', fileobj.read(12))
            if isinstance(riff, bytes):
                riff = riff.decode('utf-8')
                fmt = fmt.decode('utf-8')
            return riff == WAV_SIGNATURE[0] and fmt == WAV_SIGNATURE[1]
        except (UnicodeDecodeError, struct.error):
            return False
        finally:
            fileobj.seek(loc)
    elif filepath is not None:
        return filepath.endswith(('.wav', '.wave'))
    else:
        try:
            wave.open(args[0])
        except (wave.Error, AttributeError):
            return False
        else:
            return True
266964
def save_checksum(self, path):
        
        checksum = file_hash(path)
        kv = unitdata.kv()
        kv.set('hardening:%s' % path, checksum)
        kv.flush()
1331580
def new_backup(self, src):
        

        backup_id_file = p.join(self.backup_dir, '.bk_idx')
        backup_num = file_or_default(backup_id_file, 1, int)
        backup_name = str(backup_num) + "_" + os.path.basename(src)
        backup_num += 1

        file_put_contents(backup_id_file, str(backup_num))
        return p.join(self.backup_dir, backup_name)
1097120
def _read_audio_data(self, file_path):
        
        try:
            self.log(u"Reading audio data...")
            # if we know the TTS outputs to PCM16 mono WAVE
            # with the correct sample rate,
            # we can read samples directly from it,
            # without an intermediate conversion through ffmpeg
            audio_file = AudioFile(
                file_path=file_path,
                file_format=self.OUTPUT_AUDIO_FORMAT,
                rconf=self.rconf,
                logger=self.logger
            )
            audio_file.read_samples_from_file()
            self.log([u"Duration of '%s': %f", file_path, audio_file.audio_length])
            self.log(u"Reading audio data... done")
            return (True, (
                audio_file.audio_length,
                audio_file.audio_sample_rate,
                audio_file.audio_format,
                audio_file.audio_samples
            ))
        except (AudioFileUnsupportedFormatError, OSError) as exc:
            self.log_exc(u"An unexpected error occurred while reading audio data", exc, True, None)
            return (False, None)
552709
def _populate_audio_file(self):
        
        self.log(u"Populate audio file...")
        if self.audio_file_path_absolute is not None:
            self.log([u"audio_file_path_absolute is '%s'", self.audio_file_path_absolute])
            self.audio_file = AudioFile(
                file_path=self.audio_file_path_absolute,
                logger=self.logger
            )
            self.audio_file.read_properties()
        else:
            self.log(u"audio_file_path_absolute is None")
        self.log(u"Populate audio file... done")
832785
function storeFilesToDiskSync(i_aFiles, i_sOutputdir) {
    var l_aWrittenFiles;

    mkdirp.sync(i_sOutputdir);

    l_aWrittenFiles = i_aFiles.map(function(i_oFile) {
        storeFileToDiskSync(i_oFile, i_sOutputdir);
        return path.join(i_sOutputdir, i_oFile.filename);
    });

    return l_aWrittenFiles;
}
850096
def _load_audio_file(self):
        
        self._step_begin(u"load audio file")
        # NOTE file_format=None forces conversion to
        #      PCM16 mono WAVE with default sample rate
        audio_file = AudioFile(
            file_path=self.task.audio_file_path_absolute,
            file_format=None,
            rconf=self.rconf,
            logger=self.logger
        )
        audio_file.read_samples_from_file()
        self._step_end()
        return audio_file
474580
def write_recording(recording, save_path):
        '''
        
        '''
        assert HAVE_MREX, "To use the MEArec extractors, install MEArec: \n\n pip install MEArec\n\n"
        save_path = Path(save_path)
        if save_path.is_dir():
            print("The file will be saved as recording.h5 in the provided folder")
            save_path = save_path / 'recording.h5'
        if save_path.suffix == '.h5' or save_path.suffix == '.hdf5':
            info = {'recordings': {'fs': recording.get_sampling_frequency()}}
            rec_dict = {'recordings': recording.get_traces()}
            if 'location' in recording.get_channel_property_names():
                positions = np.array([recording.get_channel_property(chan, 'location')
                                      for chan in recording.get_channel_ids()])
                rec_dict['channel_positions'] = positions
            recgen = mr.RecordingGenerator(rec_dict=rec_dict, info=info)
            mr.save_recording_generator(recgen, str(save_path), verbose=False)
        else:
            raise Exception("Provide a folder or an .h5/.hdf5 as 'save_path'")
869101
def compute_checksum(self):
        
        if self._filename.startswith("s3://"):
            print("Warning: Did not perform client-side checksumming for file in S3. To be implemented.")
            pass
        else:
            checksumCalculator = self.ChecksumCalculator(self._filename)
            self._checksums = checksumCalculator.compute()
540516
def LoadCHM(self, archiveName):
        '''
        '''
        if self.filename is not None:
            self.CloseCHM()

        self.file = chmlib.chm_open(archiveName)
        if self.file is None:
            return 0

        self.filename = archiveName
        self.GetArchiveInfo()

        return 1
684625
def get_checksum(self, encoder=base64.b64encode, hasher=hashlib.sha256):
        """"""
        assert self._closed, "Archive not closed"
        with open(self._temp_archive_file.name, 'rb') as fh:
            return encoder(checksum(fh, hasher())).decode('ascii')
756840
def audiorate(filename):
    
    if '.wav' in filename.lower():
        wf = wave.open(filename)
        fs = wf.getframerate()
        wf.close()
    elif '.call' in filename.lower():
        fs = 333333
    else:
        raise IOError("Unsupported audio format for file: {}".format(filename))

    return fs
919179
def load_indexed_audio(self, indexed_audio_file_abs_path):
        
        with open(indexed_audio_file_abs_path, "rb") as f:
            self.__timestamps = pickle.load(f)
398885
def compute_checksum(filename, max_length=2**20):
    

    fid = open(filename, 'rb') # Use binary for portability
    crcval = safe_crc(fid.read(max_length))
    fid.close()

    return crcval
388507
def save_beat(
        self,
        output_file_name,
        frequencys,
        play_time,
        sample_rate=44100,
        volume=0.01
    ):
        '''
        
        '''
        left_frequency, right_frequency = frequencys
        left_chunk = self.__create_chunk(left_frequency, play_time, sample_rate)
        right_chunk = self.__create_chunk(right_frequency, play_time, sample_rate)
        frame_list = self.read_stream(left_chunk, right_chunk, volume)

        wf = wave.open(output_file_name, 'wb')
        wf.setparams((2, 2, sample_rate, 0, 'NONE', 'not compressed'))
        wf.writeframes(b''.join(frame_list))
        wf.close()