package whisper // This file defines the whisper_token, whisper_token_data and whisper_full_params // structures, which are used by the whisper_full() function. import ( "fmt" ) /////////////////////////////////////////////////////////////////////////////// // CGO /* #include */ import "C" /////////////////////////////////////////////////////////////////////////////// // PUBLIC METHODS func (p *Params) SetTranslate(v bool) { p.translate = toBool(v) } func (p *Params) SetNoContext(v bool) { p.no_context = toBool(v) } func (p *Params) SetSingleSegment(v bool) { p.single_segment = toBool(v) } func (p *Params) SetPrintSpecial(v bool) { p.print_special = toBool(v) } func (p *Params) SetPrintProgress(v bool) { p.print_progress = toBool(v) } func (p *Params) SetPrintRealtime(v bool) { p.print_realtime = toBool(v) } func (p *Params) SetPrintTimestamps(v bool) { p.print_timestamps = toBool(v) } func (p *Params) SetSpeedup(v bool) { p.speed_up = toBool(v) } func (p *Params) SetLanguage(lang int) error { str := C.whisper_lang_str(C.int(lang)) if str == nil { return ErrInvalidLanguage } else { p.language = str } return nil } func (p *Params) Language() int { if p.language == nil { return -1 } return int(C.whisper_lang_id(p.language)) } func (p *Params) SetThreads(threads int) { p.n_threads = C.int(threads) } func (p *Params) SetOffset(offset_ms int) { p.offset_ms = C.int(offset_ms) } func (p *Params) SetDuration(duration_ms int) { p.duration_ms = C.int(duration_ms) } /////////////////////////////////////////////////////////////////////////////// // PRIVATE METHODS func toBool(v bool) C.bool { if v { return C.bool(true) } return C.bool(false) } /////////////////////////////////////////////////////////////////////////////// // STRINGIFY func (p *Params) String() string { str := "" }