Beispiel #1
0
def showFeatures(h5file):
    fdict = yaafe.readH5FeatureDescriptions(h5file)
    if len(fdict) == 0:
        print('%s contains no yaafe features' % h5file)
        return
    for name, fd in iteritems(fdict):
        print('%s [%ix%i] %iHz:' % (name, fd['dim'], fd['nbframes'],
                                    fd['sampleRate']))
        print('  - blockSize = %i' % fd['blockSize'])
        print('  - stepSize = %i' % fd['stepSize'])
        for key, val in iteritems(fd['attrs']):
            print('  - %s = "%s"' % (key, val))
        print('')
Beispiel #2
0
def showFeatures(h5file):
    fdict = yaafe.readH5FeatureDescriptions(h5file)
    if len(fdict) == 0:
        print('%s contains no yaafe features' % h5file)
        return
    for name, fd in iteritems(fdict):
        print('%s [%ix%i] %iHz:' %
              (name, fd['dim'], fd['nbframes'], fd['sampleRate']))
        print('  - blockSize = %i' % fd['blockSize'])
        print('  - stepSize = %i' % fd['stepSize'])
        for key, val in iteritems(fd['attrs']):
            print('  - %s = "%s"' % (key, val))
        print('')
Beispiel #3
0
 def _safe_get_dataflow(cls, params, samplerate):
     # filter parameters and set missing parameters with default values
     for k, v in iteritems(params):
         if not k in [key for (key, _, _) in
                      cls._EXPOSED_PARAM_DESCRIPTORS]:
             print('WARNING: unknown parameter %s for feature %s !' % (
                 k, cls.__name__))
     filt_params = dict([
         (name, str(params.get(name, default)))
         for (name, default, desc) in cls._EXPOSED_PARAM_DESCRIPTORS])
     # build dataflow
     df = f(cls, filt_params, samplerate)
     # automatically add library dependency
     for l in cls.COMPONENT_LIBS:
         df.useComponentLibrary(l)
     return df
Beispiel #4
0
 def _safe_get_dataflow(cls, params, samplerate):
     # filter parameters and set missing parameters with default values
     for k, v in iteritems(params):
         if not k in [
                 key for (key, _, _) in cls._EXPOSED_PARAM_DESCRIPTORS
         ]:
             print('WARNING: unknown parameter %s for feature %s !' %
                   (k, cls.__name__))
     filt_params = dict([(name, str(params.get(name, default)))
                         for (name, default,
                              desc) in cls._EXPOSED_PARAM_DESCRIPTORS])
     # build dataflow
     df = f(cls, filt_params, samplerate)
     # automatically add library dependency
     for l in cls.COMPONENT_LIBS:
         df.useComponentLibrary(l)
     return df
Beispiel #5
0
    def setOutputFormat(self, format, outDir, params):
        """
            Set output format.

            :param format: format to set
            :type format: string
            :param outDir: base output directory for output files
            :type outDir: string
            :param params: format parameters
            :type params: dict
            :return: True if ok, False if format does not exists.
        """
        if not AudioFileProcessor._YAAFE_IO_LOADED:
            AudioFileProcessor._YAAFE_IO_LOADED = (
                loadComponentLibrary('yaafe-io') == 0)

        tmp = ((c_char_p * 2) * (len(params) + 1))()
        tmp[:-1] = [(c_char_p * 2)(c_char_p(to_char(k)), c_char_p(to_char(v)))
                    for k, v in iteritems(params)]
        if yc.audiofileprocessor_setOutputFormat(self.ptr, to_char(format),
                                                 to_char(outDir), tmp):
            return True
        return False
Beispiel #6
0
    def setOutputFormat(self, format, outDir, params):
        """
            Set output format.

            :param format: format to set
            :type format: string
            :param outDir: base output directory for output files
            :type outDir: string
            :param params: format parameters
            :type params: dict
            :return: True if ok, False if format does not exists.
        """
        if not AudioFileProcessor._YAAFE_IO_LOADED:
            AudioFileProcessor._YAAFE_IO_LOADED = (
                loadComponentLibrary('yaafe-io') == 0)

        tmp = ((c_char_p*2)*(len(params)+1))()
        tmp[:-1] = [(c_char_p*2)(c_char_p(to_char(k)), c_char_p(to_char(v)))
                    for k, v in iteritems(params)]
        if yc.audiofileprocessor_setOutputFormat(self.ptr, to_char(format),
                                                 to_char(outDir), tmp):
            return True
        return False
Beispiel #7
0
 def __repr__(self):
     return 'DataFlowNode: %s %s' % (
         self.componentId(),
         ' '.join(['%s=%s' % (k, v) for k, v in iteritems(self.params())]))
Beispiel #8
0
 def createNode(self, componentId, params):
     tmp = ((c_char_p*2)*(len(params)+1))()
     tmp[:-1] = [(c_char_p*2)(c_char_p(to_char(k)), c_char_p(to_char(v)))
                 for k, v in iteritems(params)]
     return DataFlowNode(yc.dataflow_createNode(self.ptr,
                                                to_char(componentId), tmp))
Beispiel #9
0
 def __repr__(self):
     return 'DataFlowNode: %s %s' % (self.componentId(), ' '.join(
         ['%s=%s' % (k, v) for k, v in iteritems(self.params())]))
Beispiel #10
0
 def createNode(self, componentId, params):
     tmp = ((c_char_p * 2) * (len(params) + 1))()
     tmp[:-1] = [(c_char_p * 2)(c_char_p(to_char(k)), c_char_p(to_char(v)))
                 for k, v in iteritems(params)]
     return DataFlowNode(
         yc.dataflow_createNode(self.ptr, to_char(componentId), tmp))