Пример #1
0
def TestLoadSample():
    dir_path = os.path.join(common.DataDir(), "systest-prototype-small")
    wave_data_set = WaveDataSet()
    wave_data_set.Load(dir_path)
    PlotSpectrum(wave_data_set.x[0])

    dir_path = os.path.join(common.DataDir(), "systest-prototype-small-npy")
    print(dir_path)
    npy_data_set = NpyDataSet()
    npy_data_set.Load(dir_path)
    PlotSpectrum(npy_data_set.x[0])
def SystemTestNNTrain():
    common.LogLevel(logging.INFO)
    # src_dir = os.path.join(common.SrcDir(), "system-sample-2017-11-08-wav")
    # input_dir = os.path.join(common.DataDir(),"system-sample-2017-11-08-npy")

    wav_dir = os.path.join(common.DataDir(), "systest-prototype-small")
    npy_dir = os.path.join(common.DataDir(), "systest-prototype-small-npy")
    if not os.path.exists(npy_dir):
        PrepareInput(wav_dir, npy_dir)
    else:
        logging.info("Skipping preparing npy dir %s since it already exists",
                     npy_dir)

    systest_dataset = systestdataset.DataSet()
    systest_dataset.Load(wav_dir, npy_dir)

    systest_dataset.Split(0.8, 0.1)
Пример #3
0
def TestLinearModel():
    test_dataset = dataset.NpyDataSet()
    dir_path = os.path.join(common.DataDir(), "systest-prototype-small-npy")
    print(dir_path)
    test_dataset.Load(dir_path)
    with model.LinearModel() as linear_model:
        linear_model.Train(test_dataset, 10, 1)
        first_row = test_dataset.x[0]
        first_row = first_row.reshape(1, first_row.shape[0])
        infer_result = linear_model.Infer(first_row)
        logging.info("infer result: %d", infer_result)
Пример #4
0
def TestPlotSpectrumNpy():
    datadir = common.DataDir()
    dir_path = os.path.join(datadir, "systest-prototype-small-npy/*.npy")
    files = glob.glob(dir_path)
    logging.debug("plot spectrom npy: %s", files[0])
    PlotSpectrumNpy(files[0])
Пример #5
0
def TestPlotSpectrumWav():
    dir_path = os.path.join(common.DataDir(), "systest-prototype-small/*.wav")
    files = glob.glob(dir_path)
    logging.debug("plot spectrom wav: %s", files[0])
    PlotSpectrumWav(files[0])