Skip to content

Commit 14c8e18

Browse files
committed
Update logging
1 parent a27efed commit 14c8e18

File tree

5 files changed

+19
-16
lines changed

5 files changed

+19
-16
lines changed

cmd/server/main.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
httpserver "github.com/mutablelogic/go-server/pkg/httpserver"
1616
whisper "github.com/mutablelogic/go-whisper/pkg/whisper"
1717
api "github.com/mutablelogic/go-whisper/pkg/whisper/api"
18-
sys "github.com/mutablelogic/go-whisper/sys/whisper"
1918
)
2019

2120
func main() {
@@ -29,14 +28,6 @@ func main() {
2928
os.Exit(-1)
3029
}
3130

32-
// Set logging
33-
sys.Whisper_log_set(func(level sys.LogLevel, text string) {
34-
if flags.Debug() && (level == sys.LogLevelDebug || level == sys.LogLevelInfo || level == sys.LogLevelWarn) {
35-
return
36-
}
37-
log.Println(level, strings.TrimSpace(text))
38-
})
39-
4031
// Determine the directory for models
4132
dir := flags.Dir()
4233
if dir == "" {
@@ -56,7 +47,15 @@ func main() {
5647

5748
// Create a whisper service
5849
log.Println("Storing models at", dir)
59-
whisper, err := whisper.New(dir, whisper.OptMaxConcurrent(1))
50+
opts := []whisper.Opt{
51+
whisper.OptLog(func(line string) {
52+
log.Println(line)
53+
}),
54+
}
55+
if flags.Debug() {
56+
opts = append(opts, whisper.OptDebug())
57+
}
58+
whisper, err := whisper.New(dir, opts...)
6059
if err != nil {
6160
log.Println(err)
6261
os.Exit(-2)

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ require (
88
github.com/djthorpe/go-tablewriter v0.0.8
99
github.com/go-audio/wav v1.1.0
1010
github.com/mutablelogic/go-client v1.0.9
11-
github.com/mutablelogic/go-media v1.6.9
12-
github.com/mutablelogic/go-server v1.4.14
11+
github.com/mutablelogic/go-media v1.6.10
12+
github.com/mutablelogic/go-server v1.4.15
1313
github.com/stretchr/testify v1.9.0
1414
)
1515

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6T
2626
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
2727
github.com/mutablelogic/go-client v1.0.9 h1:Eh4sjQOFDldP/L3IizqkcOD3WigZR+u1VaHTUM4ujYw=
2828
github.com/mutablelogic/go-client v1.0.9/go.mod h1:VLyB8j8IBJSK/FXvvqhmq93PRWDKkyLu8R7V2Vudb6A=
29-
github.com/mutablelogic/go-media v1.6.9 h1:jkmqrMo7yKXaYXkALBeyVGpV6tNNEf36tmxdOX06VXI=
30-
github.com/mutablelogic/go-media v1.6.9/go.mod h1:HulNT0yyH63a3FRlbuzNDakhOypYrmtFVkHEXZjDgAY=
31-
github.com/mutablelogic/go-server v1.4.14 h1:MsYyS9MjBoYtWfJo/iw6DnZ8slnhakWhPPqVCuzuaV8=
32-
github.com/mutablelogic/go-server v1.4.14/go.mod h1:9nenPAohKu8bFoRgwHJh+3s8h0kLFjUAb8KZvT1TQNU=
29+
github.com/mutablelogic/go-media v1.6.10 h1:LJCNGiAJHFETtATbktTpe38lquUDiLjgeaWXsi1fzI8=
30+
github.com/mutablelogic/go-media v1.6.10/go.mod h1:HulNT0yyH63a3FRlbuzNDakhOypYrmtFVkHEXZjDgAY=
31+
github.com/mutablelogic/go-server v1.4.15 h1:jOvVdDmVK+PGCMBAk5atKHVonnccwy/b4dWwWFAOTso=
32+
github.com/mutablelogic/go-server v1.4.15/go.mod h1:9nenPAohKu8bFoRgwHJh+3s8h0kLFjUAb8KZvT1TQNU=
3333
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
3434
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
3535
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=

pkg/whisper/whisper.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"strings"
1010

1111
// Packages
12+
"github.com/mutablelogic/go-media/pkg/ffmpeg"
1213
model "github.com/mutablelogic/go-whisper/pkg/whisper/model"
1314
pool "github.com/mutablelogic/go-whisper/pkg/whisper/pool"
1415
"github.com/mutablelogic/go-whisper/pkg/whisper/schema"
@@ -80,6 +81,9 @@ func New(path string, opt ...Opt) (*Whisper, error) {
8081
}
8182
o.logfn(fmt.Sprintf("[%s] %s", level, strings.TrimSpace(text)))
8283
})
84+
ffmpeg.SetLogging(o.debug, func(text string) {
85+
o.logfn(text)
86+
})
8387
}
8488

8589
// Return success

samples/en-audiobook.mp3

2.72 MB
Binary file not shown.

0 commit comments

Comments
 (0)