Save waveform to file path as a WAV file.

        :returns: Path to the saved file.
341670
def save(self, path):
        
        (folder, filename) = os.path.split(path)
        (name, extension) = os.path.splitext(filename)

        if not name:
            raise ValueError, "name is required"

        path = os.path.join(folder, name + self.extension)
        f = open(path, "wb")
        f.write(self.contents)
        f.close()

        return path
84313
def save_fileAs(self, file=None):
        

        file = file or umbra.ui.common.store_last_browsed_path(
            QFileDialog.getSaveFileName(self, "Save As:", self.__file))
        if not file:
            return False

        return self.write_file(foundations.strings.to_string(file))
540921
def save_waypoints_csv(self, filename):
        ''''''
        try:
            #need to remove the leading and trailing quotes in filename
            self.wploader.savecsv(filename.strip('"'))
        except Exception as msg:
            print("Failed to save %s - %s" % (filename, msg))
            return
        print("Saved %u waypoints to CSV %s" % (self.wploader.count(), filename))
598458
def saveto(self, path, sortkey = True):
        
        with open(path, 'w') as f:
            self.savetofile(f, sortkey)
868768
def save_to(file)
      if file.kind_of?(String)
        begin
          File.open(file, "w") do |f|
            f.puts to_ser.to_yaml
          end
        rescue Errno::ENOENT
          raise DirCatException.new, "DirCat: cannot write into '#{file}'", caller
        end
      else
        file.puts to_ser.to_yaml
      end
    end
114192
def start_recording(self, file='mingus_dump.wav'):
        """"""
        w = wave.open(file, 'wb')
        w.setnchannels(2)
        w.setsampwidth(2)
        w.setframerate(44100)
        self.wav = w
849720
def getSaveFileName(*args):
        
        result = QtGui.QFileDialog.getSaveFileName(*args)
        
        # PyQt4 returns just a string
        if type(result) is not tuple:
            return result, bool(result)
        
        # PySide returns a tuple of str, bool
        else:
            return result
297649
def write_audio
      pcms = @queues.values
        .reject { |q| q.empty? }                      # Remove empty queues
        .map { |q| q.pop.unpack 's*' }                # Grab the top element of each queue and expand

      head, *tail = pcms
      if head
        samples = head.zip(*tail)
          .map { |pcms| pcms.reduce(:+) / pcms.size }   # Average together all the columns of the matrix (merge audio streams)
          .flatten                                      # Flatten the resulting 1d matrix
        @file.write WaveFile::Buffer.new(samples, @wav_format)
      end
    end
469866
def write_to_file(self,
                      data_dict,
                      output_file_path):
        

        log.info("saving={}".format(output_file_path))
        with open(output_file_path, "w") as output_file:
            output_file.write(str(ppj(data_dict)))
835481
def to_file(self, path, precision='%.2g'):
        
        table_info = self.get_table_info()

        def dump_rows(rows):
            if len(rows) > 1:
                for row in rows:
                    csv_writer.writerow(row)
                csv_writer.writerow([])

        with open(path, 'wb') as _f:
            csv_writer = csv.writer(_f)

            state_rows = [['States']]
            state_rows += [['Name', 'Description', 'State', 'Number of Changes']]
            for state in self.states:
                state_rows.append([state.name, table_info[state.name]['description'], state.state, state.count])
            dump_rows(state_rows)

            stat_rows = [['Statistics']]
            stat_rows += [['Name', 'Description', 'Total', 'Average']]
            for stat in self.statistics:
                if stat.name == '__submissions__':
                    continue
                stat_rows.append([stat.name, table_info[stat.name]['description'], stat.count, stat.get_average(0)])
                dump_rows(stat_rows)

            timer_rows = [['Timers']]
            timer_rows += [['Name', 'Description', 'Average Seconds', 'Total Seconds', 'Total Minutes', 'Total Hours', 'Total Days']]
            for timer in self.timers:
                timer_rows.append([timer.name, table_info[timer.name]['description'],
                                   precision % timer.get_average(0), precision % timer.total_seconds, precision % timer.total_minutes,
                                   precision % timer.total_hours, precision % timer.total_days])
                dump_rows(timer_rows)

            sequence_rows = [['Sequences']]
            sequence_rows += [['Name', 'Description', 'Sequence', 'Number of Completions']]
            for sequence in self.sequences:
                checkpoints = '-->'.join(map(str, sequence.get_checkpoints()))
                sequence_rows.append([sequence.name, table_info[sequence.name]['description'], checkpoints, sequence.count])
                dump_rows(sequence_rows)
58260
def convert_to_wav(files):
    ''''''
    converted = []
    for f in files:
        new_name = f + '.temp.wav'
        print(new_name)
        if (os.path.exists(f + '.transcription.txt') is False) and (os.path.exists(new_name) is False):
            subprocess.call(['ffmpeg', '-y', '-i', f, '-acodec', 'pcm_s16le', '-ac', '1', '-ar', '16000', new_name])
        converted.append(new_name)
    return converted
651406
def save(self, filename="temp.pkl"):
    
    output = open(filename, 'wb')
    cPickle.dump(self.tm, output, protocol=cPickle.HIGHEST_PROTOCOL)
1148065
def fbank(wav_path, flat=True):
    

    (rate, sig) = wav.read(wav_path)
    if len(sig) == 0:
        logger.warning("Empty wav: {}".format(wav_path))
    fbank_feat = python_speech_features.logfbank(sig, rate, nfilt=40)
    energy = extract_energy(rate, sig)
    feat = np.hstack([energy, fbank_feat])
    delta_feat = python_speech_features.delta(feat, 2)
    delta_delta_feat = python_speech_features.delta(delta_feat, 2)
    all_feats = [feat, delta_feat, delta_delta_feat]
    if not flat:
        all_feats = np.array(all_feats)
        # Make time the first dimension for easy length normalization padding
        # later.
        all_feats = np.swapaxes(all_feats, 0, 1)
        all_feats = np.swapaxes(all_feats, 1, 2)
    else:
        all_feats = np.concatenate(all_feats, axis=1)

    # Log Mel Filterbank, with delta, and double delta
    feat_fn = wav_path[:-3] + "fbank.npy"
    np.save(feat_fn, all_feats)
262202
def save_as(self):
        """"""
        filename = splitext(self.filename)[0]
        filename, _ = QFileDialog.getSaveFileName(self, 'Export events',
                                                  filename)
        if filename == '':
            return

        self.filename = filename
        short_filename = short_strings(basename(self.filename))
        self.idx_filename.setText(short_filename)
558261
def save_current_as(self):
        
        if not self.current_widget():
            return
        mem = self.current_widget().file.path
        self.current_widget().file._path = None
        self.current_widget().file._old_path = mem
        CodeEditTabWidget.default_directory = os.path.dirname(mem)
        widget = self.current_widget()
        try:
            success = self.main_tab_widget.save_widget(widget)
        except Exception as e:
            QtWidgets.QMessageBox.warning(
                self, _('Failed to save file as'),
                _('Failed to save file as %s\nError=%s') % (
                    widget.file.path, str(e)))
            widget.file._path = mem
        else:
            if not success:
                widget.file._path = mem
            else:
                CodeEditTabWidget.default_directory = os.path.expanduser('~')
                self.document_saved.emit(widget.file.path, '')

                # rename tab
                tw = widget.parent_tab_widget
                tw.setTabText(tw.indexOf(widget),
                              os.path.split(widget.file.path)[1])

        return self.current_widget().file.path
13249
def save(self, filepath):
        

        if not filepath or not isinstance(filepath, str):
            raise ValueError("Invalid filepath")

        with open(filepath, "wb") as filehandler:
            pickle.dump(self, filehandler)
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'")