audiorecorder

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package audiorecorder records from the microphone to an AAC file, for a voice memo, say. Pause and Resume work, and the file comes back as bytes from Stop. For one spoken turn that ends by itself, see the audio plugin.

nimbus native plugin add audio-recorder

if ok, _ := audiorecorder.Request(ctx); ok {
	audiorecorder.Start(ctx)
}
r, err := audiorecorder.Stop(ctx)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cancel

func Cancel(ctx context.Context) error

Cancel ends it and throws it away.

func Pause

func Pause(ctx context.Context) error

Pause stops listening, keeping what's been recorded.

func Request

func Request(ctx context.Context) (bool, error)

Request asks to use the microphone, once.

func Resume

func Resume(ctx context.Context) error

Resume carries on after Pause.

func Start

func Start(ctx context.Context) error

Start begins recording, one at a time. Without permission it fails with plugin.Denied.

func Watch

func Watch(ctx context.Context, f func(Status)) error

Watch calls f about ten times a second until ctx ends. It blocks, so run it from a goroutine in an effect.

Types

type Recording

type Recording struct {
	Data    []byte  `json:"data"`    // the file
	Type    string  `json:"type"`    // its MIME type, "audio/mp4"
	Seconds float64 `json:"seconds"` // how long it runs
}

Recording is a finished recording.

func Stop

func Stop(ctx context.Context) (Recording, error)

Stop ends it and gives back the file.

type Status

type Status struct {
	Recording bool    `json:"recording"` // it's recording now, not paused
	Seconds   float64 `json:"seconds"`   // how much so far
	Level     float64 `json:"level"`     // how loud it is now, 0 to 1
}

Status is where it's got to.

func Current

func Current(ctx context.Context) (Status, error)

Current says where it's got to.

Jump to

Keyboard shortcuts

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