mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2024-12-30 01:08:52 +00:00
231bebca7d
* Initial import of golang bindings * Updated makefile rules * Updated bindings * Makefile update to add in more tests
56 lines
1.2 KiB
Go
Executable File
56 lines
1.2 KiB
Go
Executable File
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)
|
|
|
|
}
|