Parameters
        ----------
        audio_abs_path : str

        Returns
        -------
        total_seconds : int
182714
def _get_audio_duration_seconds(self, audio_abs_path):
        
        HHMMSS_duration = subprocess.check_output(
            ("""sox --i {} | grep "{}" | awk -F " : " '{{print $2}}' | grep -oh "^[^=]*" """).format(
                audio_abs_path, "Duration"),
            shell=True, universal_newlines=True).rstrip()
        total_seconds = sum(
            [float(x) * 60 ** (2 - i)
             for i, x in enumerate(HHMMSS_duration.split(":"))])
        return total_seconds
195058
def num_samples(self):
        
        with audioread.audio_open(self.path) as f:
            return int(f.duration * f.samplerate)
683173
def abspath(self, path):
        """"""
        if self.is_ssh(path):
            return path
        else:
            return os.path.abspath(path)
439191
def format_duration(secs):
    
    secs = int(secs)

    if abs(secs) > 60:
        mins = abs(secs) / 60
        secs = abs(secs) - (mins * 60)

        return '%s%im %02is' % ('-' if secs < 0 else '', mins, secs)

    return '%is' % secs
1210125
def scan(audio_filepaths, *, album_gain=False, skip_tagged=False, thread_count=None, ffmpeg_path=None, executor=None):
  
  r128_data = {}

  with contextlib.ExitStack() as cm:
    if executor is None:
      if thread_count is None:
        try:
          thread_count = len(os.sched_getaffinity(0))
        except AttributeError:
          thread_count = os.cpu_count()
      enable_ffmpeg_threading = thread_count > (len(audio_filepaths) + int(album_gain))
      executor = cm.enter_context(concurrent.futures.ThreadPoolExecutor(max_workers=thread_count))
      asynchronous = False
    else:
      enable_ffmpeg_threading = False
      asynchronous = True

    loudness_tags = tuple(map(has_loudness_tag, audio_filepaths))

    # remove invalid files
    audio_filepaths = tuple(audio_filepath for (audio_filepath,
                                                has_tags) in zip(audio_filepaths,
                                                                 loudness_tags) if has_tags is not None)
    loudness_tags = tuple(filter(None, loudness_tags))

    futures = {}
    if album_gain:
      if skip_tagged and all(map(operator.itemgetter(1), loudness_tags)):
        logger().info("All files already have an album gain tag, skipping album gain scan")
      elif audio_filepaths:
        calc_album_peak = any(map(lambda x: os.path.splitext(x)[-1].lower() != ".opus",
                                  audio_filepaths))
        futures[ALBUM_GAIN_KEY] = executor.submit(get_r128_loudness,
                                                  audio_filepaths,
                                                  calc_peak=calc_album_peak,
                                                  enable_ffmpeg_threading=enable_ffmpeg_threading,
                                                  ffmpeg_path=ffmpeg_path)
    for audio_filepath in audio_filepaths:
      if skip_tagged and has_loudness_tag(audio_filepath)[0]:
        logger().info("File '%s' already has a track gain tag, skipping track gain scan" % (audio_filepath))
        continue
      if os.path.splitext(audio_filepath)[-1].lower() == ".opus":
        # http://www.rfcreader.com/#rfc7845_line1060
        calc_peak = False
      else:
        calc_peak = True
      futures[audio_filepath] = executor.submit(get_r128_loudness,
                                                (audio_filepath,),
                                                calc_peak=calc_peak,
                                                enable_ffmpeg_threading=enable_ffmpeg_threading,
                                                ffmpeg_path=ffmpeg_path)

    if asynchronous:
      return futures

    for audio_filepath in audio_filepaths:
      try:
        r128_data[audio_filepath] = futures[audio_filepath].result()
      except KeyError:
        # track gain was skipped
        pass
      except Exception as e:
        # raise
        logger().warning("Failed to analyze file '%s': %s %s" % (audio_filepath,
                                                                 e.__class__.__qualname__,
                                                                 e))
    if album_gain and audio_filepaths:
      try:
        r128_data[ALBUM_GAIN_KEY] = futures[ALBUM_GAIN_KEY].result()
      except KeyError:
        # album gain was skipped
        pass
      except Exception as e:
        # raise
        logger().warning("Failed to analyze files %s: %s %s" % (", ".join("'%s'" % (audio_filepath) for audio_filepath in audio_filepaths),
                                                                e.__class__.__qualname__,
                                                                e))
  return r128_data
135258
def count_lines(abspath):
    
    with open(abspath, "rb") as f:
        i = 0
        for line in f:
            i += 1
            pass
        return i
282537
def handle_abs(self):
        """"""
        # pylint: disable=no-member
        x_raw = self.microbit.accelerometer.get_x()
        y_raw = self.microbit.accelerometer.get_y()
        x_abs = ('Absolute', 0x00, x_raw)
        y_abs = ('Absolute', 0x01, y_raw)
        return x_abs, y_abs
