summaryrefslogblamecommitdiff
path: root/kaldi_io/src/test.c
blob: e92b4c9544a8a9888fe14f6e6e2de5613a62d840 (plain) (tree)















































                                                                                                                                         
/*********************************************************************************
*     File Name           :     test.c
*     Created By          :     YIMMON, [email protected]
*     Creation Date       :     [2015-08-05 17:39]
*     Last Modified       :     [2015-08-06 14:28]
*     Description         :
**********************************************************************************/

#include "cwrapper_kaldi.h"
#include <stdio.h>

char feature_rspecifier[] = {"ark:/slfs6/users/ymz09/kaldi/src/featbin/copy-feats scp:/slfs6/users/ymz09/swb_ivec/train_bp.scp ark:- |"};

void print_nerv_matrix(Matrix *mat) {
    int n = mat->nrow;
    int m = mat->ncol;
    int i, j;
    size_t stride = mat->stride;
    for (i = 0; i < n; i++)
    {
        float *nerv_row = (float *)((char *)mat->data.f + i * stride);
        for (j = 0; j < m; j++)
            printf("%.8f ", nerv_row[j]);
        puts("");
    }
}

int main(int argc, char *argv[])
{
    Matrix *mat;
    KaldiFeatureRepo *repo = kaldi_feature_repo_new(feature_rspecifier);

    mat = kaldi_feature_repo_read_utterance(repo, NULL, 1);
    printf("1st uttrance\n");
    print_nerv_matrix(mat);

    kaldi_feature_repo_next(repo);

    mat = kaldi_feature_repo_read_utterance(repo, NULL, 1);
    printf("2nd uttrance\n");
    print_nerv_matrix(mat);

    printf("is end: %d\n", kaldi_feature_repo_is_end(repo));

    kaldi_feature_repo_destroy(repo);

    return 0;
}