summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.go39
1 files changed, 30 insertions, 9 deletions
diff --git a/main.go b/main.go
index c09e0e3..0b5d981 100644
--- a/main.go
+++ b/main.go
@@ -12,10 +12,11 @@ import (
)
const (
- subExt = ".vtt"
- outdir = "/mnt/desktop/media/datasets/nesfatelp_voice/utterances"
- ffCmdOut = "./ff_commands"
- timeSep = "-->"
+ subExt = ".vtt"
+ outdir = "/mnt/desktop/media/datasets/nesfatelp_voice/utterances"
+ ffCmdOut = "./ff_commands"
+ timeSep = "-->"
+ metadataPath = "/mnt/desktop/media/datasets/nesfatelp_voice/metadata.json"
)
type Utterance struct {
@@ -96,6 +97,24 @@ func writeLines(lines []string, path string) error {
return w.Flush()
}
+func readJson(filepath string) map[string]string {
+ plan, _ := ioutil.ReadFile(filepath)
+ data := make(map[string]string)
+ err := json.Unmarshal(plan, &data)
+ if err != nil {
+ log.Fatal(err)
+ }
+ return data
+}
+
+func writeJson(data map[string]string) {
+ metadataJson, _ := json.MarshalIndent(data, "", " ")
+ err := ioutil.WriteFile(metadataPath, metadataJson, 0644)
+ if err != nil {
+ log.Fatal(err)
+ }
+}
+
func buildFFmpegCall(fd *FileData, ut *Utterance) string {
return fmt.Sprintf(
`ffmpeg -i %s -ss %s -to %s \
@@ -130,10 +149,12 @@ func main() {
fmt.Println("utterances len:", len(utterances))
writeLines(ffmpegCommands, ffCmdOut)
- metadata := utterancesToFileTextMap(utterances)
- metadataJson, _ := json.MarshalIndent(metadata, "", " ")
- err := ioutil.WriteFile("metadata.json", metadataJson, 0644)
- if err != nil {
- log.Fatal(err)
+ metadata := readJson(metadataPath)
+ newMeta := utterancesToFileTextMap(utterances)
+
+ for k, v := range newMeta {
+ metadata[k] = v
}
+
+ writeJson(metadata)
}