mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2024-12-22 05:57:48 +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
45 lines
967 B
Go
45 lines
967 B
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
// Packages
|
|
whisper "github.com/ggerganov/whisper.cpp/bindings/go/pkg/whisper"
|
|
)
|
|
|
|
func main() {
|
|
flags, err := NewFlags(filepath.Base(os.Args[0]), os.Args[1:])
|
|
if err == flag.ErrHelp {
|
|
os.Exit(0)
|
|
} else if err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
os.Exit(1)
|
|
} else if flags.GetModel() == "" {
|
|
fmt.Fprintln(os.Stderr, "Use -model flag to specify which model file to use")
|
|
os.Exit(1)
|
|
} else if flags.NArg() == 0 {
|
|
fmt.Fprintln(os.Stderr, "No input files specified")
|
|
os.Exit(1)
|
|
}
|
|
|
|
// Load model
|
|
model, err := whisper.New(flags.GetModel())
|
|
if err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
os.Exit(1)
|
|
}
|
|
defer model.Close()
|
|
|
|
// Process files
|
|
for _, filename := range flags.Args() {
|
|
fmt.Println("Processing", filename)
|
|
if err := Process(model, filename, flags.GetLanguage(), flags.IsSpeedup(), flags.IsTokens()); err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
continue
|
|
}
|
|
}
|
|
}
|