reader

package
v0.2.13 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package reader owns application-wide read-aloud on the controller's UI thread: an assigned speech model's voice where one is usable, the OS speech otherwise.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chunks

func Chunks(text string, limit int) []string

Chunks splits text into parts of at most limit characters, each as long as its sentences allow, for a speech model that reads a bounded input. A sentence longer than limit is cut at a space, and one without spaces where the limit falls.

func Text

func Text(markdown string) string

Text preserves spoken words and code, without Markdown syntax or link targets.

Types

type Service

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

func New

func New(update func(func()), changed func()) *Service

New takes application-thread scheduling that remains usable without an open window. Speech is initialized lazily; creating the service emits no audio.

func (*Service) Active

func (s *Service) Active(id string) bool

func (*Service) Close

func (s *Service) Close() error

func (*Service) OnStarted

func (s *Service) OnStarted(started func(model bool))

OnStarted makes started hear, on the UI thread, of each reading that begins: with the model voice, or with the OS speech.

func (*Service) SetSynthesizer

func (s *Service) SetSynthesizer(synthesize Synthesizer)

SetSynthesizer makes read-aloud use a model's voice. Text the model does not read, because no speech model is assigned or the request or its playback failed, is read by the OS speech instead.

func (*Service) Stop

func (s *Service) Stop() error

func (*Service) Toggle

func (s *Service) Toggle(id, markdown string, failed func()) error

Toggle reads markdown aloud as id, or stops id when it is being read. failed reports, on the UI thread, OS speech that could not start after the model voice gave way to it; an error returned is one found at once.

type Synthesizer

type Synthesizer func(ctx context.Context, text string, voice *string) (string, []byte, error)

Synthesizer reads text aloud with a model and returns the audio's media type and bytes, as Client.SynthesizeSpeech does. A nil voice is the Node's default.

Jump to

Keyboard shortcuts

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