Exemplo n.º 1
0
    def load_target(self):
        self.p.logsection("TARGET")
        self.tgt = sfsegment.target(self.ops.TARGET, self.AnalInterface)
        self.tgt.initAnal(self.AnalInterface, self.ops, self.p)
        self.tgt.stageSegments(self.AnalInterface, self.ops, self.p)

        if len(self.tgt.segs) == 0:
            util.error(
                "TARGET FILE",
                "no segments found!  this is rather strange.  could your target file %s be digital silence??"
                % (self.tgt.filename))
        self.p.log(
            "TARGET SEGMENTATION: found %i segments with an average length of %.3f seconds"
            % (len(self.tgt.segs), np.average(self.tgt.seglengths)))

        descriptors = []
        dnames = []
        self.ops.parseDescriptors()
        for dobj in self.ops._normalizeDescriptors + self.ops._limitDescriptors:
            if dobj.seg or dobj.name in ['power']: continue
            d = np.array(self.tgt.whole.desc.get(dobj.name, copy=True))
            d -= np.min(d)
            d /= np.max(d)
            d = np.around(d, 2)

            descriptors.append(d)
            dnames.append(dobj.name)
        if self.p.html != None:
            self.p.html.jschart_timeseries(yarray=np.array([
                self.AnalInterface.f2s(i)
                for i in range(self.tgt.whole.lengthInFrames)
            ]),
                                           xarrays=descriptors,
                                           ylabel='time in seconds',
                                           xlabels=dnames)
Exemplo n.º 2
0
        options.SEGMENTATION_INFO
    }

    ops = concatenativeclasses.parseOptions(
        optsDict=agopts,
        defaults=defaultpath,
        scriptpath=os.path.dirname(__file__))
    p = userinterface.printer(ops.VERBOSITY, os.path.dirname(__file__),
                              "/tmp/agsegmentationlog.txt")
    p.printProgramInfo(audioguide.__version__, force=True)
    AnalInterface = ops.createAnalInterface(p)
    ############
    ## TARGET ##
    ############
    p.middleprint('AUDIOGUIDE SEGMENT SOUNDFILE', force=True)
    filetosegment = sfsegment.target(ops.TARGET, AnalInterface)
    filetosegment.initAnal(AnalInterface, ops, p)
    minamp = util.ampToDb(min(filetosegment.whole.desc['power']))
    p.pprint("Evaluating %s from %.2f-%.2f" %
             (filetosegment.filename, filetosegment.whole.segmentStartSec,
              filetosegment.whole.segmentEndSec),
             colour="BOLD")

    if options.OUTPUT_FILE == '': segFile = file + '.txt'
    else: segFile = os.path.abspath(options.OUTPUT_FILE)

    grainLengthFrames = round(options.GRAINLENGTH / AnalInterface.f2s(1), 0)
    grainHopFrames = round(options.GRAINHOP / AnalInterface.f2s(1), 0)
    newSegmentationInOnsetFrames = []
    newExtraSegmentationData = []
    for sidx, (start,