Documentation
¶
Index ¶
- Constants
- Variables
- func NewClient(abspath string) *client
- func Whisper_lang_max_id() int
- func Whisper_lang_str(id int) string
- func Whisper_log_set(fn func(level LogLevel, text string))
- type Client
- type Context
- func (ctx *Context) Whisper_free()
- func (ctx *Context) Whisper_full(params *Params, samples []float32, encoderBeginCallback func() bool, ...) error
- func (ctx *Context) Whisper_full_get_segment_t0(segment int) int64
- func (ctx *Context) Whisper_full_get_segment_t1(segment int) int64
- func (ctx *Context) Whisper_full_get_segment_text(segment int) string
- func (ctx *Context) Whisper_full_get_token_data(segment int, token int) TokenData
- func (ctx *Context) Whisper_full_get_token_id(segment int, token int) Token
- func (ctx *Context) Whisper_full_get_token_p(segment int, token int) float32
- func (ctx *Context) Whisper_full_get_token_text(segment int, token int) string
- func (ctx *Context) Whisper_full_lang_id() int
- func (ctx *Context) Whisper_full_n_segments() int
- func (ctx *Context) Whisper_full_n_tokens(segment int) int
- func (ctx *Context) Whisper_lang_id(lang string) int
- type LogLevel
- type Params
- func (p *Params) Close()
- func (p *Params) Language() int
- func (p *Params) MarshalJSON() ([]byte, error)
- func (p *Params) SetAudioCtx(n int)
- func (p *Params) SetDuration(duration_ms int)
- func (p *Params) SetInitialPrompt(prompt string)
- func (p *Params) SetLanguage(lang int) error
- func (p *Params) SetMaxSegmentLength(n int)
- func (p *Params) SetMaxTokensPerSegment(n int)
- func (p *Params) SetNoContext(v bool)
- func (p *Params) SetOffset(offset_ms int)
- func (p *Params) SetPrintProgress(v bool)
- func (p *Params) SetPrintRealtime(v bool)
- func (p *Params) SetPrintSpecial(v bool)
- func (p *Params) SetPrintTimestamps(v bool)
- func (p *Params) SetSingleSegment(v bool)
- func (p *Params) SetSplitOnWord(v bool)
- func (p *Params) SetTemperature(t float32)
- func (p *Params) SetThreads(threads int)
- func (p *Params) SetTokenSumThreshold(t float32)
- func (p *Params) SetTokenThreshold(t float32)
- func (p *Params) SetTokenTimestamps(b bool)
- func (p *Params) SetTranslate(v bool)
- func (p *Params) String() string
- func (p *Params) Threads() int
- type SamplingStrategy
- type Token
- type TokenData
Constants ¶
const ( SampleRate = C.WHISPER_SAMPLE_RATE // Expected sample rate, samples per second SampleBits = uint16(unsafe.Sizeof(C.float(0))) * 8 // Sample size in bits NumFFT = C.WHISPER_N_FFT HopLength = C.WHISPER_HOP_LENGTH ChunkSize = C.WHISPER_CHUNK_SIZE )
Variables ¶
Functions ¶
func NewClient ¶
func NewClient(abspath string) *client
Create a new client with the specified root URL to the models
func Whisper_lang_max_id ¶
func Whisper_lang_max_id() int
Largest language id (i.e. number of available languages - 1)
func Whisper_lang_str ¶
Return the short string of the specified language id (e.g. 2 -> "de"), returns empty string if not found
func Whisper_log_set ¶
Set logging output
Types ¶
type Context ¶
type Context C.struct_whisper_context
func Whisper_init ¶
Allocates all memory needed for the model and loads the model from the given file. Returns NULL on failure.
func (*Context) Whisper_free ¶
func (ctx *Context) Whisper_free()
Frees all memory allocated by the model.
func (*Context) Whisper_full ¶
func (ctx *Context) Whisper_full( params *Params, samples []float32, encoderBeginCallback func() bool, newSegmentCallback func(int), progressCallback func(int), ) error
Run the entire model: PCM -> log mel spectrogram -> encoder -> decoder -> text Uses the specified decoding strategy to obtain the text.
func (*Context) Whisper_full_get_segment_t0 ¶
Get the start and end time of the specified segment.
func (*Context) Whisper_full_get_segment_t1 ¶
Get the start and end time of the specified segment.
func (*Context) Whisper_full_get_segment_text ¶
Get the text of the specified segment.
func (*Context) Whisper_full_get_token_data ¶
Get token data for the specified token in the specified segment. This contains probabilities, timestamps, etc.
func (*Context) Whisper_full_get_token_id ¶
Get the token of the specified token index in the specified segment.
func (*Context) Whisper_full_get_token_p ¶
Get the probability of the specified token in the specified segment.
func (*Context) Whisper_full_get_token_text ¶
Get the token text of the specified token index in the specified segment.
func (*Context) Whisper_full_lang_id ¶
Return the id of the autodetected language, returns -1 if not found Added to whisper.cpp in https://github.com/ggerganov/whisper.cpp/commit/a1c1583cc7cd8b75222857afc936f0638c5683d6
Examples:
"de" -> 2 "german" -> 2
func (*Context) Whisper_full_n_segments ¶
Number of generated text segments. A segment can be a few words, a sentence, or even a paragraph.
func (*Context) Whisper_full_n_tokens ¶
Get number of tokens in the specified segment.
func (*Context) Whisper_lang_id ¶
Return the id of the specified language, returns -1 if not found Examples:
"de" -> 2 "german" -> 2
type LogLevel ¶
type LogLevel C.enum_ggml_log_level
const ( LogLevelDebug LogLevel = C.GGML_LOG_LEVEL_DEBUG LogLevelInfo LogLevel = C.GGML_LOG_LEVEL_INFO LogLevelWarn LogLevel = C.GGML_LOG_LEVEL_WARN LogLevelError LogLevel = C.GGML_LOG_LEVEL_ERROR )
type Params ¶
type Params C.struct_whisper_full_params
func NewParams ¶
func NewParams(strategy SamplingStrategy) *Params
Returns new default parameters. Call Close() to free memory associated with the parameters.
func (*Params) MarshalJSON ¶
func (*Params) SetDuration ¶
Set audio duration to process in ms
func (*Params) SetInitialPrompt ¶
Set initial prompt
func (*Params) SetMaxSegmentLength ¶
Set max segment length in characters
func (*Params) SetMaxTokensPerSegment ¶
Set max tokens per segment (0 = no limit)
func (*Params) SetNoContext ¶
func (*Params) SetPrintProgress ¶
func (*Params) SetPrintRealtime ¶
func (*Params) SetPrintSpecial ¶
func (*Params) SetPrintTimestamps ¶
func (*Params) SetSingleSegment ¶
func (*Params) SetSplitOnWord ¶
func (*Params) SetTemperature ¶ added in v0.0.3
Set temperature
func (*Params) SetTokenSumThreshold ¶
Set timestamp token sum probability threshold (~0.01)
func (*Params) SetTokenThreshold ¶
Set timestamp token probability threshold (~0.01)
func (*Params) SetTokenTimestamps ¶
func (*Params) SetTranslate ¶
type SamplingStrategy ¶
type SamplingStrategy C.enum_whisper_sampling_strategy
const ( SAMPLING_GREEDY SamplingStrategy = C.WHISPER_SAMPLING_GREEDY // similar to OpenAI's GreedyDecoder SAMPLING_BEAM_SEARCH SamplingStrategy = C.WHISPER_SAMPLING_BEAM_SEARCH // similar to OpenAI's BeamSearchDecoder )
func (SamplingStrategy) MarshalJSON ¶
func (v SamplingStrategy) MarshalJSON() ([]byte, error)
func (SamplingStrategy) String ¶
func (v SamplingStrategy) String() string
type Token ¶
type Token C.whisper_token