diff options
author | GrailFinder <wohilas@gmail.com> | 2023-02-16 14:45:10 +0300 |
---|---|---|
committer | GrailFinder <wohilas@gmail.com> | 2023-02-16 14:45:10 +0300 |
commit | 08f3748a34fe4d7d42da4670c8c46b7b73fbb720 (patch) | |
tree | 91721b5986f63956893c5d87bbce0284dc9c43f7 /main.go | |
parent | f7fd6d7e5877f96c605137ae185626ac6f85eebc (diff) |
Feat: attempt concurrency
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 26 |
1 files changed, 19 insertions, 7 deletions
@@ -9,7 +9,6 @@ import ( "strings" ) -// TODO: to config file const ( subExt = ".vtt" outdir = "data/utterances" @@ -73,9 +72,10 @@ func linesToUtterances(lines []string, fd *FileData) []*Utterance { RightTime: strings.TrimSpace(splitted[1]), FD: fd, } - u.OutPath = fmt.Sprintf("%s/%s_%s_%s.opus", outdir, fd.AudioBase, + u.OutPath = fmt.Sprintf("%s/%s_%s_%s.wav", outdir, fd.AudioBase, u.LeftTime, u.RightTime) + // todo: compare and filter time if u.LeftTime == u.RightTime { continue } @@ -162,15 +162,27 @@ func main() { panic(err) } - filteredUtterances := []*Utterance{} + // filteredUtterances := []*Utterance{} + + // === concurrent === + queue := make(chan *Utterance, 1000) + done := make(chan bool, 1) + + workers := 10 + for i := 0; i < workers; i++ { + go worker(queue, i, done) + } for _, ut := range utterances { if _, err := os.Stat(ut.OutPath); os.IsNotExist(err) { - if err := cutoutClipAndTranscode(ut); err == nil { - filteredUtterances = append(filteredUtterances, ut) - } + queue <- ut + // if err := cutoutClipAndTranscode(ut); err == nil { + // filteredUtterances = append(filteredUtterances, ut) + // } } } - newMeta := utterancesToFileTextMap(filteredUtterances) + done <- true + close(done) + newMeta := utterancesToFileTextMap(utterances) writeCSV(mapToCSV(newMeta)) } |