recorder.svelte.ts view source
(): RecorderDeps import {create_recorder_deps} from '@fuzdev/zzz/recorder.svelte.js'; RecorderDeps over the real browser, each global read when it's called.
returns
RecorderDeps 6 declarations
recorder.svelte.ts view source
(): RecorderDeps import {create_recorder_deps} from '@fuzdev/zzz/recorder.svelte.js'; RecorderDeps over the real browser, each global read when it's called.
RecorderDeps recorder.svelte.ts view source
import {Recorder} from '@fuzdev/zzz/recorder.svelte.js'; Records the microphone to a file on disk, uploading it as it's recorded.
App-level, so a recording carries on across route changes. capture owns
the microphone; this owns where the chunks go and what happens after. The
file is created under its final name and grows as chunks arrive
(ChunkUpload over the backend's byte routes), so a crashed tab loses at
most the last chunk; stopping uploads the rest and finalizes the file
(media_finalize) so it has a duration and seeks, then — with
transcribe_on_stop — queues its transcription.
Capture starts only in start, and only during a user gesture — nothing
the backend sends can open the microphone. active is true the whole time
it may be open and until the recording is saved, for the indicator every
page shows.
Cell<typeof RecorderJson>chunk_durationtype number
transcribe_on_stoptype boolean
capturetype AudioCapture
pathThe file being recorded to — set once it's created, cleared when the recording ends.
type DiskfilePath | null
last_pathThe last recording that stopped normally, whether or not it finalized.
type DiskfilePath | null
errorWhy the last start, recording, or stop failed — cleared by the next start.
type string | null
uploaded_bytesBytes of the current recording the backend has confirmed.
type number
statusWhere the recording is: the capture's status, and stopping until the file is saved.
type AudioCaptureStatus
activeWhether the microphone may be open or the recording is still being saved.
type boolean
constructortype new (options: RecorderOptions): Recorder
optionsstartStarts recording to a new file in dir, named for the current local
time. Must be called from a user gesture (a click handler).
type (dir: string & $brand<"DiskfilePath"> & $brand<"DiskfileDirectoryPath">): Promise<void>
dirthe directory to create the recording in
Promise<void>throws
Error - when one is already under way (leaving it and `error`
untouched), or when there's no backend to record to, no user gesture,
the browser can't record, the microphone can't be opened, or the file
can't be created — each of those also left in `error`pausePauses a recording: the microphone stays open, nothing is recorded.
type (): void
voidresumeResumes a paused recording.
type (): void
voidstopStops the recording: closes the microphone, uploads what's left, and
finalizes the file. A failure to upload or finalize is left in error
— the file is still there, as far as it got.
type (): Promise<(string & $brand<"DiskfilePath">) | null>
Promise<DiskfilePath | null>the recording's path, or null when nothing was being
recorded or the upload failed
disposeEnds the recording without finalizing — the session is gone. Chunks the uploader already holds, and the last one the browser hands over as it stops, are still sent.
type (): void
voiddurationHow long the current recording is so far — see AudioCapture.duration.
type number
levelHow loud the microphone is right now — see AudioCapture.level.
type number
depstype RecorderDeps
recorder.svelte.ts view source
RecorderDeps import type {RecorderDeps} from '@fuzdev/zzz/recorder.svelte.js'; The browser the recorder runs in — the microphone, and fetch for the
upload — so a test can stand in for both.
fetchtype (input: string, init?: RequestInit | undefined): Promise<Response>
inputstringinit?RequestInitPromise<Response>recorder.svelte.ts view source
value + type
{ id: string & $brand<"Uuid">; created: string & $brand<"Datetime">; updated: string & $brand<"Datetime">; chunk_duration: number; transcribe_on_stop: boolean; } import {RecorderJson} from '@fuzdev/zzz/recorder.svelte.js'; idtype string & $brand<"Uuid">
createdtype string & $brand<"Datetime">
updatedRequired and initially equal to created.
type string & $brand<"Datetime">
chunk_durationHow often the browser hands over a chunk to upload, in milliseconds — the most audio a crashed tab can lose.
type number
transcribe_on_stopWhether a recording is transcribed, by the local model, once it's saved.
type boolean
recorder.svelte.ts view source
{ id?: string | undefined; created?: string | undefined; updated?: string | undefined; chunk_duration?: number | undefined; transcribe_on_stop?: boolean | undefined; } import type {RecorderJsonInput} from '@fuzdev/zzz/recorder.svelte.js'; id?type string
created?type string
updated?Required and initially equal to created.
type string
chunk_duration?How often the browser hands over a chunk to upload, in milliseconds — the most audio a crashed tab can lose.
type number
transcribe_on_stop?Whether a recording is transcribed, by the local model, once it's saved.
type boolean
recorder.svelte.ts view source
RecorderOptions import type {RecorderOptions} from '@fuzdev/zzz/recorder.svelte.js'; CellOptions<typeof RecorderJson>deps?The browser to record with (default create_recorder_deps()).
type RecorderDeps