@seams/voice-capture 0.67.1 → 0.68.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,7 @@ configureVoiceCapture({ assetBase: '../assets/' });
9
9
  const ENROLLMENT_PHRASES = [
10
10
  'My voice is my signature for this wallet.',
11
11
  'I send money only when I say so.',
12
- 'Seams, please learn how I sound today.',
12
+ 'Please learn how I sound today.',
13
13
  ];
14
14
 
15
15
  const log = document.querySelector('#log');
@@ -18,7 +18,13 @@ const detector = () => (document.querySelector('#level').checked ? 'level' : 'mo
18
18
 
19
19
  /** Shows one sentence, records it and returns its WAV, or null when the person closed the card. */
20
20
  async function recordSentence(sentence, signal) {
21
- const surface = openPhraseCard({ sentence, signal, detector: detector(), frame: { parent } });
21
+ const surface = openPhraseCard({
22
+ sentence,
23
+ signal,
24
+ detector: detector(),
25
+ autoStart: document.querySelector('#auto').checked,
26
+ frame: { parent },
27
+ });
22
28
  try {
23
29
  const recording = await surface.record();
24
30
  if (recording.kind === 'cancelled') return null;
@@ -17,6 +17,7 @@
17
17
  <h1>voice-capture</h1>
18
18
  <p>This page uses only <code>@seams/voice-capture</code>. The audio stays in the page.</p>
19
19
  <label><input type="checkbox" id="level" /> Record with no model download (the detector <code>level</code>)</label>
20
+ <label><input type="checkbox" id="auto" /> Start the recording with no press on Record (<code>autoStart</code>)</label>
20
21
  <div class="row">
21
22
  <button class="start" id="sentence">Record one sentence</button>
22
23
  <button class="start" id="enroll">Record three enrollment phrases</button>
@@ -1,4 +1,4 @@
1
- export { openPhraseCard, type PhraseCardFrame, type PhraseCardInput } from './surface';
1
+ export { openPhraseCard, type PhraseCardControl, type PhraseCardControls, type PhraseCardFrame, type PhraseCardInput, } from './surface';
2
2
  export type { PhraseCheckView, PhraseChoice, PhraseRecording, PhraseResultView, PhraseSegmentState, PhraseSurface, PhraseText, PhraseView, } from './types';
3
3
  export { leaveSurface, VoicePrompt, type PhraseDisplay, type PromptChange } from './prompt';
4
4
  export { PhraseCard, type HandedOverRows, type PromptCopy } from './phraseCard';
@@ -46,10 +46,11 @@ export declare class VoicePrompt {
46
46
  /** The text to show for a phrase, such as the phrase with its commas. */
47
47
  display?: PhraseDisplay);
48
48
  /**
49
- * In an app's dialog with a step before this card, the corner control returns to that step.
50
- * It still ends the card as cancelled; the Wallet tells the app that the person went back.
49
+ * In an app's dialog with a step before this card, Back in the leading corner returns to that
50
+ * step. With `close`, Close stays in the trailing corner and ends the whole dialog; without it,
51
+ * Back takes Close's place. Each one ends the card as cancelled. The result is the Back control.
51
52
  */
52
- showBack(): void;
53
+ showBack(close: boolean): HTMLButtonElement;
53
54
  /**
54
55
  * Moves the rows to a new state. The rows whose content changes fade out together, take their
55
56
  * new content and fade in one after another; the other rows stay still. A change that comes
@@ -27,6 +27,8 @@ export declare class VoiceRibbon {
27
27
  private stopped;
28
28
  constructor(document: Document, checking?: VoiceCheckingStyle);
29
29
  readonly readLevel: () => number;
30
+ /** The voice line's width now: 1, or the theme's `voiceLineWidth`. */
31
+ private lineWidth;
30
32
  setPhase(phase: RibbonPhase): void;
31
33
  /**
32
34
  * Closes the ring into the success seal; resolves when the check is drawn.
@@ -0,0 +1,5 @@
1
+ export declare const ROW_OUT_MS = 150;
2
+ export declare const ROW_IN_MS = 200;
3
+ export declare const ROW_IN_DELAY_MS = 20;
4
+ export declare const ROW_STAGGER_MS = 30;
5
+ export declare const ROW_EASE = "cubic-bezier(0.2, 0, 0, 1)";
@@ -6,19 +6,35 @@ export type PhraseCardFrame = Readonly<{
6
6
  parent?: HTMLElement;
7
7
  /** More class names for the surface element, such as the host's theme class. */
8
8
  className?: string;
9
- /** Shows the Back control of the prompt. */
10
- back?: boolean;
9
+ /**
10
+ * The corner controls of the card. `close` (default): Close in the trailing corner. `back`: Back
11
+ * in the leading corner, in place of Close. `back_and_close`: both. Each one, and Escape, ends
12
+ * the card as cancelled.
13
+ */
14
+ controls?: PhraseCardControls;
15
+ /** Runs when the person presses Back or Close, before the card ends. Escape is not a press. */
16
+ pressed?(control: PhraseCardControl): void;
11
17
  /** The host sizes its frame to the surface, so the card follows the frame. */
12
18
  hugged?: boolean;
13
19
  /** Runs when the surface is in the document. Its return value runs when the surface closes. */
14
20
  mounted?(element: HTMLElement): (() => void) | void;
15
21
  }>;
22
+ /** The corner controls of a phrase card. */
23
+ export type PhraseCardControls = 'close' | 'back' | 'back_and_close';
24
+ /** One corner control of a phrase card. */
25
+ export type PhraseCardControl = 'back' | 'close';
16
26
  export type PhraseCardInput = Readonly<{
17
27
  sentence: string;
18
28
  signal: AbortSignal;
19
29
  frame?: PhraseCardFrame;
20
30
  /** The speech detector of the recordings. Default: `model`. */
21
31
  detector?: VoiceRecordingOptions['detector'];
32
+ /**
33
+ * The first recording starts when the caller asks for it, with no press on Record. Use it
34
+ * when the person just asked for this card, with a click or a key. If the browser does not
35
+ * start audio without a press, the card stays with its Record button.
36
+ */
37
+ autoStart?: boolean;
22
38
  }>;
23
39
  /**
24
40
  * Shows the given sentence in the prompt. The surface records clips with the quality check, and
@@ -1,5 +1,8 @@
1
+ import { type VoiceBeamColorVariant } from 'voice-glow';
1
2
  import type { VoiceActivityEvent } from '../microphone';
2
3
  import { type VoiceCheckingStyle } from './ribbon';
4
+ /** The theme's `voiceBeam`, the name of a Beam palette, or the default one. */
5
+ export declare function beamPalette(value: string): VoiceBeamColorVariant;
3
6
  /** Shared by enrollment, unlock and signing. The recorder remains the only audio owner. */
4
7
  export declare class VoiceVisual {
5
8
  readonly element: SVGSVGElement;
@@ -1,5 +1,5 @@
1
1
  export { configureVoiceCapture, type VoiceCaptureConfig, type VoiceMicrophonePreference, type VoiceMicrophonePreferenceStore, } from './config';
2
- export { recordVoice, requireVoiceForeground, requireVoiceUserAction, voiceQualityMessage, InsufficientVoiceAudioError, type VoiceActivityEvent, type VoiceCaptureEvent, type VoiceCaptureObserver, type VoiceCaptureQuality, type VoiceRecordingOptions, type VoiceRecordingResult, } from './microphone';
2
+ export { recordVoice, requireVoiceForeground, requireVoiceUserAction, voiceQualityMessage, InsufficientVoiceAudioError, VoiceUserActionNeededError, type VoiceActivityEvent, type VoiceCaptureEvent, type VoiceCaptureObserver, type VoiceCaptureQuality, type VoiceRecordingOptions, type VoiceRecordingResult, } from './microphone';
3
3
  export { openVoiceMicrophone, rememberVoiceMicrophone, useSystemVoiceMicrophone, VoiceMicrophoneInterruptedError, type VoiceMicrophone, } from './microphoneInput';
4
4
  export { endPauseMs, expectedSpeechMs } from './speechPause';
5
5
  export { createVoiceActivity, levelDetector, voiceActivityModel, type SpeechDetector, } from './voiceActivity';
@@ -73,6 +73,13 @@ export type VoiceRecordingOptions = Readonly<{
73
73
  export declare function requireVoiceUserAction(): void;
74
74
  /** Throws unless the page is visible and has the focus. */
75
75
  export declare function requireVoiceForeground(): void;
76
+ /**
77
+ * The browser starts audio only after the person acts on the page (a click or a key). A
78
+ * recording that starts by itself gets this error, and the caller then shows its Record control.
79
+ */
80
+ export declare class VoiceUserActionNeededError extends Error {
81
+ constructor();
82
+ }
76
83
  /**
77
84
  * Records one utterance at 16 kHz. The recording ends after a pause, or after 8 s. A recording
78
85
  * with less than 0.6 s of speech is `insufficient_audio`. The samples hold the speech with 0.2 s
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seams/voice-capture",
3
- "version": "0.67.1",
3
+ "version": "0.68.1",
4
4
  "type": "module",
5
5
  "description": "Records one spoken sentence in the browser, with speech detection, a quality check and a phrase card",
6
6
  "license": "Apache-2.0",