1229810
def absolute_path(self, path, minify=True):
        '''
        '''
        if minify:
            ending = '.%s' % self.mediatype
            if not path.endswith(ending):
                if self.minified:
                    path = '%s.min' % path
                path = '%s%s' % (path, ending)
        #
        if self.is_relative(path) and self.media_path:
            return '%s%s' % (self.media_path, path)
        elif self.asset_protocol and path.startswith('//'):
            return '%s%s' % (self.asset_protocol, path)
        else:
            return path
1136904
def total_duration(utterances: List[Utterance]) -> int:

    
    return sum([duration(utter) for utter in utterances])
604504
def end_time(self):
        
        return float(self.strain.start_time + (len(self.strain) - self.total_corruption) / self.sample_rate)
180226
def _abs(ctx, number):
    
    return conversions.to_decimal(abs(conversions.to_decimal(number, ctx)), ctx)
1119903
def get_absolute_time(self, key):
        
        keyframe = self.dct[key]
        try:
            # if absolute time is already calculated, return that
            return keyframe['__abs_time__']
        except KeyError:
            # if not, calculate by adding relative time to parent's time
            if keyframe['parent'] is None:
                keyframe['__abs_time__'] = keyframe['time']
            else:
                parent_time = self.get_absolute_time(keyframe['parent'])
                abs_time = keyframe['time'] + parent_time
                keyframe['__abs_time__'] = abs_time
            return keyframe['__abs_time__']
586132
def _path_is_abs(path):
    '''
    
    '''
    if path is None:
        return True
    try:
        return os.path.isabs(path)
    except AttributeError:
        # Non-string data passed
        return False
616920
def loudness_info(path)
      command = "#{bin(:ffmpeg)} -nostats -vn -i '#{path}' -y -filter_complex ebur128=peak=true -f null - 2>&1 | tail -12"
      out, err = run_command(command, echo_return: false)

      lines = out.split("\n").map(&:strip).compact.map { |o| o.split(":").map(&:strip) }
      group = nil
      info = {}
      lines.each do |i|
        if i.length == 1 && i[0].length > 0
          group = i[0].downcase.gsub(' ', '_').to_sym
          info[group] ||= {}
        elsif i.length == 2
          key = i[0].downcase.gsub(' ', '_').to_sym
          info[group][key] = i[1].to_f
        end
      end
      info
    end
1345864
def _parse(self, r, length):
        """"""

        def bits_left():
            return length * 8 - r.get_position()

        self.audioObjectType = self._get_audio_object_type(r)
        self.samplingFrequency = self._get_sampling_freq(r)
        self.channelConfiguration = r.bits(4)

        self.sbrPresentFlag = -1
        self.psPresentFlag = -1
        if self.audioObjectType in (5, 29):
            self.extensionAudioObjectType = 5
            self.sbrPresentFlag = 1
            if self.audioObjectType == 29:
                self.psPresentFlag = 1
            self.extensionSamplingFrequency = self._get_sampling_freq(r)
            self.audioObjectType = self._get_audio_object_type(r)
            if self.audioObjectType == 22:
                self.extensionChannelConfiguration = r.bits(4)
        else:
            self.extensionAudioObjectType = 0

        if self.audioObjectType in (1, 2, 3, 4, 6, 7, 17, 19, 20, 21, 22, 23):
            try:
                GASpecificConfig(r, self)
            except NotImplementedError:
                # unsupported, (warn?)
                return
        else:
            # unsupported
            return

        if self.audioObjectType in (
                17, 19, 20, 21, 22, 23, 24, 25, 26, 27, 39):
            epConfig = r.bits(2)
            if epConfig in (2, 3):
                # unsupported
                return

        if self.extensionAudioObjectType != 5 and bits_left() >= 16:
            syncExtensionType = r.bits(11)
            if syncExtensionType == 0x2b7:
                self.extensionAudioObjectType = self._get_audio_object_type(r)

                if self.extensionAudioObjectType == 5:
                    self.sbrPresentFlag = r.bits(1)
                    if self.sbrPresentFlag == 1:
                        self.extensionSamplingFrequency = \
                            self._get_sampling_freq(r)
                        if bits_left() >= 12:
                            syncExtensionType = r.bits(11)
                            if syncExtensionType == 0x548:
                                self.psPresentFlag = r.bits(1)

                if self.extensionAudioObjectType == 22:
                    self.sbrPresentFlag = r.bits(1)
                    if self.sbrPresentFlag == 1:
                        self.extensionSamplingFrequency = \
                            self._get_sampling_freq(r)
                    self.extensionChannelConfiguration = r.bits(4)
85959
def avg_rate(self):
        
        if not self._has_data or 'sum' not in self.result['end']:
            return None
        bps = self.result['end']['sum']['bits_per_second']
        return bps / 8 / 1024 / 1024
1030969
def abspath(raw):
    """"""
    path_bits = []
    if raw.find('/') != -1:
        path_bits = raw.split('/')
    elif raw.find('\\') != -1:
        path_bits = raw.split('\\')
    else:
        path_bits = [raw]

    return os.path.abspath(os.sep.join(path_bits))