Skip to content

Commit 657662c

Browse files
author
AI-Spawn
committed
Added transcriber to default args, added default args schema check
1 parent eebd2cc commit 657662c

File tree

7 files changed

+29
-26
lines changed

7 files changed

+29
-26
lines changed

align.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ func gentleAlign(url, audioFilePath, transcriptContent string) (GentleResponse,
6868

6969
// Close the multipart writer
7070
writer.Close()
71-
fmt.Println("Hello world")
7271
// Create the req: http.ResponseWriter, r *http.Requestuest
7372
request, err := http.NewRequest("POST", url, body)
7473
if err != nil {
@@ -87,7 +86,7 @@ func gentleAlign(url, audioFilePath, transcriptContent string) (GentleResponse,
8786
defer response.Body.Close()
8887

8988
// Read the response body
90-
responseBody, err := io.ReadAll(response.Body)
89+
responseBody, _ := io.ReadAll(response.Body)
9190

9291
var gentleRes GentleResponse
9392
err = json.Unmarshal(responseBody, &gentleRes)

argparser.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ import (
1717
//go:embed all:defaults
1818

1919
var defaults embed.FS
20+
var ARGS_SCHEMA_VERSION = 1
2021

2122
type Args struct {
23+
Schema int `json:"schema"`
2224
AudioPath string `json:"audioPath"`
2325
CharacterPath string `json:"characterPath"`
2426
Timestamps string `json:"timestamps"`
@@ -35,7 +37,7 @@ type Args struct {
3537
Transcriber string `json:"transcriber"`
3638
}
3739

38-
func loadDefaults() Args {
40+
func loadDefaults() (Args, string) {
3941
cacheDir, _ := os.UserCacheDir()
4042
matamataPath := filepath.Join(cacheDir, "matamata/")
4143

@@ -73,15 +75,23 @@ func loadDefaults() Args {
7375
log.Fatal(err)
7476
}
7577

76-
return defArgs
78+
return defArgs, defaultsPath
7779

7880
}
7981

8082
func parseArgs() Args {
81-
defArgs := loadDefaults()
83+
defArgs, defaultsPath := loadDefaults()
8284
if defArgs.CheckForUpdates {
8385
checkForUpdates()
8486
}
87+
if defArgs.Schema != ARGS_SCHEMA_VERSION {
88+
colorReset := "\033[0m"
89+
colorRed := "\033[31m"
90+
fmt.Println(string(colorRed)+"You are using an outdated default argument schema("+strconv.Itoa(defArgs.Schema)+" -> "+strconv.Itoa(ARGS_SCHEMA_VERSION)+") Please update or delete the file:", defaultsPath, string(colorReset))
91+
fmt.Println("Please note, deleting the file will reset your default arguments")
92+
os.Exit(1)
93+
}
94+
8595
audio := flag.String("a", defArgs.AudioPath, "audio path")
8696
character := flag.String("c", defArgs.CharacterPath, "character path")
8797
timestamps := flag.String("t", defArgs.Timestamps, "Timestamps file path")

checkForUpdates.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ package main
33
import (
44
"encoding/json"
55
"fmt"
6-
"golang.org/x/mod/semver"
76
"io"
87
"net/http"
8+
9+
"golang.org/x/mod/semver"
910
)
1011

1112
type Release struct {
@@ -16,7 +17,7 @@ type Release struct {
1617
}
1718

1819
func checkForUpdates() {
19-
currentSemVer := "v5.1.0"
20+
currentSemVer := "v5.1.1"
2021

2122
logM(1, "Checking for Updates...")
2223
endpointUrl := "https://api.github.com/repos/Matamata-Animator/Matamata/releases?per_page=1"

defaults/defaultArguments.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
{
2+
"schema": 1,
23
"audioPath": "",
34
"characterPath": "",
45
"timestamps": "",
56
"verbose": 1,
67
"outputPath": "output.mov",
78
"transcriberUrl": "https://api.openai.com/v1/",
89
"transcriberApiKey": "",
10+
"transcriber": "Whisper",
911
"alignerUrl": "http://localhost:8765/transcriptions?async=false",
1012
"phonemesPath": "",
1113
"skipTranscriber": false,
1214
"checkForUpdates": true,
1315
"runProfiler": false
14-
}
16+
}

helpers.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,6 @@ func unwrapEmbeddedDefaultCharacter() {
8181
}
8282
unwrapHelper(generateDir, "defaults", dir)
8383
}
84-
85-
func copyMap(m map[string]string) map[string]string {
86-
m2 := make(map[string]string, len(m))
87-
for id := range m {
88-
m2[id] = m[id]
89-
}
90-
return m2
91-
}
92-
9384
func openImage(filePath string) image.Image {
9485
f, err := os.Open(filePath)
9586
if err != nil {

main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ func main() {
7777

7878
t := time.Now()
7979
fmt.Println("Completed in", t.Sub(start))
80-
Fatal(nil)
8180
if args.RunProfiler {
8281
fmt.Println("Run the pprof now")
8382
select {}

videoGenerator.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ package main
33
import (
44
"encoding/json"
55
"fmt"
6-
"github.com/disintegration/imaging"
7-
"github.com/gosuri/uiprogress"
8-
"github.com/jmoiron/jsonq"
9-
"github.com/mitchellh/mapstructure"
10-
"golang.org/x/image/draw"
116
"image"
127
"image/color"
138
"image/jpeg"
@@ -20,6 +15,12 @@ import (
2015
"strings"
2116
"sync"
2217
"time"
18+
19+
"github.com/disintegration/imaging"
20+
"github.com/gosuri/uiprogress"
21+
"github.com/jmoiron/jsonq"
22+
"github.com/mitchellh/mapstructure"
23+
"golang.org/x/image/draw"
2324
)
2425

2526
type FrameRequest struct {
@@ -65,9 +66,9 @@ func getParts(partsMap map[string]string, character *jsonq.JsonQuery, characterD
6566
}
6667
path := filepath.Join(characterDir, k, imageName)
6768

68-
scale, e := character.Float(k, "scale")
69-
x, e := character.Int(k, "x")
70-
y, e := character.Int(k, "y")
69+
scale, _ := character.Float(k, "scale")
70+
x, _ := character.Int(k, "x")
71+
y, _ := character.Int(k, "y")
7172

7273
parts = append(parts, Part{
7374
path, int16(x), int16(y), float32(scale),

0 commit comments

Comments
 (0)