@siteed/expo-audio-stream 2.0.1 → 2.2.0
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.
- package/README.md +46 -27
- package/build/index.d.ts +11 -12
- package/build/index.js +44 -10
- package/package.json +49 -110
- package/src/index.ts +18 -33
- package/CHANGELOG.md +0 -195
- package/android/build.gradle +0 -105
- package/android/src/main/AndroidManifest.xml +0 -27
- package/android/src/main/java/net/siteed/audiostream/AudioAnalysisData.kt +0 -166
- package/android/src/main/java/net/siteed/audiostream/AudioDataEncoder.kt +0 -9
- package/android/src/main/java/net/siteed/audiostream/AudioFileHandler.kt +0 -131
- package/android/src/main/java/net/siteed/audiostream/AudioFormatUtils.kt +0 -103
- package/android/src/main/java/net/siteed/audiostream/AudioNotificationsManager.kt +0 -435
- package/android/src/main/java/net/siteed/audiostream/AudioProcessor.kt +0 -1936
- package/android/src/main/java/net/siteed/audiostream/AudioRecorderManager.kt +0 -1437
- package/android/src/main/java/net/siteed/audiostream/AudioRecordingService.kt +0 -138
- package/android/src/main/java/net/siteed/audiostream/Constants.kt +0 -20
- package/android/src/main/java/net/siteed/audiostream/EventSender.kt +0 -7
- package/android/src/main/java/net/siteed/audiostream/ExpoAudioStreamModule.kt +0 -509
- package/android/src/main/java/net/siteed/audiostream/FFT.kt +0 -99
- package/android/src/main/java/net/siteed/audiostream/Features.kt +0 -98
- package/android/src/main/java/net/siteed/audiostream/NotificationConfig.kt +0 -70
- package/android/src/main/java/net/siteed/audiostream/PermissionUtils.kt +0 -59
- package/android/src/main/java/net/siteed/audiostream/RecordingActionReceiver.kt +0 -59
- package/android/src/main/java/net/siteed/audiostream/RecordingConfig.kt +0 -205
- package/android/src/main/java/net/siteed/audiostream/WaveformConfig.kt +0 -19
- package/android/src/main/java/net/siteed/audiostream/WaveformRenderer.kt +0 -159
- package/android/src/main/res/drawable/ic_default_action_icon.xml +0 -16
- package/android/src/main/res/drawable/ic_microphone.xml +0 -13
- package/android/src/main/res/drawable/ic_pause.xml +0 -10
- package/android/src/main/res/drawable/ic_play.xml +0 -10
- package/android/src/main/res/drawable/ic_stop.xml +0 -10
- package/android/src/main/res/layout/notification_recording.xml +0 -37
- package/android/src/main/test/java/net/siteed/audiostream/AudioProcessorTest.kt +0 -56
- package/app.plugin.js +0 -1
- package/build/AudioAnalysis/AudioAnalysis.types.d.ts +0 -144
- package/build/AudioAnalysis/AudioAnalysis.types.d.ts.map +0 -1
- package/build/AudioAnalysis/AudioAnalysis.types.js +0 -3
- package/build/AudioAnalysis/AudioAnalysis.types.js.map +0 -1
- package/build/AudioAnalysis/extractAudioAnalysis.d.ts +0 -78
- package/build/AudioAnalysis/extractAudioAnalysis.d.ts.map +0 -1
- package/build/AudioAnalysis/extractAudioAnalysis.js +0 -229
- package/build/AudioAnalysis/extractAudioAnalysis.js.map +0 -1
- package/build/AudioAnalysis/extractWaveform.d.ts +0 -8
- package/build/AudioAnalysis/extractWaveform.d.ts.map +0 -1
- package/build/AudioAnalysis/extractWaveform.js +0 -11
- package/build/AudioAnalysis/extractWaveform.js.map +0 -1
- package/build/AudioRecorder.provider.d.ts +0 -11
- package/build/AudioRecorder.provider.d.ts.map +0 -1
- package/build/AudioRecorder.provider.js +0 -37
- package/build/AudioRecorder.provider.js.map +0 -1
- package/build/ExpoAudioStream.native.d.ts +0 -3
- package/build/ExpoAudioStream.native.d.ts.map +0 -1
- package/build/ExpoAudioStream.native.js +0 -6
- package/build/ExpoAudioStream.native.js.map +0 -1
- package/build/ExpoAudioStream.types.d.ts +0 -206
- package/build/ExpoAudioStream.types.d.ts.map +0 -1
- package/build/ExpoAudioStream.types.js +0 -2
- package/build/ExpoAudioStream.types.js.map +0 -1
- package/build/ExpoAudioStream.web.d.ts +0 -59
- package/build/ExpoAudioStream.web.d.ts.map +0 -1
- package/build/ExpoAudioStream.web.js +0 -285
- package/build/ExpoAudioStream.web.js.map +0 -1
- package/build/ExpoAudioStreamModule.d.ts +0 -3
- package/build/ExpoAudioStreamModule.d.ts.map +0 -1
- package/build/ExpoAudioStreamModule.js +0 -239
- package/build/ExpoAudioStreamModule.js.map +0 -1
- package/build/WebRecorder.web.d.ts +0 -119
- package/build/WebRecorder.web.d.ts.map +0 -1
- package/build/WebRecorder.web.js +0 -436
- package/build/WebRecorder.web.js.map +0 -1
- package/build/constants.d.ts +0 -11
- package/build/constants.d.ts.map +0 -1
- package/build/constants.js +0 -14
- package/build/constants.js.map +0 -1
- package/build/events.d.ts +0 -26
- package/build/events.d.ts.map +0 -1
- package/build/events.js +0 -21
- package/build/events.js.map +0 -1
- package/build/index.d.ts.map +0 -1
- package/build/index.js.map +0 -1
- package/build/useAudioRecorder.d.ts +0 -21
- package/build/useAudioRecorder.d.ts.map +0 -1
- package/build/useAudioRecorder.js +0 -427
- package/build/useAudioRecorder.js.map +0 -1
- package/build/utils/BlobFix.d.ts +0 -9
- package/build/utils/BlobFix.d.ts.map +0 -1
- package/build/utils/BlobFix.js +0 -498
- package/build/utils/BlobFix.js.map +0 -1
- package/build/utils/audioProcessing.d.ts +0 -24
- package/build/utils/audioProcessing.d.ts.map +0 -1
- package/build/utils/audioProcessing.js +0 -133
- package/build/utils/audioProcessing.js.map +0 -1
- package/build/utils/concatenateBuffers.d.ts +0 -8
- package/build/utils/concatenateBuffers.d.ts.map +0 -1
- package/build/utils/concatenateBuffers.js +0 -21
- package/build/utils/concatenateBuffers.js.map +0 -1
- package/build/utils/convertPCMToFloat32.d.ts +0 -13
- package/build/utils/convertPCMToFloat32.d.ts.map +0 -1
- package/build/utils/convertPCMToFloat32.js +0 -120
- package/build/utils/convertPCMToFloat32.js.map +0 -1
- package/build/utils/encodingToBitDepth.d.ts +0 -5
- package/build/utils/encodingToBitDepth.d.ts.map +0 -1
- package/build/utils/encodingToBitDepth.js +0 -13
- package/build/utils/encodingToBitDepth.js.map +0 -1
- package/build/utils/getWavFileInfo.d.ts +0 -26
- package/build/utils/getWavFileInfo.d.ts.map +0 -1
- package/build/utils/getWavFileInfo.js +0 -92
- package/build/utils/getWavFileInfo.js.map +0 -1
- package/build/utils/writeWavHeader.d.ts +0 -49
- package/build/utils/writeWavHeader.d.ts.map +0 -1
- package/build/utils/writeWavHeader.js +0 -91
- package/build/utils/writeWavHeader.js.map +0 -1
- package/build/workers/InlineFeaturesExtractor.web.d.ts +0 -2
- package/build/workers/InlineFeaturesExtractor.web.d.ts.map +0 -1
- package/build/workers/InlineFeaturesExtractor.web.js +0 -828
- package/build/workers/InlineFeaturesExtractor.web.js.map +0 -1
- package/build/workers/inlineAudioWebWorker.web.d.ts +0 -2
- package/build/workers/inlineAudioWebWorker.web.d.ts.map +0 -1
- package/build/workers/inlineAudioWebWorker.web.js +0 -157
- package/build/workers/inlineAudioWebWorker.web.js.map +0 -1
- package/expo-module.config.json +0 -9
- package/ios/AudioAnalysisData.swift +0 -74
- package/ios/AudioNotificationManager.swift +0 -135
- package/ios/AudioProcessingHelpers.swift +0 -743
- package/ios/AudioProcessor.swift +0 -858
- package/ios/AudioStreamError.swift +0 -7
- package/ios/AudioStreamManager.swift +0 -1708
- package/ios/AudioStreamManagerDelegate.swift +0 -16
- package/ios/DataPoint.swift +0 -54
- package/ios/DecodingConfig.swift +0 -47
- package/ios/ExpoAudioStream.podspec +0 -27
- package/ios/ExpoAudioStreamModule.swift +0 -698
- package/ios/FFT.swift +0 -62
- package/ios/Features.swift +0 -95
- package/ios/Logger.swift +0 -7
- package/ios/NotificationExtension.swift +0 -15
- package/ios/RecordingResult.swift +0 -22
- package/ios/RecordingSettings.swift +0 -265
- package/ios/WaveformExtractor.swift +0 -105
- package/plugin/build/index.d.ts +0 -21
- package/plugin/build/index.js +0 -191
- package/plugin/src/index.ts +0 -278
- package/plugin/tsconfig.json +0 -10
- package/plugin/tsconfig.tsbuildinfo +0 -1
- package/src/AudioAnalysis/AudioAnalysis.types.ts +0 -165
- package/src/AudioAnalysis/extractAudioAnalysis.ts +0 -370
- package/src/AudioAnalysis/extractWaveform.ts +0 -22
- package/src/AudioRecorder.provider.tsx +0 -54
- package/src/ExpoAudioStream.native.ts +0 -6
- package/src/ExpoAudioStream.types.ts +0 -329
- package/src/ExpoAudioStream.web.ts +0 -359
- package/src/ExpoAudioStreamModule.ts +0 -286
- package/src/WebRecorder.web.ts +0 -580
- package/src/constants.ts +0 -18
- package/src/events.ts +0 -60
- package/src/useAudioRecorder.tsx +0 -620
- package/src/utils/BlobFix.ts +0 -559
- package/src/utils/audioProcessing.ts +0 -205
- package/src/utils/concatenateBuffers.ts +0 -24
- package/src/utils/convertPCMToFloat32.ts +0 -170
- package/src/utils/encodingToBitDepth.ts +0 -18
- package/src/utils/getWavFileInfo.ts +0 -132
- package/src/utils/writeWavHeader.ts +0 -114
- package/src/workers/InlineFeaturesExtractor.web.tsx +0 -827
- package/src/workers/inlineAudioWebWorker.web.tsx +0 -156
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
// packages/expo-audio-stream/src/AudioAnalysis/extractAudioAnalysis.ts
|
|
2
|
-
/**
|
|
3
|
-
* This module provides functions for extracting and analyzing audio data.
|
|
4
|
-
* - `extractAudioAnalysis`: For detailed analysis with customizable ranges and decoding options.
|
|
5
|
-
* - `extractWavAudioAnalysis`: For analyzing WAV files without decoding, preserving original PCM values.
|
|
6
|
-
* - `extractPreview`: For generating quick previews of audio waveforms, optimized for UI rendering.
|
|
7
|
-
*/
|
|
8
|
-
import crc32 from 'crc-32';
|
|
9
|
-
import ExpoAudioStreamModule from '../ExpoAudioStreamModule';
|
|
10
|
-
import { isWeb } from '../constants';
|
|
11
|
-
import { processAudioBuffer } from '../utils/audioProcessing';
|
|
12
|
-
import { convertPCMToFloat32 } from '../utils/convertPCMToFloat32';
|
|
13
|
-
import { getWavFileInfo } from '../utils/getWavFileInfo';
|
|
14
|
-
import { InlineFeaturesExtractor } from '../workers/InlineFeaturesExtractor.web';
|
|
15
|
-
function calculateCRC32ForDataPoint(data) {
|
|
16
|
-
// Convert float array to byte array for CRC32
|
|
17
|
-
const byteArray = new Uint8Array(data.length * 4);
|
|
18
|
-
const dataView = new DataView(byteArray.buffer);
|
|
19
|
-
for (let i = 0; i < data.length; i++) {
|
|
20
|
-
dataView.setFloat32(i * 4, data[i], true);
|
|
21
|
-
}
|
|
22
|
-
return crc32.buf(byteArray);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Extracts detailed audio analysis from the specified audio file or buffer.
|
|
26
|
-
* Supports either time-based or byte-based ranges for flexibility in analysis.
|
|
27
|
-
*
|
|
28
|
-
* @param props - The options for extraction, including file URI, ranges, and decoding settings.
|
|
29
|
-
* @returns A promise that resolves to the audio analysis data.
|
|
30
|
-
* @throws {Error} If both time and byte ranges are provided or if required parameters are missing.
|
|
31
|
-
*/
|
|
32
|
-
export async function extractAudioAnalysis(props) {
|
|
33
|
-
const { fileUri, arrayBuffer, decodingOptions, logger, segmentDurationMs = 100, features, } = props;
|
|
34
|
-
if (isWeb) {
|
|
35
|
-
try {
|
|
36
|
-
// Create AudioContext here
|
|
37
|
-
const audioContext = new (window.AudioContext ||
|
|
38
|
-
window.webkitAudioContext)({
|
|
39
|
-
sampleRate: decodingOptions?.targetSampleRate ?? 16000,
|
|
40
|
-
});
|
|
41
|
-
try {
|
|
42
|
-
const processedBuffer = await processAudioBuffer({
|
|
43
|
-
arrayBuffer,
|
|
44
|
-
fileUri,
|
|
45
|
-
targetSampleRate: decodingOptions?.targetSampleRate ?? 16000,
|
|
46
|
-
targetChannels: decodingOptions?.targetChannels ?? 1,
|
|
47
|
-
normalizeAudio: decodingOptions?.normalizeAudio ?? false,
|
|
48
|
-
startTimeMs: 'startTimeMs' in props ? props.startTimeMs : undefined,
|
|
49
|
-
endTimeMs: 'endTimeMs' in props ? props.endTimeMs : undefined,
|
|
50
|
-
position: 'position' in props ? props.position : undefined,
|
|
51
|
-
length: 'length' in props ? props.length : undefined,
|
|
52
|
-
audioContext, // Pass the context we created
|
|
53
|
-
logger,
|
|
54
|
-
});
|
|
55
|
-
const channelData = processedBuffer.buffer.getChannelData(0);
|
|
56
|
-
// Create and initialize the worker
|
|
57
|
-
const blob = new Blob([InlineFeaturesExtractor], {
|
|
58
|
-
type: 'application/javascript',
|
|
59
|
-
});
|
|
60
|
-
const workerUrl = URL.createObjectURL(blob);
|
|
61
|
-
const worker = new Worker(workerUrl);
|
|
62
|
-
return new Promise((resolve, reject) => {
|
|
63
|
-
worker.onmessage = (event) => {
|
|
64
|
-
if (event.data.error) {
|
|
65
|
-
reject(new Error(event.data.error));
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
const result = event.data.result;
|
|
69
|
-
// Calculate CRC32 after worker completes if requested
|
|
70
|
-
if (features?.crc32) {
|
|
71
|
-
const samplesPerSegment = Math.floor((processedBuffer.sampleRate *
|
|
72
|
-
segmentDurationMs) /
|
|
73
|
-
1000);
|
|
74
|
-
result.dataPoints = result.dataPoints.map((point, index) => {
|
|
75
|
-
const startSample = index * samplesPerSegment;
|
|
76
|
-
const segmentData = channelData.slice(startSample, startSample + samplesPerSegment);
|
|
77
|
-
return {
|
|
78
|
-
...point,
|
|
79
|
-
features: {
|
|
80
|
-
...point.features,
|
|
81
|
-
crc32: calculateCRC32ForDataPoint(segmentData),
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
URL.revokeObjectURL(workerUrl);
|
|
87
|
-
worker.terminate();
|
|
88
|
-
resolve(result);
|
|
89
|
-
};
|
|
90
|
-
worker.onerror = (error) => {
|
|
91
|
-
URL.revokeObjectURL(workerUrl);
|
|
92
|
-
worker.terminate();
|
|
93
|
-
reject(error);
|
|
94
|
-
};
|
|
95
|
-
worker.postMessage({
|
|
96
|
-
channelData,
|
|
97
|
-
sampleRate: processedBuffer.sampleRate,
|
|
98
|
-
segmentDurationMs,
|
|
99
|
-
bitDepth: decodingOptions?.targetBitDepth ?? 32,
|
|
100
|
-
numberOfChannels: processedBuffer.channels,
|
|
101
|
-
// enableLogging: !!logger,
|
|
102
|
-
features,
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
finally {
|
|
107
|
-
await audioContext.close();
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
catch (error) {
|
|
111
|
-
logger?.error('Failed to process audio:', error);
|
|
112
|
-
throw error;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
return await ExpoAudioStreamModule.extractAudioAnalysis(props);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Analyzes WAV files without decoding, preserving original PCM values.
|
|
121
|
-
* Use this function when you need to ensure the analysis matches other software by avoiding any transformations.
|
|
122
|
-
*
|
|
123
|
-
* @param props - The options for WAV analysis, including file URI and range.
|
|
124
|
-
* @returns A promise that resolves to the audio analysis data.
|
|
125
|
-
*/
|
|
126
|
-
export const extractRawWavAnalysis = async ({ fileUri, segmentDurationMs = 100, // Default to 100ms
|
|
127
|
-
arrayBuffer, bitDepth, durationMs, sampleRate, numberOfChannels, features, logger, position = 0, length, }) => {
|
|
128
|
-
if (isWeb) {
|
|
129
|
-
if (!arrayBuffer && !fileUri) {
|
|
130
|
-
throw new Error('Either arrayBuffer or fileUri must be provided');
|
|
131
|
-
}
|
|
132
|
-
if (!arrayBuffer) {
|
|
133
|
-
logger?.log(`fetching fileUri`, fileUri);
|
|
134
|
-
const response = await fetch(fileUri);
|
|
135
|
-
if (!response.ok) {
|
|
136
|
-
throw new Error(`Failed to fetch fileUri: ${response.statusText}`);
|
|
137
|
-
}
|
|
138
|
-
arrayBuffer = await response.arrayBuffer();
|
|
139
|
-
logger?.log(`fetched fileUri`, arrayBuffer.byteLength, arrayBuffer);
|
|
140
|
-
}
|
|
141
|
-
// Create a new copy of the ArrayBuffer to avoid detachment issues
|
|
142
|
-
const bufferCopy = arrayBuffer.slice(0);
|
|
143
|
-
logger?.log(`extractAudioAnalysis bitDepth=${bitDepth} len=${bufferCopy.byteLength}`, bufferCopy.slice(0, 100));
|
|
144
|
-
let actualBitDepth = bitDepth;
|
|
145
|
-
if (!actualBitDepth) {
|
|
146
|
-
logger?.log(`extractAudioAnalysis bitDepth not provided -- getting wav file info`);
|
|
147
|
-
const fileInfo = await getWavFileInfo(bufferCopy);
|
|
148
|
-
actualBitDepth = fileInfo.bitDepth;
|
|
149
|
-
}
|
|
150
|
-
logger?.log(`extractAudioAnalysis actualBitDepth=${actualBitDepth}`);
|
|
151
|
-
const { pcmValues: channelData, min, max, } = await convertPCMToFloat32({
|
|
152
|
-
buffer: arrayBuffer,
|
|
153
|
-
bitDepth: actualBitDepth,
|
|
154
|
-
});
|
|
155
|
-
logger?.log(`extractAudioAnalysis convertPCMToFloat32 length=${channelData.length} range: [ ${min} :: ${max} ]`);
|
|
156
|
-
// Apply position and length constraints to channelData if specified
|
|
157
|
-
const startIndex = position;
|
|
158
|
-
const endIndex = length ? startIndex + length : channelData.length;
|
|
159
|
-
const constrainedChannelData = channelData.slice(startIndex, endIndex);
|
|
160
|
-
return new Promise((resolve, reject) => {
|
|
161
|
-
const blob = new Blob([InlineFeaturesExtractor], {
|
|
162
|
-
type: 'application/javascript',
|
|
163
|
-
});
|
|
164
|
-
const url = URL.createObjectURL(blob);
|
|
165
|
-
const worker = new Worker(url);
|
|
166
|
-
worker.onmessage = (event) => {
|
|
167
|
-
resolve(event.data.result);
|
|
168
|
-
};
|
|
169
|
-
worker.onerror = (error) => {
|
|
170
|
-
reject(error);
|
|
171
|
-
};
|
|
172
|
-
worker.postMessage({
|
|
173
|
-
command: 'process',
|
|
174
|
-
channelData: constrainedChannelData,
|
|
175
|
-
sampleRate,
|
|
176
|
-
segmentDurationMs,
|
|
177
|
-
logger,
|
|
178
|
-
bitDepth,
|
|
179
|
-
fullAudioDurationMs: durationMs,
|
|
180
|
-
numberOfChannels,
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
if (!fileUri) {
|
|
186
|
-
throw new Error('fileUri is required');
|
|
187
|
-
}
|
|
188
|
-
logger?.log(`extractAudioAnalysis`, {
|
|
189
|
-
fileUri,
|
|
190
|
-
segmentDurationMs,
|
|
191
|
-
});
|
|
192
|
-
const res = await ExpoAudioStreamModule.extractAudioAnalysis({
|
|
193
|
-
fileUri,
|
|
194
|
-
segmentDurationMs,
|
|
195
|
-
features,
|
|
196
|
-
position,
|
|
197
|
-
length,
|
|
198
|
-
});
|
|
199
|
-
logger?.log(`extractAudioAnalysis`, res);
|
|
200
|
-
return res;
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
/**
|
|
204
|
-
* Generates a simplified preview of the audio waveform for quick visualization.
|
|
205
|
-
* Ideal for UI rendering with a specified number of points.
|
|
206
|
-
*
|
|
207
|
-
* @param options - The options for the preview, including file URI and time range.
|
|
208
|
-
* @returns A promise that resolves to the audio preview data.
|
|
209
|
-
*/
|
|
210
|
-
export async function extractPreview({ fileUri, numberOfPoints = 100, startTimeMs = 0, endTimeMs = 30000, // First 30 seconds
|
|
211
|
-
decodingOptions, logger, }) {
|
|
212
|
-
const durationMs = endTimeMs - startTimeMs;
|
|
213
|
-
const segmentDurationMs = Math.floor(durationMs / numberOfPoints);
|
|
214
|
-
// Call extractAudioAnalysis with calculated parameters
|
|
215
|
-
const analysis = await extractAudioAnalysis({
|
|
216
|
-
fileUri,
|
|
217
|
-
startTimeMs,
|
|
218
|
-
endTimeMs,
|
|
219
|
-
logger,
|
|
220
|
-
segmentDurationMs,
|
|
221
|
-
decodingOptions,
|
|
222
|
-
});
|
|
223
|
-
// Transform the result into AudioPreview format
|
|
224
|
-
return analysis;
|
|
225
|
-
}
|
|
226
|
-
export const extractAudioData = async (props) => {
|
|
227
|
-
return await ExpoAudioStreamModule.extractAudioData(props);
|
|
228
|
-
};
|
|
229
|
-
//# sourceMappingURL=extractAudioAnalysis.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extractAudioAnalysis.js","sourceRoot":"","sources":["../../src/AudioAnalysis/extractAud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c,CAAC,EACjC,OAAO,EACP,cAAc,GAAG,GAAG,EACpB,WAAW,GAAG,CAAC,EACf,SAAS,GAAG,KAAK,EAAE,mBAAmB;AACtC,eAAe,EACf,MAAM,GACO;IACb,MAAM,UAAU,GAAG,SAAS,GAAG,WAAW,CAAA;IAC1C,MAAM,iBAAiB,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,cAAc,CAAC,CAAA;IAEjE,uDAAuD;IACvD,MAAM,QAAQ,GAAG,MAAM,oBAAoB,CAAC;QACxC,OAAO;QACP,WAAW;QACX,SAAS;QACT,MAAM;QACN,iBAAiB;QACjB,eAAe;KAClB,CAAC,CAAA;IAEF,gDAAgD;IAChD,OAAO,QAAQ,CAAA;AACnB,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EAAE,KAA8B,EAAE,EAAE;IACrE,OAAO,MAAM,qBAAqB,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAA;AAC9D,CAAC,CAAA","sourcesContent":["// packages/expo-audio-stream/src/AudioAnalysis/extractAudioAnalysis.ts\n/**\n * This module provides functions for extracting and analyzing audio data.\n * - `extractAudioAnalysis`: For detailed analysis with customizable ranges and decoding options.\n * - `extractWavAudioAnalysis`: For analyzing WAV files without decoding, preserving original PCM values.\n * - `extractPreview`: For generating quick previews of audio waveforms, optimized for UI rendering.\n */\nimport crc32 from 'crc-32'\n\nimport { ConsoleLike, ExtractAudioDataOptions } from '../ExpoAudioStream.types'\nimport ExpoAudioStreamModule from '../ExpoAudioStreamModule'\nimport { isWeb } from '../constants'\nimport {\n AudioAnalysis,\n AudioFeaturesOptions,\n DataPoint,\n DecodingConfig,\n PreviewOptions,\n} from './AudioAnalysis.types'\nimport { processAudioBuffer } from '../utils/audioProcessing'\nimport { convertPCMToFloat32 } from '../utils/convertPCMToFloat32'\nimport { getWavFileInfo, WavFileInfo } from '../utils/getWavFileInfo'\nimport { InlineFeaturesExtractor } from '../workers/InlineFeaturesExtractor.web'\n\nfunction calculateCRC32ForDataPoint(data: Float32Array): number {\n // Convert float array to byte array for CRC32\n const byteArray = new Uint8Array(data.length * 4)\n const dataView = new DataView(byteArray.buffer)\n\n for (let i = 0; i < data.length; i++) {\n dataView.setFloat32(i * 4, data[i], true)\n }\n\n return crc32.buf(byteArray)\n}\n\nexport interface ExtractWavAudioAnalysisProps {\n fileUri?: string // should provide either fileUri or arrayBuffer\n wavMetadata?: WavFileInfo\n arrayBuffer?: ArrayBuffer\n bitDepth?: number\n durationMs?: number\n sampleRate?: number\n numberOfChannels?: number\n position?: number // Optional number of bytes to skip. Default is 0\n length?: number // Optional number of bytes to read.\n segmentDurationMs?: number // Optional number of points per second. Use to reduce the number of points and compute the number of datapoints to return.\n features?: AudioFeaturesOptions\n featuresExtratorUrl?: string\n logger?: ConsoleLike\n decodingOptions?: DecodingConfig\n}\n\n// Define base options interface with common properties\ninterface BaseExtractOptions {\n fileUri?: string\n arrayBuffer?: ArrayBuffer\n /**\n * Duration of each analysis segment in milliseconds. Defaults to 100ms if not specified.\n */\n segmentDurationMs?: number\n features?: AudioFeaturesOptions\n decodingOptions?: DecodingConfig\n logger?: ConsoleLike\n}\n\n// Time-based range options\ninterface TimeRangeOptions extends BaseExtractOptions {\n startTimeMs?: number\n endTimeMs?: number\n position?: never\n length?: never\n}\n\n// Byte-based range options\ninterface ByteRangeOptions extends BaseExtractOptions {\n position?: number\n length?: number\n startTimeMs?: never\n endTimeMs?: never\n}\n\n/**\n * Options for extracting audio analysis.\n * - For time-based analysis, provide `startTimeMs` and `endTimeMs`.\n * - For byte-based analysis, provide `position` and `length`.\n * - Do not mix time and byte ranges.\n */\nexport type ExtractAudioAnalysisProps = TimeRangeOptions | ByteRangeOptions\n\n/**\n * Extracts detailed audio analysis from the specified audio file or buffer.\n * Supports either time-based or byte-based ranges for flexibility in analysis.\n *\n * @param props - The options for extraction, including file URI, ranges, and decoding settings.\n * @returns A promise that resolves to the audio analysis data.\n * @throws {Error} If both time and byte ranges are provided or if required parameters are missing.\n */\nexport async function extractAudioAnalysis(\n props: ExtractAudioAnalysisProps\n): Promise<AudioAnalysis> {\n const {\n fileUri,\n arrayBuffer,\n decodingOptions,\n logger,\n segmentDurationMs = 100,\n features,\n } = props\n\n if (isWeb) {\n try {\n // Create AudioContext here\n const audioContext = new (window.AudioContext ||\n (window as any).webkitAudioContext)({\n sampleRate: decodingOptions?.targetSampleRate ?? 16000,\n })\n\n try {\n const processedBuffer = await processAudioBuffer({\n arrayBuffer,\n fileUri,\n targetSampleRate:\n decodingOptions?.targetSampleRate ?? 16000,\n targetChannels: decodingOptions?.targetChannels ?? 1,\n normalizeAudio: decodingOptions?.normalizeAudio ?? false,\n startTimeMs:\n 'startTimeMs' in props ? props.startTimeMs : undefined,\n endTimeMs:\n 'endTimeMs' in props ? props.endTimeMs : undefined,\n position: 'position' in props ? props.position : undefined,\n length: 'length' in props ? props.length : undefined,\n audioContext, // Pass the context we created\n logger,\n })\n\n const channelData = processedBuffer.buffer.getChannelData(0)\n\n // Create and initialize the worker\n const blob = new Blob([InlineFeaturesExtractor], {\n type: 'application/javascript',\n })\n const workerUrl = URL.createObjectURL(blob)\n const worker = new Worker(workerUrl)\n\n return new Promise((resolve, reject) => {\n worker.onmessage = (event) => {\n if (event.data.error) {\n reject(new Error(event.data.error))\n return\n }\n\n const result: AudioAnalysis = event.data.result\n // Calculate CRC32 after worker completes if requested\n if (features?.crc32) {\n const samplesPerSegment = Math.floor(\n (processedBuffer.sampleRate *\n segmentDurationMs) /\n 1000\n )\n\n result.dataPoints = result.dataPoints.map(\n (point: DataPoint, index: number) => {\n const startSample =\n index * samplesPerSegment\n const segmentData = channelData.slice(\n startSample,\n startSample + samplesPerSegment\n )\n\n return {\n ...point,\n features: {\n ...point.features,\n crc32: calculateCRC32ForDataPoint(\n segmentData\n ),\n },\n }\n }\n )\n }\n\n URL.revokeObjectURL(workerUrl)\n worker.terminate()\n resolve(result)\n }\n\n worker.onerror = (error) => {\n URL.revokeObjectURL(workerUrl)\n worker.terminate()\n reject(error)\n }\n\n worker.postMessage({\n channelData,\n sampleRate: processedBuffer.sampleRate,\n segmentDurationMs,\n bitDepth: decodingOptions?.targetBitDepth ?? 32,\n numberOfChannels: processedBuffer.channels,\n // enableLogging: !!logger,\n features,\n })\n })\n } finally {\n await audioContext.close()\n }\n } catch (error) {\n logger?.error('Failed to process audio:', error)\n throw error\n }\n } else {\n return await ExpoAudioStreamModule.extractAudioAnalysis(props)\n }\n}\n\n/**\n * Analyzes WAV files without decoding, preserving original PCM values.\n * Use this function when you need to ensure the analysis matches other software by avoiding any transformations.\n *\n * @param props - The options for WAV analysis, including file URI and range.\n * @returns A promise that resolves to the audio analysis data.\n */\nexport const extractRawWavAnalysis = async ({\n fileUri,\n segmentDurationMs = 100, // Default to 100ms\n arrayBuffer,\n bitDepth,\n durationMs,\n sampleRate,\n numberOfChannels,\n features,\n logger,\n position = 0,\n length,\n}: ExtractWavAudioAnalysisProps): Promise<AudioAnalysis> => {\n if (isWeb) {\n if (!arrayBuffer && !fileUri) {\n throw new Error('Either arrayBuffer or fileUri must be provided')\n }\n\n if (!arrayBuffer) {\n logger?.log(`fetching fileUri`, fileUri)\n const response = await fetch(fileUri!)\n\n if (!response.ok) {\n throw new Error(\n `Failed to fetch fileUri: ${response.statusText}`\n )\n }\n\n arrayBuffer = await response.arrayBuffer()\n logger?.log(`fetched fileUri`, arrayBuffer.byteLength, arrayBuffer)\n }\n\n // Create a new copy of the ArrayBuffer to avoid detachment issues\n const bufferCopy = arrayBuffer.slice(0)\n logger?.log(\n `extractAudioAnalysis bitDepth=${bitDepth} len=${bufferCopy.byteLength}`,\n bufferCopy.slice(0, 100)\n )\n\n let actualBitDepth = bitDepth\n if (!actualBitDepth) {\n logger?.log(\n `extractAudioAnalysis bitDepth not provided -- getting wav file info`\n )\n const fileInfo = await getWavFileInfo(bufferCopy)\n actualBitDepth = fileInfo.bitDepth\n }\n logger?.log(`extractAudioAnalysis actualBitDepth=${actualBitDepth}`)\n\n const {\n pcmValues: channelData,\n min,\n max,\n } = await convertPCMToFloat32({\n buffer: arrayBuffer,\n bitDepth: actualBitDepth,\n })\n logger?.log(\n `extractAudioAnalysis convertPCMToFloat32 length=${channelData.length} range: [ ${min} :: ${max} ]`\n )\n\n // Apply position and length constraints to channelData if specified\n const startIndex = position\n const endIndex = length ? startIndex + length : channelData.length\n const constrainedChannelData = channelData.slice(startIndex, endIndex)\n\n return new Promise((resolve, reject) => {\n const blob = new Blob([InlineFeaturesExtractor], {\n type: 'application/javascript',\n })\n const url = URL.createObjectURL(blob)\n const worker = new Worker(url)\n\n worker.onmessage = (event) => {\n resolve(event.data.result)\n }\n\n worker.onerror = (error) => {\n reject(error)\n }\n\n worker.postMessage({\n command: 'process',\n channelData: constrainedChannelData,\n sampleRate,\n segmentDurationMs,\n logger,\n bitDepth,\n fullAudioDurationMs: durationMs,\n numberOfChannels,\n })\n })\n } else {\n if (!fileUri) {\n throw new Error('fileUri is required')\n }\n logger?.log(`extractAudioAnalysis`, {\n fileUri,\n segmentDurationMs,\n })\n const res = await ExpoAudioStreamModule.extractAudioAnalysis({\n fileUri,\n segmentDurationMs,\n features,\n position,\n length,\n })\n logger?.log(`extractAudioAnalysis`, res)\n return res\n }\n}\n\n/**\n * Generates a simplified preview of the audio waveform for quick visualization.\n * Ideal for UI rendering with a specified number of points.\n *\n * @param options - The options for the preview, including file URI and time range.\n * @returns A promise that resolves to the audio preview data.\n */\nexport async function extractPreview({\n fileUri,\n numberOfPoints = 100,\n startTimeMs = 0,\n endTimeMs = 30000, // First 30 seconds\n decodingOptions,\n logger,\n}: PreviewOptions): Promise<AudioAnalysis> {\n const durationMs = endTimeMs - startTimeMs\n const segmentDurationMs = Math.floor(durationMs / numberOfPoints)\n\n // Call extractAudioAnalysis with calculated parameters\n const analysis = await extractAudioAnalysis({\n fileUri,\n startTimeMs,\n endTimeMs,\n logger,\n segmentDurationMs,\n decodingOptions,\n })\n\n // Transform the result into AudioPreview format\n return analysis\n}\n\nexport const extractAudioData = async (props: ExtractAudioDataOptions) => {\n return await ExpoAudioStreamModule.extractAudioData(props)\n}"]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export interface ExtractWaveformProps {
|
|
2
|
-
fileUri: string;
|
|
3
|
-
numberOfSamples: number;
|
|
4
|
-
offset?: number;
|
|
5
|
-
length?: number;
|
|
6
|
-
}
|
|
7
|
-
export declare const extractWaveform: ({ fileUri, numberOfSamples, offset, length, }: ExtractWaveformProps) => Promise<unknown>;
|
|
8
|
-
//# sourceMappingURL=extractWaveform.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extractWaveform.d.ts","sourceRoot":"","sources":["../../src/AudioAnalysis/extractWaveform.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,oBAAoB;IACjC,OAAO,EAAE,MAAM,CAAA;IACf,eAAe,EAAE,MAAM,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;CAClB;AACD,eAAO,MAAM,eAAe,kDAKzB,oBAAoB,KAAG,QAAQ,OAAO,CAQxC,CAAA"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import ExpoAudioStreamModule from '../ExpoAudioStreamModule';
|
|
2
|
-
export const extractWaveform = async ({ fileUri, numberOfSamples, offset = 0, length, }) => {
|
|
3
|
-
const res = await ExpoAudioStreamModule.extractAudioAnalysis({
|
|
4
|
-
fileUri,
|
|
5
|
-
numberOfSamples,
|
|
6
|
-
offset,
|
|
7
|
-
length,
|
|
8
|
-
});
|
|
9
|
-
return res;
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=extractWaveform.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extractWaveform.js","sourceRoot":"","sources":["../../src/AudioAnalysis/extractWaveform.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,MAAM,0BAA0B,CAAA;AAQ5D,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAAE,EAClC,OAAO,EACP,eAAe,EACf,MAAM,GAAG,CAAC,EACV,MAAM,GACa,EAAoB,EAAE;IACzC,MAAM,GAAG,GAAG,MAAM,qBAAqB,CAAC,oBAAoB,CAAC;QACzD,OAAO;QACP,eAAe;QACf,MAAM;QACN,MAAM;KACT,CAAC,CAAA;IACF,OAAO,GAAG,CAAA;AACd,CAAC,CAAA","sourcesContent":["import ExpoAudioStreamModule from '../ExpoAudioStreamModule'\n\nexport interface ExtractWaveformProps {\n fileUri: string\n numberOfSamples: number\n offset?: number\n length?: number\n}\nexport const extractWaveform = async ({\n fileUri,\n numberOfSamples,\n offset = 0,\n length,\n}: ExtractWaveformProps): Promise<unknown> => {\n const res = await ExpoAudioStreamModule.extractAudioAnalysis({\n fileUri,\n numberOfSamples,\n offset,\n length,\n })\n return res\n}\n"]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { UseAudioRecorderState } from './ExpoAudioStream.types';
|
|
3
|
-
import { UseAudioRecorderProps } from './useAudioRecorder';
|
|
4
|
-
interface AudioRecorderProviderProps {
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
config?: UseAudioRecorderProps;
|
|
7
|
-
}
|
|
8
|
-
export declare const AudioRecorderProvider: React.FC<AudioRecorderProviderProps>;
|
|
9
|
-
export declare const useSharedAudioRecorder: () => UseAudioRecorderState;
|
|
10
|
-
export {};
|
|
11
|
-
//# sourceMappingURL=AudioRecorder.provider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AudioRecorder.provider.d.ts","sourceRoot":"","sources":["../src/AudioRecorder.provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoC,MAAM,OAAO,CAAA;AAExD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,qBAAqB,EAAoB,MAAM,oBAAoB,CAAA;AAwB5E,UAAU,0BAA0B;IAChC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,MAAM,CAAC,EAAE,qBAAqB,CAAA;CACjC;AAED,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAUtE,CAAA;AAED,eAAO,MAAM,sBAAsB,6BAQlC,CAAA"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// packages/expo-audio-stream/src/AudioRecorder.provider.tsx
|
|
2
|
-
import React, { createContext, useContext } from 'react';
|
|
3
|
-
import { useAudioRecorder } from './useAudioRecorder';
|
|
4
|
-
const initContext = {
|
|
5
|
-
isRecording: false,
|
|
6
|
-
isPaused: false,
|
|
7
|
-
durationMs: 0,
|
|
8
|
-
size: 0,
|
|
9
|
-
compression: undefined,
|
|
10
|
-
startRecording: async () => {
|
|
11
|
-
throw new Error('AudioRecorderProvider not found');
|
|
12
|
-
},
|
|
13
|
-
stopRecording: async () => {
|
|
14
|
-
throw new Error('AudioRecorderProvider not found');
|
|
15
|
-
},
|
|
16
|
-
pauseRecording: async () => {
|
|
17
|
-
throw new Error('AudioRecorderProvider not found');
|
|
18
|
-
},
|
|
19
|
-
resumeRecording: async () => {
|
|
20
|
-
throw new Error('AudioRecorderProvider not found');
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
const AudioRecorderContext = createContext(initContext);
|
|
24
|
-
export const AudioRecorderProvider = ({ children, config = {}, }) => {
|
|
25
|
-
const audioRecorder = useAudioRecorder(config);
|
|
26
|
-
return (<AudioRecorderContext.Provider value={audioRecorder}>
|
|
27
|
-
{children}
|
|
28
|
-
</AudioRecorderContext.Provider>);
|
|
29
|
-
};
|
|
30
|
-
export const useSharedAudioRecorder = () => {
|
|
31
|
-
const context = useContext(AudioRecorderContext);
|
|
32
|
-
if (!context) {
|
|
33
|
-
throw new Error('useSharedAudioRecorder must be used within an AudioRecorderProvider');
|
|
34
|
-
}
|
|
35
|
-
return context;
|
|
36
|
-
};
|
|
37
|
-
//# sourceMappingURL=AudioRecorder.provider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AudioRecorder.provider.js","sourceRoot":"","sources":["../src/AudioRecorder.provider.tsx"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAGxD,OAAO,EAAyB,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAE5E,MAAM,WAAW,GAA0B;IACvC,WAAW,EAAE,KAAK;IAClB,QAAQ,EAAE,KAAK;IACf,UAAU,EAAE,CAAC;IACb,IAAI,EAAE,CAAC;IACP,WAAW,EAAE,SAAS;IACtB,cAAc,EAAE,KAAK,IAAI,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;IACtD,CAAC;IACD,aAAa,EAAE,KAAK,IAAI,EAAE;QACtB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;IACtD,CAAC;IACD,cAAc,EAAE,KAAK,IAAI,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;IACtD,CAAC;IACD,eAAe,EAAE,KAAK,IAAI,EAAE;QACxB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;IACtD,CAAC;CACJ,CAAA;AAED,MAAM,oBAAoB,GAAG,aAAa,CAAwB,WAAW,CAAC,CAAA;AAO9E,MAAM,CAAC,MAAM,qBAAqB,GAAyC,CAAC,EACxE,QAAQ,EACR,MAAM,GAAG,EAAE,GACd,EAAE,EAAE;IACD,MAAM,aAAa,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAA;IAC9C,OAAO,CACH,CAAC,oBAAoB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,aAAa,CAAC,CAChD;YAAA,CAAC,QAAQ,CACb;QAAA,EAAE,oBAAoB,CAAC,QAAQ,CAAC,CACnC,CAAA;AACL,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,EAAE;IACvC,MAAM,OAAO,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAA;IAChD,IAAI,CAAC,OAAO,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACX,qEAAqE,CACxE,CAAA;IACL,CAAC;IACD,OAAO,OAAO,CAAA;AAClB,CAAC,CAAA","sourcesContent":["// packages/expo-audio-stream/src/AudioRecorder.provider.tsx\nimport React, { createContext, useContext } from 'react'\n\nimport { UseAudioRecorderState } from './ExpoAudioStream.types'\nimport { UseAudioRecorderProps, useAudioRecorder } from './useAudioRecorder'\n\nconst initContext: UseAudioRecorderState = {\n isRecording: false,\n isPaused: false,\n durationMs: 0,\n size: 0,\n compression: undefined,\n startRecording: async () => {\n throw new Error('AudioRecorderProvider not found')\n },\n stopRecording: async () => {\n throw new Error('AudioRecorderProvider not found')\n },\n pauseRecording: async () => {\n throw new Error('AudioRecorderProvider not found')\n },\n resumeRecording: async () => {\n throw new Error('AudioRecorderProvider not found')\n },\n}\n\nconst AudioRecorderContext = createContext<UseAudioRecorderState>(initContext)\n\ninterface AudioRecorderProviderProps {\n children: React.ReactNode\n config?: UseAudioRecorderProps\n}\n\nexport const AudioRecorderProvider: React.FC<AudioRecorderProviderProps> = ({\n children,\n config = {},\n}) => {\n const audioRecorder = useAudioRecorder(config)\n return (\n <AudioRecorderContext.Provider value={audioRecorder}>\n {children}\n </AudioRecorderContext.Provider>\n )\n}\n\nexport const useSharedAudioRecorder = () => {\n const context = useContext(AudioRecorderContext)\n if (!context) {\n throw new Error(\n 'useSharedAudioRecorder must be used within an AudioRecorderProvider'\n )\n }\n return context\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoAudioStream.native.d.ts","sourceRoot":"","sources":["../src/ExpoAudioStream.native.ts"],"names":[],"mappings":";AAKA,wBAAqD"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
// src/ExpoAudioStreamModule.ts
|
|
2
|
-
import { requireNativeModule } from 'expo-modules-core';
|
|
3
|
-
// It loads the native module object from the JSI or falls back to
|
|
4
|
-
// the bridge module (from NativeModulesProxy) if the remote debugger is on.
|
|
5
|
-
export default requireNativeModule('ExpoAudioStream');
|
|
6
|
-
//# sourceMappingURL=ExpoAudioStream.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoAudioStream.native.js","sourceRoot":"","sources":["../src/ExpoAudioStream.native.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAEvD,kEAAkE;AAClE,4EAA4E;AAC5E,eAAe,mBAAmB,CAAC,iBAAiB,CAAC,CAAA","sourcesContent":["// src/ExpoAudioStreamModule.ts\nimport { requireNativeModule } from 'expo-modules-core'\n\n// It loads the native module object from the JSI or falls back to\n// the bridge module (from NativeModulesProxy) if the remote debugger is on.\nexport default requireNativeModule('ExpoAudioStream')\n"]}
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
import { AudioAnalysis, AudioFeaturesOptions, DecodingConfig } from './AudioAnalysis/AudioAnalysis.types';
|
|
2
|
-
import { AudioAnalysisEvent } from './events';
|
|
3
|
-
export interface CompressionInfo {
|
|
4
|
-
size: number;
|
|
5
|
-
mimeType: string;
|
|
6
|
-
bitrate: number;
|
|
7
|
-
format: string;
|
|
8
|
-
compressedFileUri?: string;
|
|
9
|
-
}
|
|
10
|
-
export interface AudioStreamStatus {
|
|
11
|
-
isRecording: boolean;
|
|
12
|
-
isPaused: boolean;
|
|
13
|
-
durationMs: number;
|
|
14
|
-
size: number;
|
|
15
|
-
interval: number;
|
|
16
|
-
intervalAnalysis: number;
|
|
17
|
-
mimeType: string;
|
|
18
|
-
compression?: CompressionInfo;
|
|
19
|
-
}
|
|
20
|
-
export interface AudioDataEvent {
|
|
21
|
-
data: string | Float32Array;
|
|
22
|
-
position: number;
|
|
23
|
-
fileUri: string;
|
|
24
|
-
eventDataSize: number;
|
|
25
|
-
totalSize: number;
|
|
26
|
-
compression?: CompressionInfo & {
|
|
27
|
-
data?: string | Blob;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
export type EncodingType = 'pcm_32bit' | 'pcm_16bit' | 'pcm_8bit';
|
|
31
|
-
export type SampleRate = 16000 | 44100 | 48000;
|
|
32
|
-
export type BitDepth = 8 | 16 | 32;
|
|
33
|
-
export type PCMFormat = `pcm_${BitDepth}bit`;
|
|
34
|
-
export type ConsoleLike = {
|
|
35
|
-
log: (message: string, ...args: unknown[]) => void;
|
|
36
|
-
debug: (message: string, ...args: unknown[]) => void;
|
|
37
|
-
info: (message: string, ...args: unknown[]) => void;
|
|
38
|
-
warn: (message: string, ...args: unknown[]) => void;
|
|
39
|
-
error: (message: string, ...args: unknown[]) => void;
|
|
40
|
-
};
|
|
41
|
-
export interface Chunk {
|
|
42
|
-
text: string;
|
|
43
|
-
timestamp: [number, number | null];
|
|
44
|
-
}
|
|
45
|
-
export interface TranscriberData {
|
|
46
|
-
id: string;
|
|
47
|
-
isBusy: boolean;
|
|
48
|
-
text: string;
|
|
49
|
-
startTime: number;
|
|
50
|
-
endTime: number;
|
|
51
|
-
chunks: Chunk[];
|
|
52
|
-
}
|
|
53
|
-
export interface AudioRecording {
|
|
54
|
-
fileUri: string;
|
|
55
|
-
filename: string;
|
|
56
|
-
durationMs: number;
|
|
57
|
-
size: number;
|
|
58
|
-
mimeType: string;
|
|
59
|
-
channels: number;
|
|
60
|
-
bitDepth: BitDepth;
|
|
61
|
-
sampleRate: SampleRate;
|
|
62
|
-
createdAt?: number;
|
|
63
|
-
transcripts?: TranscriberData[];
|
|
64
|
-
analysisData?: AudioAnalysis;
|
|
65
|
-
compression?: CompressionInfo & {
|
|
66
|
-
compressedFileUri: string;
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
export interface StartRecordingResult {
|
|
70
|
-
fileUri: string;
|
|
71
|
-
mimeType: string;
|
|
72
|
-
channels?: number;
|
|
73
|
-
bitDepth?: BitDepth;
|
|
74
|
-
sampleRate?: SampleRate;
|
|
75
|
-
compression?: CompressionInfo & {
|
|
76
|
-
compressedFileUri: string;
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
export interface AudioSessionConfig {
|
|
80
|
-
category?: 'Ambient' | 'SoloAmbient' | 'Playback' | 'Record' | 'PlayAndRecord' | 'MultiRoute';
|
|
81
|
-
mode?: 'Default' | 'VoiceChat' | 'VideoChat' | 'GameChat' | 'VideoRecording' | 'Measurement' | 'MoviePlayback' | 'SpokenAudio';
|
|
82
|
-
categoryOptions?: ('MixWithOthers' | 'DuckOthers' | 'InterruptSpokenAudioAndMixWithOthers' | 'AllowBluetooth' | 'AllowBluetoothA2DP' | 'AllowAirPlay' | 'DefaultToSpeaker')[];
|
|
83
|
-
}
|
|
84
|
-
export interface IOSConfig {
|
|
85
|
-
audioSession?: AudioSessionConfig;
|
|
86
|
-
}
|
|
87
|
-
export type RecordingInterruptionReason = 'audioFocusLoss' | 'audioFocusGain' | 'phoneCall' | 'phoneCallEnded' | 'recordingStopped';
|
|
88
|
-
export interface RecordingInterruptionEvent {
|
|
89
|
-
reason: RecordingInterruptionReason;
|
|
90
|
-
isPaused: boolean;
|
|
91
|
-
}
|
|
92
|
-
export interface RecordingConfig {
|
|
93
|
-
sampleRate?: SampleRate;
|
|
94
|
-
channels?: 1 | 2;
|
|
95
|
-
encoding?: EncodingType;
|
|
96
|
-
interval?: number;
|
|
97
|
-
intervalAnalysis?: number;
|
|
98
|
-
keepAwake?: boolean;
|
|
99
|
-
showNotification?: boolean;
|
|
100
|
-
showWaveformInNotification?: boolean;
|
|
101
|
-
notification?: NotificationConfig;
|
|
102
|
-
enableProcessing?: boolean;
|
|
103
|
-
ios?: IOSConfig;
|
|
104
|
-
segmentDurationMs?: number;
|
|
105
|
-
features?: AudioFeaturesOptions;
|
|
106
|
-
onAudioStream?: (_: AudioDataEvent) => Promise<void>;
|
|
107
|
-
onAudioAnalysis?: (_: AudioAnalysisEvent) => Promise<void>;
|
|
108
|
-
compression?: {
|
|
109
|
-
enabled: boolean;
|
|
110
|
-
format: 'aac' | 'opus';
|
|
111
|
-
bitrate?: number;
|
|
112
|
-
};
|
|
113
|
-
autoResumeAfterInterruption?: boolean;
|
|
114
|
-
onRecordingInterrupted?: (_: RecordingInterruptionEvent) => void;
|
|
115
|
-
outputDirectory?: string;
|
|
116
|
-
filename?: string;
|
|
117
|
-
}
|
|
118
|
-
export interface NotificationConfig {
|
|
119
|
-
title?: string;
|
|
120
|
-
text?: string;
|
|
121
|
-
icon?: string;
|
|
122
|
-
android?: {
|
|
123
|
-
channelId?: string;
|
|
124
|
-
channelName?: string;
|
|
125
|
-
channelDescription?: string;
|
|
126
|
-
notificationId?: number;
|
|
127
|
-
actions?: NotificationAction[];
|
|
128
|
-
waveform?: WaveformConfig;
|
|
129
|
-
lightColor?: string;
|
|
130
|
-
priority?: 'min' | 'low' | 'default' | 'high' | 'max';
|
|
131
|
-
accentColor?: string;
|
|
132
|
-
};
|
|
133
|
-
ios?: {
|
|
134
|
-
categoryIdentifier?: string;
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
export interface NotificationAction {
|
|
138
|
-
title: string;
|
|
139
|
-
identifier: string;
|
|
140
|
-
icon?: string;
|
|
141
|
-
}
|
|
142
|
-
export interface WaveformConfig {
|
|
143
|
-
color?: string;
|
|
144
|
-
opacity?: number;
|
|
145
|
-
strokeWidth?: number;
|
|
146
|
-
style?: 'stroke' | 'fill';
|
|
147
|
-
mirror?: boolean;
|
|
148
|
-
height?: number;
|
|
149
|
-
}
|
|
150
|
-
export interface ExtractAudioDataOptions {
|
|
151
|
-
fileUri: string;
|
|
152
|
-
startTimeMs?: number;
|
|
153
|
-
endTimeMs?: number;
|
|
154
|
-
position?: number;
|
|
155
|
-
length?: number;
|
|
156
|
-
/** Include normalized audio data in [-1, 1] range */
|
|
157
|
-
includeNormalizedData?: boolean;
|
|
158
|
-
/** Include base64 encoded string representation of the audio data */
|
|
159
|
-
includeBase64Data?: boolean;
|
|
160
|
-
/** Include WAV header in the PCM data (makes it a valid WAV file) */
|
|
161
|
-
includeWavHeader?: boolean;
|
|
162
|
-
/** Logger for debugging - can pass console directly. */
|
|
163
|
-
logger?: ConsoleLike;
|
|
164
|
-
/** Compute the checksum of the pcm data */
|
|
165
|
-
computeChecksum?: boolean;
|
|
166
|
-
/** Target config for the normalized audio (Android and Web) */
|
|
167
|
-
decodingOptions?: DecodingConfig;
|
|
168
|
-
}
|
|
169
|
-
export interface ExtractedAudioData {
|
|
170
|
-
/** Raw PCM audio data */
|
|
171
|
-
pcmData: Uint8Array;
|
|
172
|
-
/** Normalized audio data in [-1, 1] range (when includeNormalizedData is true) */
|
|
173
|
-
normalizedData?: Float32Array;
|
|
174
|
-
/** Base64 encoded string representation of the audio data (when includeBase64Data is true) */
|
|
175
|
-
base64Data?: string;
|
|
176
|
-
/** Sample rate in Hz (e.g., 44100, 48000) */
|
|
177
|
-
sampleRate: number;
|
|
178
|
-
/** Number of audio channels (1 for mono, 2 for stereo) */
|
|
179
|
-
channels: number;
|
|
180
|
-
/** Bits per sample (8, 16, or 32) */
|
|
181
|
-
bitDepth: BitDepth;
|
|
182
|
-
/** Duration of the audio in milliseconds */
|
|
183
|
-
durationMs: number;
|
|
184
|
-
/** PCM format identifier (e.g., "pcm_16bit") */
|
|
185
|
-
format: PCMFormat;
|
|
186
|
-
/** Total number of audio samples per channel */
|
|
187
|
-
samples: number;
|
|
188
|
-
/** Whether the pcmData includes a WAV header */
|
|
189
|
-
hasWavHeader?: boolean;
|
|
190
|
-
/** CRC32 Checksum of pcm data */
|
|
191
|
-
checksum?: number;
|
|
192
|
-
}
|
|
193
|
-
export interface UseAudioRecorderState {
|
|
194
|
-
startRecording: (_: RecordingConfig) => Promise<StartRecordingResult>;
|
|
195
|
-
stopRecording: () => Promise<AudioRecording | null>;
|
|
196
|
-
pauseRecording: () => Promise<void>;
|
|
197
|
-
resumeRecording: () => Promise<void>;
|
|
198
|
-
isRecording: boolean;
|
|
199
|
-
isPaused: boolean;
|
|
200
|
-
durationMs: number;
|
|
201
|
-
size: number;
|
|
202
|
-
compression?: CompressionInfo;
|
|
203
|
-
analysisData?: AudioAnalysis;
|
|
204
|
-
onRecordingInterrupted?: (_: RecordingInterruptionEvent) => void;
|
|
205
|
-
}
|
|
206
|
-
//# sourceMappingURL=ExpoAudioStream.types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoAudioStream.types.d.ts","sourceRoot":"","sources":["../src/ExpoAudioStream.types.ts"],"names":[],"mappings":"AACA,OAAO,EACH,aAAa,EACb,oBAAoB,EACpB,cAAc,EACjB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAE7C,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC7B;AAED,MAAM,WAAW,iBAAiB;IAC9B,WAAW,EAAE,OAAO,CAAA;IACpB,QAAQ,EAAE,OAAO,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,gBAAgB,EAAE,MAAM,CAAA;IACxB,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,eAAe,CAAA;CAChC;AAED,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,GAAG,YAAY,CAAA;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,aAAa,EAAE,MAAM,CAAA;IACrB,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,eAAe,GAAG;QAC5B,IA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AE,eAAe,CAAA;IAC7B,YAAY,CAAC,EAAE,aAAa,CAAA;IAC5B,sBAAsB,CAAC,EAAE,CAAC,CAAC,EAAE,0BAA0B,KAAK,IAAI,CAAA;CACnE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoAudioStream.types.js","sourceRoot":"","sources":["../src/ExpoAudioStream.types.ts"],"names":[],"mappings":"","sourcesContent":["// packages/expo-audio-stream/src/ExpoAudioStream.types.ts\nimport {\n AudioAnalysis,\n AudioFeaturesOptions,\n DecodingConfig,\n} from './AudioAnalysis/AudioAnalysis.types'\nimport { AudioAnalysisEvent } from './events'\n\nexport interface CompressionInfo {\n size: number\n mimeType: string\n bitrate: number\n format: string\n compressedFileUri?: string\n}\n\nexport interface AudioStreamStatus {\n isRecording: boolean\n isPaused: boolean\n durationMs: number\n size: number\n interval: number\n intervalAnalysis: number\n mimeType: string\n compression?: CompressionInfo\n}\n\nexport interface AudioDataEvent {\n data: string | Float32Array\n position: number\n fileUri: string\n eventDataSize: number\n totalSize: number\n compression?: CompressionInfo & {\n data?: string | Blob // Base64 (native) or Float32Array (web) encoded compressed data chunk\n }\n}\n\nexport type EncodingType = 'pcm_32bit' | 'pcm_16bit' | 'pcm_8bit'\nexport type SampleRate = 16000 | 44100 | 48000\nexport type BitDepth = 8 | 16 | 32\nexport type PCMFormat = `pcm_${BitDepth}bit`\n\nexport type ConsoleLike = {\n log: (message: string, ...args: unknown[]) => void\n debug: (message: string, ...args: unknown[]) => void\n info: (message: string, ...args: unknown[]) => void\n warn: (message: string, ...args: unknown[]) => void\n error: (message: string, ...args: unknown[]) => void\n}\n\nexport interface Chunk {\n text: string\n timestamp: [number, number | null]\n}\n\nexport interface TranscriberData {\n id: string\n isBusy: boolean\n text: string\n startTime: number\n endTime: number\n chunks: Chunk[]\n}\n\nexport interface AudioRecording {\n fileUri: string\n filename: string\n durationMs: number\n size: number\n mimeType: string\n channels: number\n bitDepth: BitDepth\n sampleRate: SampleRate\n createdAt?: number\n transcripts?: TranscriberData[]\n analysisData?: AudioAnalysis // Analysis data for the recording depending on enableProcessing flag\n compression?: CompressionInfo & {\n compressedFileUri: string\n }\n}\n\nexport interface StartRecordingResult {\n fileUri: string\n mimeType: string\n channels?: number\n bitDepth?: BitDepth\n sampleRate?: SampleRate\n compression?: CompressionInfo & {\n compressedFileUri: string\n }\n}\n\nexport interface AudioSessionConfig {\n category?:\n | 'Ambient'\n | 'SoloAmbient'\n | 'Playback'\n | 'Record'\n | 'PlayAndRecord'\n | 'MultiRoute'\n mode?:\n | 'Default'\n | 'VoiceChat'\n | 'VideoChat'\n | 'GameChat'\n | 'VideoRecording'\n | 'Measurement'\n | 'MoviePlayback'\n | 'SpokenAudio'\n categoryOptions?: (\n | 'MixWithOthers'\n | 'DuckOthers'\n | 'InterruptSpokenAudioAndMixWithOthers'\n | 'AllowBluetooth'\n | 'AllowBluetoothA2DP'\n | 'AllowAirPlay'\n | 'DefaultToSpeaker'\n )[]\n}\n\nexport interface IOSConfig {\n audioSession?: AudioSessionConfig\n}\n\n// Add new type for interruption reasons\nexport type RecordingInterruptionReason =\n | 'audioFocusLoss'\n | 'audioFocusGain'\n | 'phoneCall'\n | 'phoneCallEnded'\n | 'recordingStopped'\n\n// Add new interface for interruption events\nexport interface RecordingInterruptionEvent {\n reason: RecordingInterruptionReason\n isPaused: boolean\n}\n\nexport interface RecordingConfig {\n // Sample rate for recording (16000, 44100, or 48000 Hz)\n sampleRate?: SampleRate\n\n // Number of audio channels (1 for mono, 2 for stereo)\n channels?: 1 | 2\n\n // Encoding type for the recording (pcm_32bit, pcm_16bit, pcm_8bit)\n encoding?: EncodingType\n\n // Interval in milliseconds at which to emit recording data\n interval?: number\n\n // Interval in milliseconds at which to emit analysis data\n intervalAnalysis?: number\n\n // Keep the device awake while recording (default is false)\n keepAwake?: boolean\n\n // Show a notification during recording (default is false)\n showNotification?: boolean\n\n // Show waveform in the notification (Android only, when showNotification is true)\n showWaveformInNotification?: boolean\n\n // Configuration for the notification\n notification?: NotificationConfig\n\n // Enable audio processing (default is false)\n enableProcessing?: boolean\n\n // iOS-specific configuration\n ios?: IOSConfig\n\n // Duration of each segment in milliseconds (default: 100)\n segmentDurationMs?: number\n\n // Feature options to extract (default is empty)\n features?: AudioFeaturesOptions\n\n // Callback function to handle audio stream\n onAudioStream?: (_: AudioDataEvent) => Promise<void>\n\n // Callback function to handle audio features extraction results\n onAudioAnalysis?: (_: AudioAnalysisEvent) => Promise<void>\n\n compression?: {\n enabled: boolean\n format: 'aac' | 'opus'\n bitrate?: number\n }\n\n // Whether to automatically resume recording after an interruption (default is false)\n autoResumeAfterInterruption?: boolean\n\n // Optional callback to handle recording interruptions\n onRecordingInterrupted?: (_: RecordingInterruptionEvent) => void\n\n // Optional output configuration\n outputDirectory?: string // If not provided, uses default app directory\n filename?: string // If not provided, uses UUID\n}\n\nexport interface NotificationConfig {\n // Title of the notification\n title?: string\n\n // Main text content of the notification\n text?: string\n\n // Icon to be displayed in the notification (resource name or URI)\n icon?: string\n\n // Android-specific notification configuration\n android?: {\n // Unique identifier for the notification channel\n channelId?: string\n\n // User-visible name of the notification channel\n channelName?: string\n\n // User-visible description of the notification channel\n channelDescription?: string\n\n // Unique identifier for this notification\n notificationId?: number\n\n // List of actions that can be performed from the notification\n actions?: NotificationAction[]\n\n // Configuration for the waveform visualization in the notification\n waveform?: WaveformConfig\n\n // Color of the notification LED (if device supports it)\n lightColor?: string\n\n // Priority of the notification (affects how it's displayed)\n priority?: 'min' | 'low' | 'default' | 'high' | 'max'\n\n // Accent color for the notification (used for the app icon and buttons)\n accentColor?: string\n }\n\n // iOS-specific notification configuration\n ios?: {\n // Identifier for the notification category (used for grouping similar notifications)\n categoryIdentifier?: string\n }\n}\n\nexport interface NotificationAction {\n // Display title for the action\n title: string\n\n // Unique identifier for the action\n identifier: string\n\n // Icon to be displayed for the action (Android only)\n icon?: string\n}\n\nexport interface WaveformConfig {\n color?: string // The color of the waveform (e.g., \"#FFFFFF\" for white)\n opacity?: number // Opacity of the waveform (0.0 - 1.0)\n strokeWidth?: number // Width of the waveform line (default: 1.5)\n style?: 'stroke' | 'fill' // Drawing style: \"stroke\" for outline, \"fill\" for solid\n mirror?: boolean // Whether to mirror the waveform (symmetrical display)\n height?: number // Height of the waveform view in dp (default: 64)\n}\n\nexport interface ExtractAudioDataOptions {\n fileUri: string\n // Time-based range (mutually exclusive with byte-based range)\n startTimeMs?: number\n endTimeMs?: number\n // Byte-based range (mutually exclusive with time-based range)\n position?: number\n length?: number\n /** Include normalized audio data in [-1, 1] range */\n includeNormalizedData?: boolean\n /** Include base64 encoded string representation of the audio data */\n includeBase64Data?: boolean\n /** Include WAV header in the PCM data (makes it a valid WAV file) */\n includeWavHeader?: boolean\n /** Logger for debugging - can pass console directly. */\n logger?: ConsoleLike\n /** Compute the checksum of the pcm data */\n computeChecksum?: boolean\n /** Target config for the normalized audio (Android and Web) */\n decodingOptions?: DecodingConfig\n}\n\nexport interface ExtractedAudioData {\n /** Raw PCM audio data */\n pcmData: Uint8Array\n /** Normalized audio data in [-1, 1] range (when includeNormalizedData is true) */\n normalizedData?: Float32Array\n /** Base64 encoded string representation of the audio data (when includeBase64Data is true) */\n base64Data?: string\n /** Sample rate in Hz (e.g., 44100, 48000) */\n sampleRate: number\n /** Number of audio channels (1 for mono, 2 for stereo) */\n channels: number\n /** Bits per sample (8, 16, or 32) */\n bitDepth: BitDepth\n /** Duration of the audio in milliseconds */\n durationMs: number\n /** PCM format identifier (e.g., \"pcm_16bit\") */\n format: PCMFormat\n /** Total number of audio samples per channel */\n samples: number\n /** Whether the pcmData includes a WAV header */\n hasWavHeader?: boolean\n /** CRC32 Checksum of pcm data */\n checksum?: number\n}\n\nexport interface UseAudioRecorderState {\n startRecording: (_: RecordingConfig) => Promise<StartRecordingResult>\n stopRecording: () => Promise<AudioRecording | null>\n pauseRecording: () => Promise<void>\n resumeRecording: () => Promise<void>\n isRecording: boolean\n isPaused: boolean\n durationMs: number // Duration of the recording\n size: number // Size in bytes of the recorded audio\n compression?: CompressionInfo\n analysisData?: AudioAnalysis // Analysis data for the recording depending on enableProcessing flag\n onRecordingInterrupted?: (_: RecordingInterruptionEvent) => void\n}\n"]}
|