mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2024-12-21 05:33:06 +00:00
86a277f78d
* run `go mod tidy` before building examples Running `make examples` after cloning the repository gives the following error: ``` ... [100%] Built target whisper gmake[3]: Leaving directory '/tmp/exp/whisper.cpp/bindings/go/build' gmake[2]: Leaving directory '/tmp/exp/whisper.cpp/bindings/go/build' gmake[1]: Leaving directory '/tmp/exp/whisper.cpp/bindings/go/build' Build example go-model-download Build example go-whisper examples/go-whisper/process.go:11:2: missing go.sum entry for module providing package github.com/go-audio/wav (imported by github.com/ggerganov/whisper.cpp/bindings/go/examples/go-whisper); to add: go get github.com/ggerganov/whisper.cpp/bindings/go/examples/go-whisper make: *** [Makefile:26: examples/go-whisper] Error 1 ``` * remove executable bit from various files
56 lines
1.2 KiB
Go
56 lines
1.2 KiB
Go
package whisper_test
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
// Packages
|
|
whisper "github.com/ggerganov/whisper.cpp/bindings/go/pkg/whisper"
|
|
assert "github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
const (
|
|
ModelPath = "../../models/ggml-tiny.bin"
|
|
SamplePath = "../../samples/jfk.wav"
|
|
)
|
|
|
|
func Test_Whisper_000(t *testing.T) {
|
|
assert := assert.New(t)
|
|
if _, err := os.Stat(ModelPath); os.IsNotExist(err) {
|
|
t.Skip("Skipping test, model not found:", ModelPath)
|
|
}
|
|
if _, err := os.Stat(SamplePath); os.IsNotExist(err) {
|
|
t.Skip("Skipping test, sample not found:", SamplePath)
|
|
}
|
|
|
|
// Load model
|
|
model, err := whisper.New(ModelPath)
|
|
assert.NoError(err)
|
|
assert.NotNil(model)
|
|
assert.NoError(model.Close())
|
|
|
|
t.Log("languages=", model.Languages())
|
|
}
|
|
|
|
func Test_Whisper_001(t *testing.T) {
|
|
assert := assert.New(t)
|
|
if _, err := os.Stat(ModelPath); os.IsNotExist(err) {
|
|
t.Skip("Skipping test, model not found:", ModelPath)
|
|
}
|
|
if _, err := os.Stat(SamplePath); os.IsNotExist(err) {
|
|
t.Skip("Skipping test, sample not found:", SamplePath)
|
|
}
|
|
|
|
// Load model
|
|
model, err := whisper.New(ModelPath)
|
|
assert.NoError(err)
|
|
assert.NotNil(model)
|
|
defer model.Close()
|
|
|
|
// Get context for decoding
|
|
ctx, err := model.NewContext()
|
|
assert.NoError(err)
|
|
assert.NotNil(ctx)
|
|
|
|
}
|