trainer = Trainer(params, args.model_dir, single_cpu=True) with open(os.path.join(nnet_dir, "feature_dim"), "r") as f: dim = int(f.readline().strip()) #trainer.build("predict", dim=dim) trainer.build("predict", dim=dim, loss_type="extract_asoftmax", num_speakers=154) if args.rspecifier.rsplit(".", 1)[1] == "scp": # The rspecifier cannot be scp sys.exit("The rspecifier must be ark or input pipe") fp_out = open_or_fd(args.wspecifier, "wb") for index, (key, feature) in enumerate(read_mat_ark(args.rspecifier)): if feature.shape[0] < args.min_chunk_size: tf.logging.info("[INFO] Key %s length too short, %d < %d, skip." % (key, feature.shape[0], args.min_chunk_size)) continue if feature.shape[0] > args.chunk_size: feature_array = [] feature_length = [] num_chunks = int( np.ceil( float(feature.shape[0] - args.chunk_size) / (args.chunk_size / 2))) + 1 tf.logging.info( "[INFO] Key %s length %d > %d, split to %d segments." % (key, feature.shape[0], args.chunk_size, num_chunks)) for i in range(num_chunks):
trainer = Trainer(params, args.model_dir, single_cpu=True) with open(os.path.join(nnet_dir, "feature_dim"), "r") as f: dim = int(f.readline().strip()) trainer.build("predict", dim=dim) vad_dir = args.rspecifier.split(":")[5].split()[0] #tf.logging.info(vad_dir) write_dir = args.wspecifier.split(":")[3].split(",") #tf.logging.info(args.wspecifier) while True: if os.path.isfile(vad_dir): #start = time.time() fp_out = open_or_fd(args.wspecifier, "wb") for index, (key, feature) in enumerate(read_mat_ark(args.rspecifier)): if feature.shape[0] < args.min_chunk_size: tf.logging.info( "[INFO] Key %s length too short, %d < %d, skip." % (key, feature.shape[0], args.min_chunk_size)) continue if feature.shape[0] > args.chunk_size: feature_array = [] feature_length = [] num_chunks = int( np.ceil( float(feature.shape[0] - args.chunk_size) / (args.chunk_size / 2))) + 1 tf.logging.info( "[INFO] Key %s length %d > %d, split to %d segments." % (key, feature.shape[0], args.chunk_size, num_chunks))