@adminide-stack/yantra-mobile 12.0.157 → 12.0.158

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.
@@ -0,0 +1,66 @@
1
+ import {ACTIONS_HEADING,SUGGESTION_ORDER,suggestionHeading}from'./kinds.js';import {medicationLine}from'./noteText.js';import {placeholderLabel}from'./privacy.js';const SPEECH_PIECE_CHARS = 1500;
2
+ const PLACEHOLDER = /\[[A-Z]+_\d+\]/g;
3
+ function spokenLabels(text) {
4
+ return text.replace(PLACEHOLDER, (token) => placeholderLabel(token));
5
+ }
6
+ function sentence(line) {
7
+ const text = line.trim();
8
+ if (!text) return "";
9
+ return /[.!?:;]$/.test(text) ? text : `${text}.`;
10
+ }
11
+ function heading(text) {
12
+ const lower = text.trim().toLowerCase();
13
+ return lower.charAt(0).toUpperCase() + lower.slice(1);
14
+ }
15
+ function answerForSpeech(text) {
16
+ return text.split("\n").map((line) => sentence(line.replace(/^\s*[-*•]\s+/, ""))).filter(Boolean).join("\n");
17
+ }
18
+ function noteForSpeech(note, suggestions) {
19
+ const lines = [sentence(note.title)];
20
+ const group = (title, items) => {
21
+ if (items.length) lines.push(sentence(heading(title)), ...items.map(sentence));
22
+ };
23
+ group("Check before you use", note.to_verify);
24
+ if (note.summary) lines.push(sentence(note.summary));
25
+ for (const section of note.sections) group(section.heading, section.items);
26
+ group(ACTIONS_HEADING[note.kind], note.actions);
27
+ group("Medications", note.medications.map(medicationLine));
28
+ if (suggestions == null ? void 0 : suggestions.length) {
29
+ lines.push("Suggestions.");
30
+ for (const kind of SUGGESTION_ORDER) {
31
+ group(suggestionHeading(kind, note.kind), suggestions.filter((s) => s.kind === kind).map((s) => s.text));
32
+ }
33
+ }
34
+ return lines.filter(Boolean).join("\n");
35
+ }
36
+ function sentencesOf(line, max) {
37
+ var _a;
38
+ const sentences = (_a = line.match(/[^.!?]+[.!?]+["')\]]*\s*|[^.!?]+$/g)) != null ? _a : [line];
39
+ return sentences.flatMap((s) => {
40
+ if (s.length <= max) return [s.trim()];
41
+ const words = s.trim().split(/\s+/);
42
+ const cut = [];
43
+ let current = "";
44
+ for (const word of words) {
45
+ if (current && current.length + word.length + 1 > max) {
46
+ cut.push(current);
47
+ current = word;
48
+ } else current = current ? `${current} ${word}` : word;
49
+ }
50
+ return current ? [...cut, current] : cut;
51
+ });
52
+ }
53
+ function splitForSpeech(text, max = SPEECH_PIECE_CHARS) {
54
+ const pieces = [];
55
+ let current = "";
56
+ const lines = text.split("\n").flatMap((line) => line.length > max ? sentencesOf(line, max) : [line]).map((line) => line.trim()).filter(Boolean);
57
+ for (const next of lines) {
58
+ if (current && current.length + next.length + 1 > max) {
59
+ pieces.push(current);
60
+ current = next;
61
+ } else current = current ? `${current}
62
+ ${next}` : next;
63
+ }
64
+ if (current) pieces.push(current);
65
+ return pieces;
66
+ }export{SPEECH_PIECE_CHARS,answerForSpeech,noteForSpeech,splitForSpeech,spokenLabels};//# sourceMappingURL=speechText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"speechText.js","sources":["../../../src/features/dictate/speechText.ts"],"sourcesContent":["/**\n * What Dictate says when it reads a note or an answer aloud: plain sentences in\n * the order the screen shows them, each placeholder spoken as its label\n * (\"Name 1\") or as what it stands for, split into pieces a voice takes at once\n * (the connector's voice 2,000 characters, Android's engine about 4,000).\n *\n * Pure: no native imports, so it runs under jest.\n */\nimport { ACTIONS_HEADING, SUGGESTION_ORDER, suggestionHeading } from './kinds';\nimport { medicationLine } from './noteText';\nimport { placeholderLabel } from './privacy';\nimport type { DictationNote, NoteSuggestion } from './types';\n\n/** Short enough for every voice, long enough that a note is a handful of pieces. */\nexport const SPEECH_PIECE_CHARS = 1500;\n\nconst PLACEHOLDER = /\\[[A-Z]+_\\d+\\]/g;\n\n/** Each placeholder read as its label: \"[NAME_1]\" -> \"Name 1\". */\nexport function spokenLabels(text: string): string {\n return text.replace(PLACEHOLDER, (token) => placeholderLabel(token));\n}\n\n/** A line read as a sentence: a heading or a list item without a full stop gets one, so the voice pauses. */\nfunction sentence(line: string): string {\n const text = line.trim();\n if (!text) return '';\n return /[.!?:;]$/.test(text) ? text : `${text}.`;\n}\n\n/** \"TO DO\" -> \"To do\", \"KEY IDEAS\" -> \"Key ideas\": a heading spoken, not shouted. */\nfunction heading(text: string): string {\n const lower = text.trim().toLowerCase();\n return lower.charAt(0).toUpperCase() + lower.slice(1);\n}\n\n/** An answer as speech: list markers dropped (numbers kept), each line its own sentence. */\nexport function answerForSpeech(text: string): string {\n return text\n .split('\\n')\n .map((line) => sentence(line.replace(/^\\s*[-*•]\\s+/, '')))\n .filter(Boolean)\n .join('\\n');\n}\n\n/** The note as speech: title, what to check, summary, sections, tasks, medications, suggestions. Never the transcript. */\nexport function noteForSpeech(note: DictationNote, suggestions?: NoteSuggestion[] | null): string {\n const lines: string[] = [sentence(note.title)];\n const group = (title: string, items: string[]) => {\n if (items.length) lines.push(sentence(heading(title)), ...items.map(sentence));\n };\n group('Check before you use', note.to_verify);\n if (note.summary) lines.push(sentence(note.summary));\n for (const section of note.sections) group(section.heading, section.items);\n group(ACTIONS_HEADING[note.kind], note.actions);\n group('Medications', note.medications.map(medicationLine));\n if (suggestions?.length) {\n lines.push('Suggestions.');\n for (const kind of SUGGESTION_ORDER) {\n group(\n suggestionHeading(kind, note.kind),\n suggestions.filter((s) => s.kind === kind).map((s) => s.text),\n );\n }\n }\n return lines.filter(Boolean).join('\\n');\n}\n\n/** Sentences of a line too long for one piece; a sentence still too long is cut between words. */\nfunction sentencesOf(line: string, max: number): string[] {\n const sentences = line.match(/[^.!?]+[.!?]+[\"')\\]]*\\s*|[^.!?]+$/g) ?? [line];\n return sentences.flatMap((s) => {\n if (s.length <= max) return [s.trim()];\n const words = s.trim().split(/\\s+/);\n const cut: string[] = [];\n let current = '';\n for (const word of words) {\n if (current && current.length + word.length + 1 > max) {\n cut.push(current);\n current = word;\n } else current = current ? `${current} ${word}` : word;\n }\n return current ? [...cut, current] : cut;\n });\n}\n\n/** The text in pieces of at most `max` characters, breaking between lines, else between sentences. */\nexport function splitForSpeech(text: string, max = SPEECH_PIECE_CHARS): string[] {\n const pieces: string[] = [];\n let current = '';\n const lines = text\n .split('\\n')\n .flatMap((line) => (line.length > max ? sentencesOf(line, max) : [line]))\n .map((line) => line.trim())\n .filter(Boolean);\n for (const next of lines) {\n if (current && current.length + next.length + 1 > max) {\n pieces.push(current);\n current = next;\n } else current = current ? `${current}\\n${next}` : next;\n }\n if (current) pieces.push(current);\n return pieces;\n}\n"],"names":[],"mappings":"mKAcO,MAAM,kBAAqB,GAAA;AAClC,MAAM,WAAc,GAAA,iBAAA;AAGb,SAAS,aAAa,IAAsB,EAAA;AACjD,EAAA,OAAO,KAAK,OAAQ,CAAA,WAAA,EAAa,CAAS,KAAA,KAAA,gBAAA,CAAiB,KAAK,CAAC,CAAA;AACnE;AAGA,SAAS,SAAS,IAAsB,EAAA;AACtC,EAAM,MAAA,IAAA,GAAO,KAAK,IAAK,EAAA;AACvB,EAAI,IAAA,CAAC,MAAa,OAAA,EAAA;AAClB,EAAA,OAAO,WAAW,IAAK,CAAA,IAAI,CAAI,GAAA,IAAA,GAAO,GAAG,IAAI,CAAA,CAAA,CAAA;AAC/C;AAGA,SAAS,QAAQ,IAAsB,EAAA;AACrC,EAAA,MAAM,KAAQ,GAAA,IAAA,CAAK,IAAK,EAAA,CAAE,WAAY,EAAA;AACtC,EAAO,OAAA,KAAA,CAAM,OAAO,CAAC,CAAA,CAAE,aAAgB,GAAA,KAAA,CAAM,MAAM,CAAC,CAAA;AACtD;AAGO,SAAS,gBAAgB,IAAsB,EAAA;AACpD,EAAA,OAAO,KAAK,KAAM,CAAA,IAAI,EAAE,GAAI,CAAA,CAAA,IAAA,KAAQ,SAAS,IAAK,CAAA,OAAA,CAAQ,cAAgB,EAAA,EAAE,CAAC,CAAC,CAAA,CAAE,OAAO,OAAO,CAAA,CAAE,KAAK,IAAI,CAAA;AAC3G;AAGgB,SAAA,aAAA,CAA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AAA,IAAA,CAAK,IAAK,EAAC,CAAE,CAAA,MAAA,CAAO,OAAO,CAAA;AAC3I,EAAA,KAAA,MAAW,QAAQ,KAAO,EAAA;AACxB,IAAA,IAAI,WAAW,OAAQ,CAAA,MAAA,GAAS,IAAK,CAAA,MAAA,GAAS,IAAI,GAAK,EAAA;AACrD,MAAA,MAAA,CAAO,KAAK,OAAO,CAAA;AACnB,MAAU,OAAA,GAAA,IAAA;AAAA,KACL,MAAA,OAAA,GAAU,OAAU,GAAA,CAAA,EAAG,OAAO;AAAA,EAAK,IAAI,CAAK,CAAA,GAAA,IAAA;AAAA;AAErD,EAAI,IAAA,OAAA,EAAgB,MAAA,CAAA,IAAA,CAAK,OAAO,CAAA;AAChC,EAAO,OAAA,MAAA;AACT"}
@@ -1,4 +1,4 @@
1
- import {useState,useRef,useMemo,useCallback,useEffect}from'react';import {AppState}from'react-native';import {useAudioRecorder,useAudioRecorderState,setAudioModeAsync,requestRecordingPermissionsAsync,setIsAudioActiveAsync,RecordingPresets,AudioQuality,IOSOutputFormat}from'expo-audio';import {deactivateKeepAwake,activateKeepAwakeAsync}from'expo-keep-awake';import {backgroundRecordingNative,BACKGROUND_NOTICE}from'./backgroundRecording.js';var __defProp = Object.defineProperty;
1
+ import {useState,useRef,useMemo,useCallback,useEffect}from'react';import {Platform,AppState}from'react-native';import {useAudioRecorder,useAudioRecorderState,setAudioModeAsync,requestRecordingPermissionsAsync,setIsAudioActiveAsync,RecordingPresets,AudioQuality,IOSOutputFormat}from'expo-audio';import {deactivateKeepAwake,activateKeepAwakeAsync}from'expo-keep-awake';import {backgroundRecordingNative,BACKGROUND_NOTICE}from'./backgroundRecording.js';import {readMicPreference,writeMicPreference}from'./dictatePreference.js';import {micsOf,chooseMic,otherMic,micOf}from'./micInput.js';var __defProp = Object.defineProperty;
2
2
  var __defProps = Object.defineProperties;
3
3
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
4
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
@@ -34,6 +34,11 @@ const DICTATION_RECORDING = __spreadProps(__spreadValues({}, RecordingPresets.HI
34
34
  });
35
35
  const MAX_DICTATION_MS = 60 * 6e4;
36
36
  const KEEP_AWAKE_TAG = "yantra-dictate";
37
+ const MIC_CHECK_MS = 2e3;
38
+ function phoneWord() {
39
+ if (Platform.OS !== "ios") return "Phone";
40
+ return Platform.isPad ? "iPad" : "iPhone";
41
+ }
37
42
  function levelFromMetering(db) {
38
43
  if (typeof db !== "number" || !Number.isFinite(db)) return 0;
39
44
  return Math.min(1, Math.max(0, (db + 60) / 60));
@@ -86,7 +91,35 @@ function useDictationRecorder() {
86
91
  phaseRef.current = phase;
87
92
  const background = useMemo(() => backgroundRecordingNative(), []);
88
93
  const inBackgroundRef = useRef(false);
94
+ const [mic, setMic] = useState(null);
95
+ const [mics, setMics] = useState([]);
96
+ const [micLost, setMicLost] = useState(null);
97
+ const micRef = useRef(null);
98
+ micRef.current = mic;
99
+ const micsRef = useRef([]);
100
+ micsRef.current = mics;
101
+ const listMics = useCallback(() => {
102
+ try {
103
+ return micsOf(recorder.getAvailableInputs(), phoneWord());
104
+ } catch (e) {
105
+ return [];
106
+ }
107
+ }, [recorder]);
108
+ const selectMic = useCallback((next) => {
109
+ try {
110
+ recorder.setInput(next.uid);
111
+ return true;
112
+ } catch (e) {
113
+ return false;
114
+ }
115
+ }, [recorder]);
89
116
  const releaseSession = useCallback(async () => {
117
+ var _a;
118
+ const phoneMic = micsRef.current.find((m) => m.kind === "phone");
119
+ if (Platform.OS === "android" && ((_a = micRef.current) == null ? void 0 : _a.kind) === "headset" && phoneMic) selectMic(phoneMic);
120
+ setMic(null);
121
+ setMics([]);
122
+ setMicLost(null);
90
123
  if (inBackgroundRef.current) await (background == null ? void 0 : background.stop().catch(() => void 0));
91
124
  inBackgroundRef.current = false;
92
125
  await deactivateKeepAwake(KEEP_AWAKE_TAG).catch(() => void 0);
@@ -95,7 +128,7 @@ function useDictationRecorder() {
95
128
  playsInSilentMode: true,
96
129
  shouldPlayInBackground: false
97
130
  }).catch(() => void 0);
98
- }, [background]);
131
+ }, [background, selectMic]);
99
132
  const pause = useCallback((reason = "user") => {
100
133
  if (phaseRef.current !== "recording") return;
101
134
  recorder.pause();
@@ -113,6 +146,12 @@ function useDictationRecorder() {
113
146
  shouldPlayInBackground: inBackgroundRef.current
114
147
  });
115
148
  await recorder.prepareToRecordAsync();
149
+ const available = listMics();
150
+ const chosen = chooseMic(available, await readMicPreference());
151
+ if (chosen && available.length > 1) selectMic(chosen);
152
+ setMics(available);
153
+ setMic(chosen);
154
+ setMicLost(null);
116
155
  recorder.record();
117
156
  } catch (err) {
118
157
  await releaseSession();
@@ -121,7 +160,16 @@ function useDictationRecorder() {
121
160
  if (!inBackgroundRef.current) await activateKeepAwakeAsync(KEEP_AWAKE_TAG).catch(() => void 0);
122
161
  setPhase("recording");
123
162
  setPauseReason(null);
124
- }, [recorder, background, releaseSession]);
163
+ }, [recorder, background, releaseSession, listMics, selectMic]);
164
+ const switchMic = useCallback(() => {
165
+ const available = listMics();
166
+ const next = otherMic(available, micRef.current);
167
+ if (!next || !selectMic(next)) return;
168
+ setMics(available);
169
+ setMic(next);
170
+ setMicLost(null);
171
+ writeMicPreference(next.kind);
172
+ }, [listMics, selectMic]);
125
173
  const resume = useCallback(async () => {
126
174
  if (phaseRef.current !== "paused") return;
127
175
  await setIsAudioActiveAsync(true).catch(() => void 0);
@@ -156,6 +204,22 @@ function useDictationRecorder() {
156
204
  useEffect(() => {
157
205
  if (phase === "recording" && state.durationMillis >= MAX_DICTATION_MS) pause("limit");
158
206
  }, [phase, state.durationMillis, pause]);
207
+ useEffect(() => {
208
+ if (phase !== "recording") return void 0;
209
+ const id = setInterval(() => {
210
+ void Promise.resolve().then(() => recorder.getCurrentInput()).then((input) => {
211
+ const heard = micOf(input, phoneWord());
212
+ const was = micRef.current;
213
+ const now = listMics();
214
+ const uids = (list) => list.map((m) => m.uid).join(" ");
215
+ if (uids(now) !== uids(micsRef.current)) setMics(now);
216
+ if (!was || heard.uid === was.uid) return;
217
+ setMicLost(was.kind === "headset" && heard.kind === "phone" ? was.label : null);
218
+ setMic(heard);
219
+ }).catch(() => void 0);
220
+ }, MIC_CHECK_MS);
221
+ return () => clearInterval(id);
222
+ }, [phase, recorder, listMics]);
159
223
  const signalAtRef = useRef(0);
160
224
  useEffect(() => {
161
225
  if (phase !== "recording" || carriesSignal(state.metering) || state.durationMillis < signalAtRef.current) {
@@ -188,9 +252,16 @@ function useDictationRecorder() {
188
252
  noInput,
189
253
  /** This binary keeps a dictation recording with the phone locked or another app open. */
190
254
  recordsInBackground: (background == null ? void 0 : background.supported) === true,
255
+ /** The microphone the dictation is recording from, once it started. */
256
+ mic,
257
+ /** The other microphone it can switch to (AirPods <-> the phone's), if one is connected. */
258
+ otherMic: otherMic(mics, mic),
259
+ /** The headset that went away mid-dictation, while the phone's microphone carries on. */
260
+ micLost,
261
+ switchMic,
191
262
  start,
192
263
  pause: () => pause("user"),
193
264
  resume,
194
265
  finish
195
266
  };
196
- }export{DICTATION_RECORDING,MAX_DICTATION_MS,MicrophoneDeniedError,NO_INPUT_WARN_MS,backgroundActivityText,carriesSignal,levelFromMetering,useDictationRecorder};//# sourceMappingURL=useDictationRecorder.js.map
267
+ }export{DICTATION_RECORDING,MAX_DICTATION_MS,MIC_CHECK_MS,MicrophoneDeniedError,NO_INPUT_WARN_MS,backgroundActivityText,carriesSignal,levelFromMetering,useDictationRecorder};//# sourceMappingURL=useDictationRecorder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDictationRecorder.js","sources":["../../../src/features/dictate/useDictationRecorder.ts"],"sourcesContent":["/**\n * The dictation recorder: mono AAC at 64 kbps (speech, about 0.5 MB a minute),\n * pause and resume, and a live level.\n *\n * A binary with the background-recording module keeps recording when Yantra\n * leaves the screen or the phone locks, like a call, and on iOS shows it on the\n * lock screen and in the Dynamic Island meanwhile (backgroundRecording.ts).\n * An older binary cannot: iOS stops the microphone there, so the recorder\n * keeps the screen awake, pauses itself when the app leaves the screen, and\n * says so. Either way, a call or another app taking the microphone pauses the\n * dictation and says why, instead of recording nothing under a running timer.\n */\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { AppState } from 'react-native';\nimport {\n AudioQuality,\n IOSOutputFormat,\n RecordingPresets,\n requestRecordingPermissionsAsync,\n setAudioModeAsync,\n setIsAudioActiveAsync,\n useAudioRecorder,\n useAudioRecorderState,\n type RecordingOptions,\n} from 'expo-audio';\nimport { activateKeepAwakeAsync, deactivateKeepAwake } from 'expo-keep-awake';\nimport { BACKGROUND_NOTICE, backgroundRecordingNative } from './backgroundRecording';\n\nexport const DICTATION_RECORDING: RecordingOptions = {\n ...RecordingPresets.HIGH_QUALITY,\n extension: '.m4a',\n sampleRate: 44100,\n numberOfChannels: 1,\n bitRate: 64000,\n isMeteringEnabled: true,\n ios: {\n ...RecordingPresets.HIGH_QUALITY.ios,\n outputFormat: IOSOutputFormat.MPEG4AAC,\n audioQuality: AudioQuality.HIGH,\n },\n android: {\n ...RecordingPresets.HIGH_QUALITY.android,\n outputFormat: 'mpeg4',\n audioEncoder: 'aac',\n },\n};\n\n/** One visit is well under this; past it the recording pauses and asks to be finished. */\nexport const MAX_DICTATION_MS = 60 * 60_000;\nconst KEEP_AWAKE_TAG = 'yantra-dictate';\n\nexport type RecorderPhase = 'idle' | 'recording' | 'paused';\nexport type PauseReason = 'user' | 'background' | 'interrupted' | 'limit' | null;\n\n/** -60 dB (silence) .. 0 dB (loud) mapped to 0..1. */\nexport function levelFromMetering(db: number | undefined): number {\n if (typeof db !== 'number' || !Number.isFinite(db)) return 0;\n return Math.min(1, Math.max(0, (db + 60) / 60));\n}\n\n/**\n * Below this the microphone carries no signal at all (iOS reports -120 to\n * -160 dB): it is blocked, taken by another app, or failed to start. A quiet\n * room still reads about -50 dB, so silence between sentences never trips it.\n */\nconst NO_SIGNAL_DB = -100;\n/** How long a running recording may carry no signal before the clinician is told. */\nexport const NO_INPUT_WARN_MS = 4000;\n\n/** False only for a metering reading that shows no signal; no reading at all says nothing either way. */\nexport function carriesSignal(db: number | undefined): boolean {\n return typeof db !== 'number' || !Number.isFinite(db) || db > NO_SIGNAL_DB;\n}\n\n/** The Live Activity's words for where the dictation stands; nothing once it is done. */\nexport function backgroundActivityText(\n phase: RecorderPhase,\n pauseReason: PauseReason,\n noInput: boolean,\n): { title: string; detail: string } | null {\n if (phase === 'idle') return null;\n if (phase === 'recording') {\n return noInput\n ? { title: BACKGROUND_NOTICE.title, detail: 'No sound is reaching the microphone. Open Yantra to check.' }\n : { title: BACKGROUND_NOTICE.title, detail: BACKGROUND_NOTICE.text };\n }\n if (pauseReason === 'interrupted') {\n return {\n title: 'Paused for a call',\n detail: 'A call or another app took the microphone. Open Yantra to resume.',\n };\n }\n if (pauseReason === 'limit') {\n return {\n title: 'Paused at one hour',\n detail: 'An hour is the most one dictation holds. Open Yantra to write the note.',\n };\n }\n return { title: 'Paused', detail: 'Open Yantra to resume or finish the dictation.' };\n}\n\nexport class MicrophoneDeniedError extends Error {\n constructor() {\n super('Microphone access was declined. Allow it in Settings to dictate.');\n this.name = 'MicrophoneDeniedError';\n }\n}\n\nexport function useDictationRecorder() {\n const recorder = useAudioRecorder(DICTATION_RECORDING);\n const state = useAudioRecorderState(recorder, 100);\n const [phase, setPhase] = useState<RecorderPhase>('idle');\n const [pauseReason, setPauseReason] = useState<PauseReason>(null);\n const phaseRef = useRef<RecorderPhase>('idle');\n phaseRef.current = phase;\n const background = useMemo(() => backgroundRecordingNative(), []);\n /** This dictation keeps recording when Yantra leaves the screen. */\n const inBackgroundRef = useRef(false);\n\n const releaseSession = useCallback(async () => {\n if (inBackgroundRef.current) await background?.stop().catch(() => undefined);\n inBackgroundRef.current = false;\n await deactivateKeepAwake(KEEP_AWAKE_TAG).catch(() => undefined);\n // The rest of the app's audio (chat voice notes) does not play on in the background.\n await setAudioModeAsync({\n allowsRecording: false,\n playsInSilentMode: true,\n shouldPlayInBackground: false,\n }).catch(() => undefined);\n }, [background]);\n\n const pause = useCallback(\n (reason: Exclude<PauseReason, null> = 'user') => {\n if (phaseRef.current !== 'recording') return;\n recorder.pause();\n setPhase('paused');\n setPauseReason(reason);\n },\n [recorder],\n );\n\n const start = useCallback(async () => {\n const permission = await requestRecordingPermissionsAsync();\n if (!permission.granted) throw new MicrophoneDeniedError();\n // Android's microphone service has to be running before Yantra leaves the screen, and\n // may only start while it is on it: now. A refusal means pausing on leave, as before.\n inBackgroundRef.current = background?.supported\n ? await background.start(BACKGROUND_NOTICE.title, BACKGROUND_NOTICE.text).then(\n () => true,\n () => false,\n )\n : false;\n try {\n await setAudioModeAsync({\n allowsRecording: true,\n playsInSilentMode: true,\n shouldPlayInBackground: inBackgroundRef.current,\n });\n await recorder.prepareToRecordAsync();\n recorder.record();\n } catch (err) {\n await releaseSession();\n throw err;\n }\n // Without background recording the screen must stay on, or the microphone stops.\n if (!inBackgroundRef.current) await activateKeepAwakeAsync(KEEP_AWAKE_TAG).catch(() => undefined);\n setPhase('recording');\n setPauseReason(null);\n }, [recorder, background, releaseSession]);\n\n const resume = useCallback(async () => {\n if (phaseRef.current !== 'paused') return;\n // A call or another app deactivated the audio session; recording needs it back.\n await setIsAudioActiveAsync(true).catch(() => undefined);\n recorder.record();\n setPhase('recording');\n setPauseReason(null);\n }, [recorder]);\n\n /** Ends the recording; resolves to its file (in the recorder's cache - move it before anything else). */\n const finish = useCallback(async (): Promise<{ uri: string; durationMs: number } | null> => {\n if (phaseRef.current === 'idle') return null;\n const durationMs = recorder.getStatus().durationMillis;\n await recorder.stop();\n setPhase('idle');\n setPauseReason(null);\n await releaseSession();\n return recorder.uri ? { uri: recorder.uri, durationMs } : null;\n }, [recorder, releaseSession]);\n\n // Without background recording the microphone stops when the app leaves the screen: pause, and say so.\n useEffect(() => {\n const sub = AppState.addEventListener('change', (next) => {\n if (next !== 'active' && !inBackgroundRef.current) pause('background');\n });\n return () => sub.remove();\n }, [pause]);\n\n // A call or another app took the microphone. Nothing is recorded from here, though\n // expo-audio's timer would keep running: pause, and stay paused until the clinician resumes.\n useEffect(() => {\n const sub = background?.addListener('onInterruption', (event) => {\n if (event.state === 'began') pause('interrupted');\n });\n return () => sub?.remove();\n }, [background, pause]);\n\n useEffect(() => {\n if (phase === 'recording' && state.durationMillis >= MAX_DICTATION_MS) pause('limit');\n }, [phase, state.durationMillis, pause]);\n\n // Recording time at which the microphone last carried a signal. A paused or idle recorder\n // starts the count again, so Resume gets a fresh few seconds; so does a new recording,\n // whose time restarts below the last one's.\n const signalAtRef = useRef(0);\n useEffect(() => {\n if (phase !== 'recording' || carriesSignal(state.metering) || state.durationMillis < signalAtRef.current) {\n signalAtRef.current = state.durationMillis;\n }\n }, [phase, state.durationMillis, state.metering]);\n // Without this a dead microphone records a whole visit of silence, timer running.\n const noInput =\n phase === 'recording' &&\n !carriesSignal(state.metering) &&\n state.durationMillis - signalAtRef.current >= NO_INPUT_WARN_MS;\n\n // The lock screen and the Dynamic Island follow the dictation while it records in the background (iOS).\n const activity = backgroundActivityText(phase, pauseReason, noInput);\n const activityTitle = activity?.title;\n const activityDetail = activity?.detail;\n useEffect(() => {\n if (!activityTitle || !activityDetail || !inBackgroundRef.current || !background?.update) return;\n void background\n .update({\n title: activityTitle,\n detail: activityDetail,\n recording: phase === 'recording',\n recordedMs: recorder.getStatus().durationMillis,\n noSound: noInput,\n })\n .catch(() => undefined);\n }, [activityTitle, activityDetail, phase, noInput, background, recorder]);\n\n // Leaving the screen mid-dictation stops the microphone and lets the screen sleep.\n useEffect(\n () => () => {\n if (phaseRef.current !== 'idle') void recorder.stop().catch(() => undefined);\n void releaseSession();\n },\n [recorder, releaseSession],\n );\n\n return {\n phase,\n pauseReason,\n elapsedMs: state.durationMillis,\n level: phase === 'recording' ? levelFromMetering(state.metering) : 0,\n noInput,\n /** This binary keeps a dictation recording with the phone locked or another app open. */\n recordsInBackground: background?.supported === true,\n start,\n pause: () => pause('user'),\n resume,\n finish,\n };\n}\n"],"names":[],"mappings":";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,MAAM,MAAS,CAAA;AAC3E,IAAA,KAAK,cAAe,EAAA;AAAA,GACnB,EAAA,CAAC,QAAU,EAAA,cAAc,CAAC,CAAA;AAC7B,EAAO,OAAA;AAAA,IACL,KAAA;AAAA,IACA,WAAA;AAAA,IACA,WAAW,KAAM,CAAA,cAAA;AAAA,IACjB,OAAO,KAAU,KAAA,WAAA,GAAc,iBAAkB,CAAA,KAAA,CAAM,QAAQ,CAAI,GAAA,CAAA;AAAA,IACnE,OAAA;AAAA;AAAA,IAEA,mBAAA,EAAA,CAAqB,yCAAY,SAAc,MAAA,IAAA;AAAA,IAC/C,KAAA;AAAA,IACA,KAAA,EAAO,MAAM,KAAA,CAAM,MAAM,CAAA;AAAA,IACzB,MAAA;AAAA,IACA;AAAA,GACF;AACF"}
1
+ {"version":3,"file":"useDictationRecorder.js","sources":["../../../src/features/dictate/useDictationRecorder.ts"],"sourcesContent":["/**\n * The dictation recorder: mono AAC at 64 kbps (speech, about 0.5 MB a minute),\n * pause and resume, and a live level.\n *\n * A binary with the background-recording module keeps recording when Yantra\n * leaves the screen or the phone locks, like a call, and on iOS shows it on the\n * lock screen and in the Dynamic Island meanwhile (backgroundRecording.ts).\n * An older binary cannot: iOS stops the microphone there, so the recorder\n * keeps the screen awake, pauses itself when the app leaves the screen, and\n * says so. Either way, a call or another app taking the microphone pauses the\n * dictation and says why, instead of recording nothing under a running timer.\n *\n * With AirPods or another headset connected, the dictation records through them\n * unless the person chose the phone's microphone (micInput.ts); either can be\n * switched to mid-dictation. A headset that goes away mid-dictation (taken\n * out, battery flat) leaves the recording running on the phone's microphone,\n * and the screen says so. On Android the headset microphone is let go when the\n * dictation ends, or it would keep the AirPods in call mode.\n */\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { AppState, Platform } from 'react-native';\nimport {\n AudioQuality,\n IOSOutputFormat,\n RecordingPresets,\n requestRecordingPermissionsAsync,\n setAudioModeAsync,\n setIsAudioActiveAsync,\n useAudioRecorder,\n useAudioRecorderState,\n type RecordingOptions,\n} from 'expo-audio';\nimport { activateKeepAwakeAsync, deactivateKeepAwake } from 'expo-keep-awake';\nimport { BACKGROUND_NOTICE, backgroundRecordingNative } from './backgroundRecording';\nimport { readMicPreference, writeMicPreference } from './dictatePreference';\nimport { chooseMic, micOf, micsOf, otherMic, type Mic } from './micInput';\n\nexport const DICTATION_RECORDING: RecordingOptions = {\n ...RecordingPresets.HIGH_QUALITY,\n extension: '.m4a',\n sampleRate: 44100,\n numberOfChannels: 1,\n bitRate: 64000,\n isMeteringEnabled: true,\n ios: {\n ...RecordingPresets.HIGH_QUALITY.ios,\n outputFormat: IOSOutputFormat.MPEG4AAC,\n audioQuality: AudioQuality.HIGH,\n },\n android: {\n ...RecordingPresets.HIGH_QUALITY.android,\n outputFormat: 'mpeg4',\n audioEncoder: 'aac',\n },\n};\n\n/** One visit is well under this; past it the recording pauses and asks to be finished. */\nexport const MAX_DICTATION_MS = 60 * 60_000;\nconst KEEP_AWAKE_TAG = 'yantra-dictate';\n/** How often a running dictation checks which microphone it is hearing (a headset can go away). */\nexport const MIC_CHECK_MS = 2000;\n\n/** What the phone's own microphone is called on this device. */\nfunction phoneWord(): string {\n if (Platform.OS !== 'ios') return 'Phone';\n return (Platform as { isPad?: boolean }).isPad ? 'iPad' : 'iPhone';\n}\n\nexport type RecorderPhase = 'idle' | 'recording' | 'paused';\nexport type PauseReason = 'user' | 'background' | 'interrupted' | 'limit' | null;\n\n/** -60 dB (silence) .. 0 dB (loud) mapped to 0..1. */\nexport function levelFromMetering(db: number | undefined): number {\n if (typeof db !== 'number' || !Number.isFinite(db)) return 0;\n return Math.min(1, Math.max(0, (db + 60) / 60));\n}\n\n/**\n * Below this the microphone carries no signal at all (iOS reports -120 to\n * -160 dB): it is blocked, taken by another app, or failed to start. A quiet\n * room still reads about -50 dB, so silence between sentences never trips it.\n */\nconst NO_SIGNAL_DB = -100;\n/** How long a running recording may carry no signal before the clinician is told. */\nexport const NO_INPUT_WARN_MS = 4000;\n\n/** False only for a metering reading that shows no signal; no reading at all says nothing either way. */\nexport function carriesSignal(db: number | undefined): boolean {\n return typeof db !== 'number' || !Number.isFinite(db) || db > NO_SIGNAL_DB;\n}\n\n/** The Live Activity's words for where the dictation stands; nothing once it is done. */\nexport function backgroundActivityText(\n phase: RecorderPhase,\n pauseReason: PauseReason,\n noInput: boolean,\n): { title: string; detail: string } | null {\n if (phase === 'idle') return null;\n if (phase === 'recording') {\n return noInput\n ? { title: BACKGROUND_NOTICE.title, detail: 'No sound is reaching the microphone. Open Yantra to check.' }\n : { title: BACKGROUND_NOTICE.title, detail: BACKGROUND_NOTICE.text };\n }\n if (pauseReason === 'interrupted') {\n return {\n title: 'Paused for a call',\n detail: 'A call or another app took the microphone. Open Yantra to resume.',\n };\n }\n if (pauseReason === 'limit') {\n return {\n title: 'Paused at one hour',\n detail: 'An hour is the most one dictation holds. Open Yantra to write the note.',\n };\n }\n return { title: 'Paused', detail: 'Open Yantra to resume or finish the dictation.' };\n}\n\nexport class MicrophoneDeniedError extends Error {\n constructor() {\n super('Microphone access was declined. Allow it in Settings to dictate.');\n this.name = 'MicrophoneDeniedError';\n }\n}\n\nexport function useDictationRecorder() {\n const recorder = useAudioRecorder(DICTATION_RECORDING);\n const state = useAudioRecorderState(recorder, 100);\n const [phase, setPhase] = useState<RecorderPhase>('idle');\n const [pauseReason, setPauseReason] = useState<PauseReason>(null);\n const phaseRef = useRef<RecorderPhase>('idle');\n phaseRef.current = phase;\n const background = useMemo(() => backgroundRecordingNative(), []);\n /** This dictation keeps recording when Yantra leaves the screen. */\n const inBackgroundRef = useRef(false);\n const [mic, setMic] = useState<Mic | null>(null);\n const [mics, setMics] = useState<Mic[]>([]);\n /** The headset this dictation was recording through until it went away. */\n const [micLost, setMicLost] = useState<string | null>(null);\n const micRef = useRef<Mic | null>(null);\n micRef.current = mic;\n const micsRef = useRef<Mic[]>([]);\n micsRef.current = mics;\n\n // The recorder lists and switches inputs only once prepared; an older binary may not offer it at all.\n const listMics = useCallback((): Mic[] => {\n try {\n return micsOf(recorder.getAvailableInputs(), phoneWord());\n } catch {\n return [];\n }\n }, [recorder]);\n const selectMic = useCallback(\n (next: Mic): boolean => {\n try {\n recorder.setInput(next.uid);\n return true;\n } catch {\n return false;\n }\n },\n [recorder],\n );\n\n const releaseSession = useCallback(async () => {\n // Android keeps a Bluetooth headset in call mode while its microphone is selected: let it go.\n const phoneMic = micsRef.current.find((m) => m.kind === 'phone');\n if (Platform.OS === 'android' && micRef.current?.kind === 'headset' && phoneMic) selectMic(phoneMic);\n setMic(null);\n setMics([]);\n setMicLost(null);\n if (inBackgroundRef.current) await background?.stop().catch(() => undefined);\n inBackgroundRef.current = false;\n await deactivateKeepAwake(KEEP_AWAKE_TAG).catch(() => undefined);\n // The rest of the app's audio (chat voice notes) does not play on in the background.\n await setAudioModeAsync({\n allowsRecording: false,\n playsInSilentMode: true,\n shouldPlayInBackground: false,\n }).catch(() => undefined);\n }, [background, selectMic]);\n\n const pause = useCallback(\n (reason: Exclude<PauseReason, null> = 'user') => {\n if (phaseRef.current !== 'recording') return;\n recorder.pause();\n setPhase('paused');\n setPauseReason(reason);\n },\n [recorder],\n );\n\n const start = useCallback(async () => {\n const permission = await requestRecordingPermissionsAsync();\n if (!permission.granted) throw new MicrophoneDeniedError();\n // Android's microphone service has to be running before Yantra leaves the screen, and\n // may only start while it is on it: now. A refusal means pausing on leave, as before.\n inBackgroundRef.current = background?.supported\n ? await background.start(BACKGROUND_NOTICE.title, BACKGROUND_NOTICE.text).then(\n () => true,\n () => false,\n )\n : false;\n try {\n await setAudioModeAsync({\n allowsRecording: true,\n playsInSilentMode: true,\n shouldPlayInBackground: inBackgroundRef.current,\n });\n await recorder.prepareToRecordAsync();\n const available = listMics();\n const chosen = chooseMic(available, await readMicPreference());\n if (chosen && available.length > 1) selectMic(chosen);\n setMics(available);\n setMic(chosen);\n setMicLost(null);\n recorder.record();\n } catch (err) {\n await releaseSession();\n throw err;\n }\n // Without background recording the screen must stay on, or the microphone stops.\n if (!inBackgroundRef.current) await activateKeepAwakeAsync(KEEP_AWAKE_TAG).catch(() => undefined);\n setPhase('recording');\n setPauseReason(null);\n }, [recorder, background, releaseSession, listMics, selectMic]);\n\n /** The other microphone (AirPods <-> the phone's), remembered for the next dictation. */\n const switchMic = useCallback(() => {\n const available = listMics();\n const next = otherMic(available, micRef.current);\n if (!next || !selectMic(next)) return;\n setMics(available);\n setMic(next);\n setMicLost(null);\n writeMicPreference(next.kind);\n }, [listMics, selectMic]);\n\n const resume = useCallback(async () => {\n if (phaseRef.current !== 'paused') return;\n // A call or another app deactivated the audio session; recording needs it back.\n await setIsAudioActiveAsync(true).catch(() => undefined);\n recorder.record();\n setPhase('recording');\n setPauseReason(null);\n }, [recorder]);\n\n /** Ends the recording; resolves to its file (in the recorder's cache - move it before anything else). */\n const finish = useCallback(async (): Promise<{ uri: string; durationMs: number } | null> => {\n if (phaseRef.current === 'idle') return null;\n const durationMs = recorder.getStatus().durationMillis;\n await recorder.stop();\n setPhase('idle');\n setPauseReason(null);\n await releaseSession();\n return recorder.uri ? { uri: recorder.uri, durationMs } : null;\n }, [recorder, releaseSession]);\n\n // Without background recording the microphone stops when the app leaves the screen: pause, and say so.\n useEffect(() => {\n const sub = AppState.addEventListener('change', (next) => {\n if (next !== 'active' && !inBackgroundRef.current) pause('background');\n });\n return () => sub.remove();\n }, [pause]);\n\n // A call or another app took the microphone. Nothing is recorded from here, though\n // expo-audio's timer would keep running: pause, and stay paused until the clinician resumes.\n useEffect(() => {\n const sub = background?.addListener('onInterruption', (event) => {\n if (event.state === 'began') pause('interrupted');\n });\n return () => sub?.remove();\n }, [background, pause]);\n\n useEffect(() => {\n if (phase === 'recording' && state.durationMillis >= MAX_DICTATION_MS) pause('limit');\n }, [phase, state.durationMillis, pause]);\n\n // A headset can go away mid-dictation (taken out, battery flat): the system moves the recording\n // to the phone's microphone without a word, so look, and say so. One coming back is offered again.\n useEffect(() => {\n if (phase !== 'recording') return undefined;\n const id = setInterval(() => {\n void Promise.resolve()\n .then(() => recorder.getCurrentInput())\n .then((input) => {\n const heard = micOf(input, phoneWord());\n const was = micRef.current;\n const now = listMics();\n const uids = (list: Mic[]) => list.map((m) => m.uid).join(' ');\n if (uids(now) !== uids(micsRef.current)) setMics(now);\n if (!was || heard.uid === was.uid) return;\n setMicLost(was.kind === 'headset' && heard.kind === 'phone' ? was.label : null);\n setMic(heard);\n })\n .catch(() => undefined);\n }, MIC_CHECK_MS);\n return () => clearInterval(id);\n }, [phase, recorder, listMics]);\n\n // Recording time at which the microphone last carried a signal. A paused or idle recorder\n // starts the count again, so Resume gets a fresh few seconds; so does a new recording,\n // whose time restarts below the last one's.\n const signalAtRef = useRef(0);\n useEffect(() => {\n if (phase !== 'recording' || carriesSignal(state.metering) || state.durationMillis < signalAtRef.current) {\n signalAtRef.current = state.durationMillis;\n }\n }, [phase, state.durationMillis, state.metering]);\n // Without this a dead microphone records a whole visit of silence, timer running.\n const noInput =\n phase === 'recording' &&\n !carriesSignal(state.metering) &&\n state.durationMillis - signalAtRef.current >= NO_INPUT_WARN_MS;\n\n // The lock screen and the Dynamic Island follow the dictation while it records in the background (iOS).\n const activity = backgroundActivityText(phase, pauseReason, noInput);\n const activityTitle = activity?.title;\n const activityDetail = activity?.detail;\n useEffect(() => {\n if (!activityTitle || !activityDetail || !inBackgroundRef.current || !background?.update) return;\n void background\n .update({\n title: activityTitle,\n detail: activityDetail,\n recording: phase === 'recording',\n recordedMs: recorder.getStatus().durationMillis,\n noSound: noInput,\n })\n .catch(() => undefined);\n }, [activityTitle, activityDetail, phase, noInput, background, recorder]);\n\n // Leaving the screen mid-dictation stops the microphone and lets the screen sleep.\n useEffect(\n () => () => {\n if (phaseRef.current !== 'idle') void recorder.stop().catch(() => undefined);\n void releaseSession();\n },\n [recorder, releaseSession],\n );\n\n return {\n phase,\n pauseReason,\n elapsedMs: state.durationMillis,\n level: phase === 'recording' ? levelFromMetering(state.metering) : 0,\n noInput,\n /** This binary keeps a dictation recording with the phone locked or another app open. */\n recordsInBackground: background?.supported === true,\n /** The microphone the dictation is recording from, once it started. */\n mic,\n /** The other microphone it can switch to (AirPods <-> the phone's), if one is connected. */\n otherMic: otherMic(mics, mic),\n /** The headset that went away mid-dictation, while the phone's microphone carries on. */\n micLost,\n switchMic,\n start,\n pause: () => pause('user'),\n resume,\n finish,\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AA0Ba,MAAA,mBAAA,GAAwC,aAChD,CAAA,cAAA,CAAA,EAAA,EAAA,gBAAA,CAAiB,YAD+B,CAAA,EAAA;AAAA,EAEnD,SAAW,EAAA,MAAA;AAAA,EACX,UAAY,EAAA,KAAA;AAAA,EACZ,gBAAkB,EAAA,CAAA;AAAA,EAClB,OAAS,EAAA,IAAA;AAAA,EACT,iBAAmB,EAAA,IAAA;AAAA,EACnB,GAAK,EAAA,aAAA,CAAA,cAAA,CAAA,EAAA,EACA,gBAAiB,CAAA,YAAA,CAAa,GAD9B,CAAA,EAAA;AAAA,IAEH,cAAc,eAAgB,CAAA,QAAA;AAAA,IAC9B,cAAc,YAAa,CAAA;AAAA,GAC7B,CAAA;AAAA,EACA,OAAS,EAAA,aAAA,CAAA,cAAA,CAAA,EAAA,EACJ,gBAAiB,CAAA,YAAA,CAAa,OAD1B,CAAA,EAAA;AAAA,IAEP,YAAc,EAAA,OAAA;AAAA,IACd,YAAc,EAAA;AAAA,GAChB;AACF,CAAA;AAGO,MAAM,mBAAmB,EAAK,GAAA;AACrC,MAAM,cAAiB,GAAA,gBAAA;AAEhB,MAAM,YAAe,GAAA;AAG5B,SAAS,SAAoB,GAAA;AAC3B,EAAI,IAAA,QAAA,CAAS,EAAO,KAAA,KAAA,EAAc,OAAA,OAAA;AAClC,EAAQ,OAAA,QAAA,CAEL,QAAQ,MAAS,GAAA,QAAA;AACtB;AAKO,SAAS,kBAAkB,EAAgC,EAAA;AAChE,EAAI,IAAA,OAAO,OAAO,QAAY,IAAA,CAAC,OAAO,QAAS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,OAAA;AAAA,IACL,KAAA;AAAA,IACA,WAAA;AAAA,IACA,WAAW,KAAM,CAAA,cAAA;AAAA,IACjB,OAAO,KAAU,KAAA,WAAA,GAAc,iBAAkB,CAAA,KAAA,CAAM,QAAQ,CAAI,GAAA,CAAA;AAAA,IACnE,OAAA;AAAA;AAAA,IAEA,mBAAA,EAAA,CAAqB,yCAAY,SAAc,MAAA,IAAA;AAAA;AAAA,IAE/C,GAAA;AAAA;AAAA,IAEA,QAAA,EAAU,QAAS,CAAA,IAAA,EAAM,GAAG,CAAA;AAAA;AAAA,IAE5B,OAAA;AAAA,IACA,SAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA,EAAO,MAAM,KAAA,CAAM,MAAM,CAAA;AAAA,IACzB,MAAA;AAAA,IACA;AAAA,GACF;AACF"}
@@ -0,0 +1,100 @@
1
+ import {useMemo,useState,useRef,useCallback,useEffect}from'react';import {speechRecognitionNative}from'./dictateVoice.js';function speechLanguage() {
2
+ try {
3
+ const {
4
+ locale
5
+ } = Intl.DateTimeFormat().resolvedOptions();
6
+ return /^[a-z]{2,3}-[A-Z]{2}$/.test(locale) ? locale : "en-US";
7
+ } catch (e) {
8
+ return "en-US";
9
+ }
10
+ }
11
+ function useVoiceQuestion(onQuestion) {
12
+ const ears = useMemo(() => speechRecognitionNative(), []);
13
+ const [listening, setListening] = useState(false);
14
+ const [heard, setHeard] = useState("");
15
+ const [error, setError] = useState(null);
16
+ const heardRef = useRef("");
17
+ const subsRef = useRef([]);
18
+ const onQuestionRef = useRef(onQuestion);
19
+ onQuestionRef.current = onQuestion;
20
+ const settle = useCallback((send) => {
21
+ if (!subsRef.current.length) return;
22
+ subsRef.current.forEach((s) => s.remove());
23
+ subsRef.current = [];
24
+ const text = heardRef.current.trim();
25
+ heardRef.current = "";
26
+ setHeard("");
27
+ setListening(false);
28
+ if (send && text) onQuestionRef.current(text);
29
+ }, []);
30
+ const start = useCallback(() => {
31
+ if (!ears || subsRef.current.length) return;
32
+ setError(null);
33
+ void (async () => {
34
+ var _a;
35
+ const permission = await ears.requestPermissionsAsync().catch(() => ({
36
+ granted: false
37
+ }));
38
+ if (!permission.granted) {
39
+ setError("Allow the microphone and speech recognition for Yantra in Settings to ask by voice.");
40
+ return;
41
+ }
42
+ heardRef.current = "";
43
+ subsRef.current = [ears.addListener("result", (event) => {
44
+ var _a2, _b, _c;
45
+ heardRef.current = (_c = (_b = (_a2 = event.results) == null ? void 0 : _a2[0]) == null ? void 0 : _b.transcript) != null ? _c : heardRef.current;
46
+ setHeard(heardRef.current);
47
+ }), ears.addListener("end", () => settle(true)), ears.addListener("error", (event) => {
48
+ const quiet = event.error === "no-speech" || event.error === "aborted";
49
+ if (!quiet) setError("The question was not heard. Try again, or type it.");
50
+ settle(quiet);
51
+ })];
52
+ setListening(true);
53
+ try {
54
+ ears.start({
55
+ lang: speechLanguage(),
56
+ interimResults: true,
57
+ continuous: false,
58
+ addsPunctuation: true,
59
+ // On the device when the phone can: then the question never leaves it until it is sent.
60
+ requiresOnDeviceRecognition: ((_a = ears.supportsOnDeviceRecognition) == null ? void 0 : _a.call(ears)) === true
61
+ });
62
+ } catch (e) {
63
+ setError("The question was not heard. Try again, or type it.");
64
+ settle(false);
65
+ }
66
+ })();
67
+ }, [ears, settle]);
68
+ const finish = useCallback(() => {
69
+ try {
70
+ ears == null ? void 0 : ears.stop();
71
+ } catch (e) {
72
+ settle(true);
73
+ }
74
+ }, [ears, settle]);
75
+ const cancel = useCallback(() => {
76
+ try {
77
+ ears == null ? void 0 : ears.abort();
78
+ } catch (e) {
79
+ }
80
+ settle(false);
81
+ }, [ears, settle]);
82
+ useEffect(() => () => {
83
+ if (!subsRef.current.length) return;
84
+ subsRef.current.forEach((s) => s.remove());
85
+ subsRef.current = [];
86
+ try {
87
+ ears == null ? void 0 : ears.abort();
88
+ } catch (e) {
89
+ }
90
+ }, [ears]);
91
+ return {
92
+ available: !!ears,
93
+ listening,
94
+ heard,
95
+ error,
96
+ start,
97
+ finish,
98
+ cancel
99
+ };
100
+ }export{speechLanguage,useVoiceQuestion};//# sourceMappingURL=useVoiceQuestion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useVoiceQuestion.js","sources":["../../../src/features/dictate/useVoiceQuestion.ts"],"sourcesContent":["/**\n * Asking about a note by voice: the phone's speech recognition hears the\n * question (through AirPods when they are in: it records with Bluetooth\n * allowed), on the device whenever the phone can, and hands over the words\n * once the person stops talking. What they said then goes the way a typed\n * question does, names the note knows hidden before it leaves the phone.\n */\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { speechRecognitionNative } from './dictateVoice';\n\n/** The phone's language as a recogniser takes it (\"en-US\"); English when it cannot tell. */\nexport function speechLanguage(): string {\n try {\n const { locale } = Intl.DateTimeFormat().resolvedOptions();\n return /^[a-z]{2,3}-[A-Z]{2}$/.test(locale) ? locale : 'en-US';\n } catch {\n return 'en-US';\n }\n}\n\nexport interface VoiceQuestion {\n /** This binary can hear a question. */\n available: boolean;\n listening: boolean;\n /** The words so far, while listening. */\n heard: string;\n error: string | null;\n start(): void;\n /** Done talking: send what was heard. */\n finish(): void;\n cancel(): void;\n}\n\nexport function useVoiceQuestion(onQuestion: (text: string) => void): VoiceQuestion {\n const ears = useMemo(() => speechRecognitionNative(), []);\n const [listening, setListening] = useState(false);\n const [heard, setHeard] = useState('');\n const [error, setError] = useState<string | null>(null);\n const heardRef = useRef('');\n const subsRef = useRef<Array<{ remove(): void }>>([]);\n const onQuestionRef = useRef(onQuestion);\n onQuestionRef.current = onQuestion;\n\n // Once per question, whichever of `end` and `error` comes first.\n const settle = useCallback((send: boolean) => {\n if (!subsRef.current.length) return;\n subsRef.current.forEach((s) => s.remove());\n subsRef.current = [];\n const text = heardRef.current.trim();\n heardRef.current = '';\n setHeard('');\n setListening(false);\n if (send && text) onQuestionRef.current(text);\n }, []);\n\n const start = useCallback(() => {\n if (!ears || subsRef.current.length) return;\n setError(null);\n void (async () => {\n const permission = await ears.requestPermissionsAsync().catch(() => ({ granted: false }));\n if (!permission.granted) {\n setError('Allow the microphone and speech recognition for Yantra in Settings to ask by voice.');\n return;\n }\n heardRef.current = '';\n subsRef.current = [\n ears.addListener('result', (event) => {\n heardRef.current = event.results?.[0]?.transcript ?? heardRef.current;\n setHeard(heardRef.current);\n }),\n ears.addListener('end', () => settle(true)),\n ears.addListener('error', (event) => {\n // Silence or a stop is not a failure: whatever was heard still goes.\n const quiet = event.error === 'no-speech' || event.error === 'aborted';\n if (!quiet) setError('The question was not heard. Try again, or type it.');\n settle(quiet);\n }),\n ];\n setListening(true);\n try {\n ears.start({\n lang: speechLanguage(),\n interimResults: true,\n continuous: false,\n addsPunctuation: true,\n // On the device when the phone can: then the question never leaves it until it is sent.\n requiresOnDeviceRecognition: ears.supportsOnDeviceRecognition?.() === true,\n });\n } catch {\n setError('The question was not heard. Try again, or type it.');\n settle(false);\n }\n })();\n }, [ears, settle]);\n\n const finish = useCallback(() => {\n try {\n ears?.stop();\n } catch {\n settle(true);\n }\n }, [ears, settle]);\n\n const cancel = useCallback(() => {\n try {\n ears?.abort();\n } catch {\n /* already stopped */\n }\n settle(false);\n }, [ears, settle]);\n\n useEffect(\n () => () => {\n if (!subsRef.current.length) return;\n subsRef.current.forEach((s) => s.remove());\n subsRef.current = [];\n try {\n ears?.abort();\n } catch {\n /* already stopped */\n }\n },\n [ears],\n );\n\n return { available: !!ears, listening, heard, error, start, finish, cancel };\n}\n"],"names":["_a"],"mappings":"0HAWO,SAAS,cAAyB,GAAA;AACvC,EAAI,IAAA;AACF,IAAM,MAAA;AAAA,MACJ;AAAA,KACE,GAAA,IAAA,CAAK,cAAe,EAAA,CAAE,eAAgB,EAAA;AAC1C,IAAA,OAAO,uBAAwB,CAAA,IAAA,CAAK,MAAM,CAAA,GAAI,MAAS,GAAA,OAAA;AAAA,GACjD,CAAA,OAAA,CAAA,EAAA;AACN,IAAO,OAAA,OAAA;AAAA;AAEX;AAaO,SAAS,iBAAiB,UAAmD,EAAA;AAClF,EAAA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ACF,MAAM,IAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,IAAA,CAAA,KAAA,EAAA;AAAA,KACA,CAAA,OAAA,CAAA,EAAA;AAAA;AAER,GACF,EAAG,CAAC,IAAI,CAAC,CAAA;AACT,EAAO,OAAA;AAAA,IACL,SAAA,EAAW,CAAC,CAAC,IAAA;AAAA,IACb,SAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA;AAAA,IACA,MAAA;AAAA,IACA;AAAA,GACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminide-stack/yantra-mobile",
3
- "version": "12.0.157",
3
+ "version": "12.0.158",
4
4
  "description": "Sample core for higher packages to depend on",
5
5
  "license": "ISC",
6
6
  "author": "CDMBase LLC",
@@ -27,7 +27,7 @@
27
27
  "uuid": "^9.0.0"
28
28
  },
29
29
  "devDependencies": {
30
- "common": "^12.0.157",
30
+ "common": "12.0.157",
31
31
  "libphonenumber-js": "^1.13.3"
32
32
  },
33
33
  "peerDependencies": {
@@ -45,7 +45,7 @@
45
45
  "@messenger-box/platform-mobile": "*",
46
46
  "@react-native-async-storage/async-storage": "*",
47
47
  "@react-navigation/native": "*",
48
- "common": "12.0.156",
48
+ "common": "12.0.157",
49
49
  "expo-background-task": "*",
50
50
  "expo-constants": "*",
51
51
  "expo-secure-store": "*",
@@ -67,5 +67,5 @@
67
67
  "typescript": {
68
68
  "definition": "lib/index.d.ts"
69
69
  },
70
- "gitHead": "ac70d0234c778559ac7146fdf19c06d611b0a8e2"
70
+ "gitHead": "d1c58122b449bc81747d66461ccb40487c06691c"
71
71
  }