Beispiel #1
0
func MakeMfcc(files []string, dst string) error {
	dir, _ := filepath.Abs(dst)
	kaldi.InsureDir(dir)
	log := filepath.Join(dir, "log")
	kaldi.InsureDir(log)
	kaldi.BashRun("rm " + dir + "/*.*")
	jobs := make(chan string, 100)
	var wg sync.WaitGroup

	for i := 0; i < 10; i++ {
		wg.Add(1)
		go func(id int, job <-chan string) {
			defer wg.Done()
			for f := range jobs {
				wav, _ := filepath.Abs(f)
				cmd := kaldi.JoinArgs("cd ~/rev_kaldi; ./steps/make_mfcc.sh",
					"--nj 8", wav, log, dir)
				fmt.Println(cmd)
				kaldi.BashRun(cmd)
			}
		}(i, jobs)
	}
	for _, f := range files {
		jobs <- f
	}
	close(jobs)
	wg.Wait()

	return nil
}
Beispiel #2
0
func deal_scp(dir string) {
	file := file_files(dir, "scp")
	if len(file) < 1 {
		fmt.Println("No scp files, maybe something wrong!")
	}
	for _, f := range file {
		name := path.Base(f)
		parts := strings.Split(name, "_")
		dir := path.Join(path.Dir(f), strings.Join(parts[:len(parts)-1], "_"))
		kaldi.InsureDir(dir)
		os.Rename(f, path.Join(dir, parts[len(parts)-1]))
	}
}
Beispiel #3
0
func ConstructData(data, param string) {
	cmd := kaldi.JoinArgs(
		"find", param, "-type f", "-iname \"feats.scp\"")
	output, _ := kaldi.BashOutput(cmd)
	files := strings.Split(strings.Trim(string(output), " \n"), "\n")
	if len(files) == 0 {
		return
	}
	for _, f := range files {
		dst := strings.Replace(f, "param/", "data/", 1)
		kaldi.InsureDir(path.Dir(dst))
		cmd := kaldi.JoinArgs("cp", f, dst)
		fmt.Println(cmd)
		kaldi.BashRun(cmd)
	}
}