anki

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2026 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MediaPath

func MediaPath(profile string, goos string) (string, error)

MediaPath returns the Anki media path based on the profile name and the OS(runtime.GOOS)

func WriteCSVRecords

func WriteCSVRecords(w io.Writer, records []Record, stripCSVHeader, shuffle bool) error

WriteCSVRecords writes records into anki CSV file

Types

type Record

type Record struct {
	Text                           string
	HelperText                     string
	TextA, TextB, TextC, TextD     string
	AudioA, AudioB, AudioC, AudioD string
	AudioAnswer                    string
}

Record is how anki CSV file should look like

func ReadCSVRecords

func ReadCSVRecords(r io.Reader) ([]Record, error)

ReadCSVRecords reads records from anki CSV file

func (Record) CleanedText

func (r Record) CleanedText() string

CleanedText returns the cleaned text without "{{c1::}}"

func (Record) RandomizedRow

func (r Record) RandomizedRow() []string

RandomizedRow returns Record with shuffled order of TextA, TextB, TextC, TextD

func (Record) Row

func (r Record) Row() []string

Row returns Record in correct order

type RunConfig

type RunConfig struct {
	Speed          string
	Voice          string
	HelperLanguage string
	Deck           string
	Endpoint       string
	Shuffle        bool
	StripCSVHeader bool
	PrintOut       bool
}

RunConfig tells each run how to run

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner handles concurrent processing of synthesize operations

func NewRunner

func NewRunner(profile string, opts ...RunnerOption) (*Runner, error)

NewRunner creates a new Runner

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, reader io.Reader, c RunConfig) error

Run runs given opts concurrently and stops if encounters an error

type RunnerOption

type RunnerOption func(*Runner)

RunnerOption configures a Runner

func WithClient

func WithClient(c *http.Client) RunnerOption

WithClient sets the HTTP client

func WithMaxWorkers

func WithMaxWorkers(n int) RunnerOption

WithMaxWorkers sets the maximum number of concurrent workers

func WithSaveFunc

func WithSaveFunc(fn SaveFn) RunnerOption

WithSaveFunc sets custom save function

type SaveFn

type SaveFn func(filename string, audio []byte) error

SaveFn is function that allows additional save step for Runner's per run

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL