mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2025-08-16 16:31:34 +02:00
.devops
.github
bindings
go
examples
go-model-download
context.go
main.go
go-whisper
pkg
samples
.gitignore
LICENSE
Makefile
README.md
doc.go
go.mod
go.sum
params.go
whisper.go
whisper_test.go
ios
java
javascript
ruby
CMakeLists.txt
cmake
coreml
examples
extra
grammars
models
openvino
samples
spm-headers
tests
.gitignore
.gitmodules
CMakeLists.txt
LICENSE
Makefile
Package.swift
README.md
ggml-alloc.c
ggml-alloc.h
ggml-backend-impl.h
ggml-backend.c
ggml-backend.h
ggml-cuda.cu
ggml-cuda.h
ggml-impl.h
ggml-metal.h
ggml-metal.m
ggml-metal.metal
ggml-opencl.cpp
ggml-opencl.h
ggml-quants.c
ggml-quants.h
ggml.c
ggml.h
whisper.cpp
whisper.h
* 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
31 lines
582 B
Go
31 lines
582 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"os/signal"
|
|
)
|
|
|
|
// ContextForSignal returns a context object which is cancelled when a signal
|
|
// is received. It returns nil if no signal parameter is provided
|
|
func ContextForSignal(signals ...os.Signal) context.Context {
|
|
if len(signals) == 0 {
|
|
return nil
|
|
}
|
|
|
|
ch := make(chan os.Signal)
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
// Send message on channel when signal received
|
|
signal.Notify(ch, signals...)
|
|
|
|
// When any signal received, call cancel
|
|
go func() {
|
|
<-ch
|
|
cancel()
|
|
}()
|
|
|
|
// Return success
|
|
return ctx
|
|
}
|