-
Notifications
You must be signed in to change notification settings - Fork 0
/
binding_test.go
64 lines (58 loc) · 1.48 KB
/
binding_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package whisper_test
import (
"fmt"
"runtime"
"testing"
"whisper"
)
func getLibrary() string {
switch runtime.GOOS {
//case "darwin":
// return "./deps/darwin/librwkv_arm64.dylib"
//case "linux":
// return "./deps/linux/librwkv.so"
case "windows":
return "./deps/windows/whisper-abi.dll"
default:
panic(fmt.Errorf("GOOS=%s is not supported", runtime.GOOS))
}
}
func TestNewCWhisper(t *testing.T) {
model, err := whisper.NewCWhisper(getLibrary())
if err != nil {
t.Error(err)
return
}
t.Run("Test WhisperContextDefaultParamsByRef", func(t *testing.T) {
pointer := model.WhisperContextDefaultParamsByRef()
t.Log(pointer)
})
t.Run("WhisperInitFromFileWithParamsRef", func(t *testing.T) {
params := model.WhisperContextDefaultParamsByRef()
t.Log(params)
ctx := model.WhisperInitFromFileWithParamsRef("./models/ggml-tiny.bin", params)
t.Log(ctx)
})
t.Run("Test WhisperFullDefaultParamsByRef", func(t *testing.T) {
fullParams := model.WhisperFullDefaultParamsByRef(whisper.WHISPER_SAMPLING_GREEDY)
t.Log(fullParams)
})
}
func TestNativeSysCall(t *testing.T) {
//// TODO why goland debug build pass but test build panic?
//handle, err := windows.LoadLibrary(getLibrary())
//if err != nil {
// t.Error(err)
// return
//}
//address, err := windows.GetProcAddress(handle,)
//if err != nil {
// return
//}
//var i = int(WHISPER_SAMPLING_GREEDY)
//r1, r2, _ := syscall.SyscallN(address, uintptr(i))
////if err != nil {
//// t.Error(err)
////}
//t.Log(r1, r2)
}