@siteed/expo-audio-stream 1.0.2 → 1.0.3
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/.size-limit.json +6 -0
- package/build/AudioAnalysis/AudioAnalysis.types.d.ts +76 -0
- package/build/AudioAnalysis/AudioAnalysis.types.d.ts.map +1 -0
- package/build/AudioAnalysis/AudioAnalysis.types.js +3 -0
- package/build/AudioAnalysis/AudioAnalysis.types.js.map +1 -0
- package/build/AudioAnalysis/extractAudioAnalysis.d.ts +4 -0
- package/build/AudioAnalysis/extractAudioAnalysis.d.ts.map +1 -0
- package/build/AudioAnalysis/extractAudioAnalysis.js +101 -0
- package/build/AudioAnalysis/extractAudioAnalysis.js.map +1 -0
- package/build/AudioAnalysis/extractWaveform.d.ts +8 -0
- package/build/AudioAnalysis/extractWaveform.d.ts.map +1 -0
- package/build/AudioAnalysis/extractWaveform.js +14 -0
- package/build/AudioAnalysis/extractWaveform.js.map +1 -0
- package/build/AudioRecorder.provider.d.ts +14 -1
- package/build/AudioRecorder.provider.d.ts.map +1 -1
- package/build/AudioRecorder.provider.js +17 -4
- package/build/AudioRecorder.provider.js.map +1 -1
- package/build/ExpoAudioStream.types.d.ts +26 -84
- package/build/ExpoAudioStream.types.d.ts.map +1 -1
- package/build/ExpoAudioStream.types.js.map +1 -1
- package/build/ExpoAudioStream.web.d.ts +6 -5
- package/build/ExpoAudioStream.web.d.ts.map +1 -1
- package/build/ExpoAudioStream.web.js +9 -8
- package/build/ExpoAudioStream.web.js.map +1 -1
- package/build/ExpoAudioStreamModule.d.ts.map +1 -1
- package/build/ExpoAudioStreamModule.js +5 -1
- package/build/ExpoAudioStreamModule.js.map +1 -1
- package/build/{WebRecorder.d.ts → WebRecorder.web.d.ts} +7 -3
- package/build/WebRecorder.web.d.ts.map +1 -0
- package/build/{WebRecorder.js → WebRecorder.web.js} +74 -29
- package/build/WebRecorder.web.js.map +1 -0
- package/build/constants.d.ts +11 -0
- package/build/constants.d.ts.map +1 -0
- package/build/constants.js +14 -0
- package/build/constants.js.map +1 -0
- package/build/events.d.ts +6 -0
- package/build/events.d.ts.map +1 -0
- package/build/events.js +15 -0
- package/build/events.js.map +1 -0
- package/build/index.d.ts +8 -16
- package/build/index.d.ts.map +1 -1
- package/build/index.js +6 -112
- package/build/index.js.map +1 -1
- package/build/logger.d.ts +9 -0
- package/build/logger.d.ts.map +1 -0
- package/build/logger.js +17 -0
- package/build/logger.js.map +1 -0
- package/build/{useAudioRecording.d.ts → useAudioRecorder.d.ts} +6 -7
- package/build/useAudioRecorder.d.ts.map +1 -0
- package/build/{useAudioRecording.js → useAudioRecorder.js} +69 -65
- package/build/useAudioRecorder.js.map +1 -0
- package/build/utils/convertPCMToFloat32.d.ts +11 -0
- package/build/utils/convertPCMToFloat32.d.ts.map +1 -0
- package/build/utils/convertPCMToFloat32.js +41 -0
- package/build/utils/convertPCMToFloat32.js.map +1 -0
- package/build/utils/encodingToBitDepth.d.ts +5 -0
- package/build/utils/encodingToBitDepth.d.ts.map +1 -0
- package/build/utils/encodingToBitDepth.js +13 -0
- package/build/utils/encodingToBitDepth.js.map +1 -0
- package/build/utils/getWavFileInfo.d.ts +25 -0
- package/build/utils/getWavFileInfo.d.ts.map +1 -0
- package/build/utils/getWavFileInfo.js +89 -0
- package/build/utils/getWavFileInfo.js.map +1 -0
- package/build/utils/writeWavHeader.d.ts +9 -0
- package/build/utils/writeWavHeader.d.ts.map +1 -0
- package/build/utils/writeWavHeader.js +41 -0
- package/build/utils/writeWavHeader.js.map +1 -0
- package/build/workers/InlineFeaturesExtractor.web.d.ts +2 -0
- package/build/workers/InlineFeaturesExtractor.web.d.ts.map +1 -0
- package/build/workers/InlineFeaturesExtractor.web.js +303 -0
- package/build/workers/InlineFeaturesExtractor.web.js.map +1 -0
- package/build/workers/inlineAudioWebWorker.web.d.ts +2 -0
- package/build/workers/inlineAudioWebWorker.web.d.ts.map +1 -0
- package/build/workers/inlineAudioWebWorker.web.js +243 -0
- package/build/workers/inlineAudioWebWorker.web.js.map +1 -0
- package/ios/AudioStreamManager.swift +39 -2
- package/ios/ExpoAudioStreamModule.swift +10 -0
- package/package.json +7 -6
- package/plugin/tsconfig.json +1 -1
- package/publish.sh +0 -0
- package/src/AudioAnalysis/AudioAnalysis.types.ts +85 -0
- package/src/AudioAnalysis/extractAudioAnalysis.ts +136 -0
- package/src/AudioAnalysis/extractWaveform.ts +25 -0
- package/src/AudioRecorder.provider.tsx +35 -7
- package/src/ExpoAudioStream.types.ts +33 -94
- package/src/ExpoAudioStream.web.ts +17 -16
- package/src/ExpoAudioStreamModule.ts +6 -1
- package/src/{WebRecorder.ts → WebRecorder.web.ts} +85 -33
- package/src/constants.ts +18 -0
- package/src/events.ts +25 -0
- package/src/index.ts +8 -169
- package/src/logger.ts +26 -0
- package/src/{useAudioRecording.tsx → useAudioRecorder.tsx} +141 -136
- package/src/utils/convertPCMToFloat32.ts +48 -0
- package/src/utils/encodingToBitDepth.ts +18 -0
- package/src/utils/getWavFileInfo.ts +125 -0
- package/src/utils/writeWavHeader.ts +56 -0
- package/src/workers/InlineFeaturesExtractor.web.tsx +302 -0
- package/src/workers/inlineAudioWebWorker.web.tsx +242 -0
- package/build/WebRecorder.d.ts.map +0 -1
- package/build/WebRecorder.js.map +0 -1
- package/build/inlineAudioWebWorker.d.ts +0 -3
- package/build/inlineAudioWebWorker.d.ts.map +0 -1
- package/build/inlineAudioWebWorker.js +0 -340
- package/build/inlineAudioWebWorker.js.map +0 -1
- package/build/useAudioRecording.d.ts.map +0 -1
- package/build/useAudioRecording.js.map +0 -1
- package/build/utils.d.ts +0 -31
- package/build/utils.d.ts.map +0 -1
- package/build/utils.js +0 -143
- package/build/utils.js.map +0 -1
- package/src/inlineAudioWebWorker.tsx +0 -340
- package/src/utils.ts +0 -189
package/.size-limit.json
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents various audio features extracted from an audio signal.
|
|
3
|
+
*/
|
|
4
|
+
export interface AudioFeatures {
|
|
5
|
+
energy: number;
|
|
6
|
+
mfcc: number[];
|
|
7
|
+
rms: number;
|
|
8
|
+
minAmplitude: number;
|
|
9
|
+
maxAmplitude: number;
|
|
10
|
+
zcr: number;
|
|
11
|
+
spectralCentroid: number;
|
|
12
|
+
spectralFlatness: number;
|
|
13
|
+
spectralRolloff: number;
|
|
14
|
+
spectralBandwidth: number;
|
|
15
|
+
chromagram: number[];
|
|
16
|
+
tempo: number;
|
|
17
|
+
hnr: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Options to specify which audio features to extract.
|
|
21
|
+
*/
|
|
22
|
+
export interface AudioFeaturesOptions {
|
|
23
|
+
energy?: boolean;
|
|
24
|
+
mfcc?: boolean;
|
|
25
|
+
rms?: boolean;
|
|
26
|
+
zcr?: boolean;
|
|
27
|
+
spectralCentroid?: boolean;
|
|
28
|
+
spectralFlatness?: boolean;
|
|
29
|
+
spectralRolloff?: boolean;
|
|
30
|
+
spectralBandwidth?: boolean;
|
|
31
|
+
chromagram?: boolean;
|
|
32
|
+
tempo?: boolean;
|
|
33
|
+
hnr?: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Represents a single data point in the audio analysis.
|
|
37
|
+
*/
|
|
38
|
+
export interface DataPoint {
|
|
39
|
+
id: number;
|
|
40
|
+
amplitude: number;
|
|
41
|
+
activeSpeech?: boolean;
|
|
42
|
+
dB?: number;
|
|
43
|
+
silent?: boolean;
|
|
44
|
+
features?: AudioFeatures;
|
|
45
|
+
startTime?: number;
|
|
46
|
+
endTime?: number;
|
|
47
|
+
startPosition?: number;
|
|
48
|
+
endPosition?: number;
|
|
49
|
+
samples?: number;
|
|
50
|
+
speaker?: number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Represents the complete data from the audio analysis.
|
|
54
|
+
*/
|
|
55
|
+
export interface AudioAnalysisData {
|
|
56
|
+
pointsPerSecond: number;
|
|
57
|
+
durationMs: number;
|
|
58
|
+
bitDepth: number;
|
|
59
|
+
samples: number;
|
|
60
|
+
numberOfChannels: number;
|
|
61
|
+
sampleRate: number;
|
|
62
|
+
dataPoints: DataPoint[];
|
|
63
|
+
amplitudeRange: {
|
|
64
|
+
min: number;
|
|
65
|
+
max: number;
|
|
66
|
+
};
|
|
67
|
+
speakerChanges?: {
|
|
68
|
+
timestamp: number;
|
|
69
|
+
speaker: number;
|
|
70
|
+
}[];
|
|
71
|
+
}
|
|
72
|
+
export interface AudioAnalysisEventPayload {
|
|
73
|
+
analysis: AudioAnalysisData;
|
|
74
|
+
visualizationDuration: number;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=AudioAnalysis.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AudioAnalysis.types.d.ts","sourceRoot":"","sources":["../../src/AudioAnalysis/AudioAnalysis.types.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,gBAAgB,CAAC,E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AAqB,EAAE,MAAM,CAAC;CAC/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AudioAnalysis.types.js","sourceRoot":"","sources":["../../src/AudioAnalysis/AudioAnalysis.types.ts"],"names":[],"mappings":"AAAA,sEAAsE","sourcesContent":["// packages/expo-audio-stream/src/AudioAnalysis/AudioAnalysis.types.ts\n\n/**\n * Represents various audio features extracted from an audio signal.\n */\nexport interface AudioFeatures {\n energy: number; // The infinite integral of the squared signal, representing the overall energy of the audio.\n mfcc: number[]; // Mel-frequency cepstral coefficients, describing the short-term power spectrum of a sound.\n rms: number; // Root mean square value, indicating the amplitude of the audio signal.\n minAmplitude: number; // Minimum amplitude value in the audio signal.\n maxAmplitude: number; // Maximum amplitude value in the audio signal.\n zcr: number; // Zero-crossing rate, indicating the rate at which the signal changes sign.\n spectralCentroid: number; // The center of mass of the spectrum, indicating the brightness of the sound.\n spectralFlatness: number; // Measure of the flatness of the spectrum, indicating how noise-like the signal is.\n spectralRolloff: number; // The frequency below which a specified percentage (usually 85%) of the total spectral energy lies.\n spectralBandwidth: number; // The width of the spectrum, indicating the range of frequencies present.\n chromagram: number[]; // Chromagram, representing the 12 different pitch classes of the audio.\n tempo: number; // Estimated tempo of the audio signal, measured in beats per minute (BPM).\n hnr: number; // Harmonics-to-noise ratio, indicating the proportion of harmonics to noise in the audio signal.\n}\n\n/**\n * Options to specify which audio features to extract.\n */\nexport interface AudioFeaturesOptions {\n energy?: boolean;\n mfcc?: boolean;\n rms?: boolean;\n zcr?: boolean;\n spectralCentroid?: boolean;\n spectralFlatness?: boolean;\n spectralRolloff?: boolean;\n spectralBandwidth?: boolean;\n chromagram?: boolean;\n tempo?: boolean;\n hnr?: boolean;\n}\n\n/**\n * Represents a single data point in the audio analysis.\n */\nexport interface DataPoint {\n id: number;\n amplitude: number;\n activeSpeech?: boolean;\n dB?: number;\n silent?: boolean;\n features?: AudioFeatures;\n startTime?: number;\n endTime?: number;\n // start / end position in bytes\n startPosition?: number;\n endPosition?: number;\n // number of audio samples for this point (samples size depends on bit depth)\n samples?: number;\n // TODO: speaker detection\n speaker?: number;\n}\n\n/**\n * Represents the complete data from the audio analysis.\n */\nexport interface AudioAnalysisData {\n pointsPerSecond: number; // How many consolidated value per second\n durationMs: number; // Duration of the audio in milliseconds\n bitDepth: number; // Bit depth of the audio\n samples: number; // Size of the audio in bytes\n numberOfChannels: number; // Number of audio channels\n sampleRate: number; // Sample rate of the audio\n dataPoints: DataPoint[]; // Array of data points from the analysis.\n amplitudeRange: {\n min: number;\n max: number;\n };\n // TODO: speaker detection\n speakerChanges?: {\n timestamp: number; // Timestamp of the speaker change in milliseconds.\n speaker: number; // Speaker identifier.\n }[];\n}\n\nexport interface AudioAnalysisEventPayload {\n analysis: AudioAnalysisData;\n visualizationDuration: number;\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AudioAnalysisData } from "./AudioAnalysis.types";
|
|
2
|
+
import { ExtractMetadataProps } from "../useAudioRecorder";
|
|
3
|
+
export declare const extractAudioAnalysis: ({ fileUri, pointsPerSecond, arrayBuffer, bitDepth, skipWavHeader, durationMs, sampleRate, numberOfChannels, algorithm, features, featuresExtratorUrl, }: ExtractMetadataProps) => Promise<AudioAnalysisData>;
|
|
4
|
+
//# sourceMappingURL=extractAudioAnalysis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractAudioAnalysis.d.ts","sourceRoot":"","sources":["../../src/AudioAnalysis/extractAudioAnalysis.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAI1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAO3D,eAAO,MAAM,oBAAoB,4JAY9B,oBAAoB,KAAG,OAAO,CAAC,iBAAiB,CA+GlD,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import ExpoAudioStreamModule from "../ExpoAudioStreamModule";
|
|
2
|
+
import { isWeb } from "../constants";
|
|
3
|
+
import { getLogger } from "../logger";
|
|
4
|
+
import { convertPCMToFloat32 } from "../utils/convertPCMToFloat32";
|
|
5
|
+
import { getWavFileInfo } from "../utils/getWavFileInfo";
|
|
6
|
+
import { InlineFeaturesExtractor } from "../workers/InlineFeaturesExtractor.web";
|
|
7
|
+
const logger = getLogger("extractAudioAnalysis");
|
|
8
|
+
export const extractAudioAnalysis = async ({ fileUri, pointsPerSecond = 20, arrayBuffer, bitDepth, skipWavHeader, durationMs, sampleRate, numberOfChannels, algorithm = "rms", features, featuresExtratorUrl, }) => {
|
|
9
|
+
if (isWeb) {
|
|
10
|
+
if (!arrayBuffer && !fileUri) {
|
|
11
|
+
throw new Error("Either arrayBuffer or fileUri must be provided");
|
|
12
|
+
}
|
|
13
|
+
if (!arrayBuffer) {
|
|
14
|
+
logger.log(`fetching fileUri`, fileUri);
|
|
15
|
+
const response = await fetch(fileUri);
|
|
16
|
+
if (!response.ok) {
|
|
17
|
+
throw new Error(`Failed to fetch fileUri: ${response.statusText}`);
|
|
18
|
+
}
|
|
19
|
+
arrayBuffer = (await response.arrayBuffer()).slice(0);
|
|
20
|
+
logger.log(`fetched fileUri`, arrayBuffer.byteLength, arrayBuffer);
|
|
21
|
+
}
|
|
22
|
+
// Create a new copy of the ArrayBuffer to avoid detachment issues
|
|
23
|
+
const bufferCopy = arrayBuffer.slice(0);
|
|
24
|
+
logger.log(`extractAudioAnalysis skipWavHeader=${skipWavHeader} bitDepth=${bitDepth} len=${bufferCopy.byteLength}`, bufferCopy.slice(0, 100));
|
|
25
|
+
let actualBitDepth = bitDepth;
|
|
26
|
+
if (!actualBitDepth) {
|
|
27
|
+
logger.log(`extractAudioAnalysis bitDepth not provided -- getting wav file info`);
|
|
28
|
+
const fileInfo = await getWavFileInfo(bufferCopy);
|
|
29
|
+
actualBitDepth = fileInfo.bitDepth;
|
|
30
|
+
}
|
|
31
|
+
logger.log(`extractAudioAnalysis actualBitDepth=${actualBitDepth}`);
|
|
32
|
+
// let copyChannelData: Float32Array;
|
|
33
|
+
// try {
|
|
34
|
+
// const audioContext = new (window.AudioContext ||
|
|
35
|
+
// // @ts-ignore
|
|
36
|
+
// window.webkitAudioContext)();
|
|
37
|
+
// const audioBuffer = await audioContext.decodeAudioData(bufferCopy);
|
|
38
|
+
// const channelData = audioBuffer.getChannelData(0); // Use only the first channel
|
|
39
|
+
// copyChannelData = new Float32Array(channelData); // Create a new Float32Array
|
|
40
|
+
// } catch (error) {
|
|
41
|
+
// console.warn("Failed to decode audio data:", error);
|
|
42
|
+
// // Fall back to creating a new Float32Array from the ArrayBuffer if decoding fails
|
|
43
|
+
// copyChannelData = new Float32Array(arrayBuffer);
|
|
44
|
+
// }
|
|
45
|
+
const { pcmValues: channelData, min, max, } = convertPCMToFloat32({
|
|
46
|
+
buffer: arrayBuffer,
|
|
47
|
+
bitDepth: actualBitDepth,
|
|
48
|
+
skipWavHeader,
|
|
49
|
+
});
|
|
50
|
+
logger.log(`extractAudioAnalysis skipWaveHeader=${skipWavHeader} convertPCMToFloat32 length=${channelData.length} range: [ ${min} :: ${max} ]`);
|
|
51
|
+
return new Promise((resolve, reject) => {
|
|
52
|
+
let worker;
|
|
53
|
+
if (featuresExtratorUrl) {
|
|
54
|
+
worker = new Worker(new URL(featuresExtratorUrl, window.location.href));
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
const blob = new Blob([InlineFeaturesExtractor], {
|
|
58
|
+
type: "application/javascript",
|
|
59
|
+
});
|
|
60
|
+
const url = URL.createObjectURL(blob);
|
|
61
|
+
worker = new Worker(url);
|
|
62
|
+
}
|
|
63
|
+
worker.onmessage = (event) => {
|
|
64
|
+
resolve(event.data.result);
|
|
65
|
+
};
|
|
66
|
+
worker.onerror = (error) => {
|
|
67
|
+
reject(error);
|
|
68
|
+
};
|
|
69
|
+
worker.postMessage({
|
|
70
|
+
command: "process",
|
|
71
|
+
channelData,
|
|
72
|
+
sampleRate,
|
|
73
|
+
pointsPerSecond,
|
|
74
|
+
algorithm,
|
|
75
|
+
bitDepth,
|
|
76
|
+
fullAudioDurationMs: durationMs,
|
|
77
|
+
numberOfChannels,
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
if (!fileUri) {
|
|
83
|
+
throw new Error("fileUri is required");
|
|
84
|
+
}
|
|
85
|
+
logger.log(`extractAudioAnalysis`, {
|
|
86
|
+
fileUri,
|
|
87
|
+
pointsPerSecond,
|
|
88
|
+
algorithm,
|
|
89
|
+
});
|
|
90
|
+
const res = await ExpoAudioStreamModule.extractAudioAnalysis({
|
|
91
|
+
fileUri,
|
|
92
|
+
pointsPerSecond,
|
|
93
|
+
skipWavHeader,
|
|
94
|
+
algorithm,
|
|
95
|
+
features,
|
|
96
|
+
});
|
|
97
|
+
logger.log(`extractAudioAnalysis`, res);
|
|
98
|
+
return res;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
//# sourceMappingURL=extractAudioAnalysis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractAudioAnalysis.js","sourceRoot":"","sources":["../../src/AudioAnalysis/extractAudioAnalysis.ts"],"names":[],"mappings":"AAEA,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAEjF,MAAM,MAAM,GAAG,SAAS,CAAC,sBAAsB,CAAC,CAAC;AAEjD,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EAAE,EACzC,OAAO,EACP,eAAe,GAAG,EAAE,EACpB,WAAW,EACX,QAAQ,EAC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MAAM,CAAC,KAAK,CAAC,CAAC;YAChB,CAAC,CAAC;YAEF,MAAM,CAAC,WAAW,CAAC;gBACjB,OAAO,EAAE,SAAS;gBAClB,WAAW;gBACX,UAAU;gBACV,eAAe;gBACf,SAAS;gBACT,QAAQ;gBACR,mBAAmB,EAAE,UAAU;gBAC/B,gBAAgB;aACjB,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;QACzC,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,sBAAsB,EAAE;YACjC,OAAO;YACP,eAAe;YACf,SAAS;SACV,CAAC,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,qBAAqB,CAAC,oBAAoB,CAAC;YAC3D,OAAO;YACP,eAAe;YACf,aAAa;YACb,SAAS;YACT,QAAQ;SACT,CAAC,CAAC;QACH,MAAM,CAAC,GAAG,CAAC,sBAAsB,EAAE,GAAG,CAAC,CAAC;QACxC,OAAO,GAAG,CAAC;IACb,CAAC;AACH,CAAC,CAAC","sourcesContent":["// packages/expo-audio-stream/src/AudioAnalysis/extractAudioAnalysis.ts\nimport { AudioAnalysisData } from \"./AudioAnalysis.types\";\nimport ExpoAudioStreamModule from \"../ExpoAudioStreamModule\";\nimport { isWeb } from \"../constants\";\nimport { getLogger } from \"../logger\";\nimport { ExtractMetadataProps } from \"../useAudioRecorder\";\nimport { convertPCMToFloat32 } from \"../utils/convertPCMToFloat32\";\nimport { getWavFileInfo } from \"../utils/getWavFileInfo\";\nimport { InlineFeaturesExtractor } from \"../workers/InlineFeaturesExtractor.web\";\n\nconst logger = getLogger(\"extractAudioAnalysis\");\n\nexport const extractAudioAnalysis = async ({\n fileUri,\n pointsPerSecond = 20,\n arrayBuffer,\n bitDepth,\n skipWavHeader,\n durationMs,\n sampleRate,\n numberOfChannels,\n algorithm = \"rms\",\n features,\n featuresExtratorUrl,\n}: ExtractMetadataProps): Promise<AudioAnalysisData> => {\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(`Failed to fetch fileUri: ${response.statusText}`);\n }\n\n arrayBuffer = (await response.arrayBuffer()).slice(0);\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 skipWavHeader=${skipWavHeader} 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 // let copyChannelData: Float32Array;\n // try {\n // const audioContext = new (window.AudioContext ||\n // // @ts-ignore\n // window.webkitAudioContext)();\n // const audioBuffer = await audioContext.decodeAudioData(bufferCopy);\n // const channelData = audioBuffer.getChannelData(0); // Use only the first channel\n // copyChannelData = new Float32Array(channelData); // Create a new Float32Array\n // } catch (error) {\n // console.warn(\"Failed to decode audio data:\", error);\n // // Fall back to creating a new Float32Array from the ArrayBuffer if decoding fails\n // copyChannelData = new Float32Array(arrayBuffer);\n // }\n\n const {\n pcmValues: channelData,\n min,\n max,\n } = convertPCMToFloat32({\n buffer: arrayBuffer,\n bitDepth: actualBitDepth,\n skipWavHeader,\n });\n logger.log(\n `extractAudioAnalysis skipWaveHeader=${skipWavHeader} convertPCMToFloat32 length=${channelData.length} range: [ ${min} :: ${max} ]`,\n );\n\n return new Promise((resolve, reject) => {\n let worker: Worker;\n if (featuresExtratorUrl) {\n worker = new Worker(new URL(featuresExtratorUrl, window.location.href));\n } else {\n const blob = new Blob([InlineFeaturesExtractor], {\n type: \"application/javascript\",\n });\n const url = URL.createObjectURL(blob);\n worker = new Worker(url);\n }\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,\n sampleRate,\n pointsPerSecond,\n algorithm,\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 pointsPerSecond,\n algorithm,\n });\n const res = await ExpoAudioStreamModule.extractAudioAnalysis({\n fileUri,\n pointsPerSecond,\n skipWavHeader,\n algorithm,\n features,\n });\n logger.log(`extractAudioAnalysis`, res);\n return res;\n }\n};\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractWaveform.d.ts","sourceRoot":"","sources":["../../src/AudioAnalysis/extractWaveform.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AACD,eAAO,MAAM,eAAe,kDAKzB,oBAAoB,KAAG,OAAO,CAAC,OAAO,CASxC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import ExpoAudioStreamModule from "../ExpoAudioStreamModule";
|
|
2
|
+
import { getLogger } from "../logger";
|
|
3
|
+
const logger = getLogger("extractWaveform");
|
|
4
|
+
export const extractWaveform = async ({ fileUri, numberOfSamples, offset = 0, length, }) => {
|
|
5
|
+
const res = await ExpoAudioStreamModule.extractAudioAnalysis({
|
|
6
|
+
fileUri,
|
|
7
|
+
numberOfSamples,
|
|
8
|
+
offset,
|
|
9
|
+
length,
|
|
10
|
+
});
|
|
11
|
+
logger.log(`extractWaveform`, res);
|
|
12
|
+
return res;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=extractWaveform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractWaveform.js","sourceRoot":"","sources":["../../src/AudioAnalysis/extractWaveform.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,MAAM,GAAG,SAAS,CAAC,iBAAiB,CAAC,CAAC;AAO5C,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAAE,EACpC,OAAO,EACP,eAAe,EACf,MAAM,GAAG,CAAC,EACV,MAAM,GACe,EAAoB,EAAE;IAC3C,MAAM,GAAG,GAAG,MAAM,qBAAqB,CAAC,oBAAoB,CAAC;QAC3D,OAAO;QACP,eAAe;QACf,MAAM;QACN,MAAM;KACP,CAAC,CAAC;IACH,MAAM,CAAC,GAAG,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;IACnC,OAAO,GAAG,CAAC;AACb,CAAC,CAAC","sourcesContent":["import ExpoAudioStreamModule from \"../ExpoAudioStreamModule\";\nimport { getLogger } from \"../logger\";\n\nconst logger = getLogger(\"extractWaveform\");\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 logger.log(`extractWaveform`, res);\n return res;\n};\n"]}
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { AudioAnalysisData } from "./AudioAnalysis/AudioAnalysis.types";
|
|
3
|
+
import { AudioRecordingResult, RecordingConfig, StartRecordingResult } from "./ExpoAudioStream.types";
|
|
4
|
+
import { UseAudioRecorderProps } from "./useAudioRecorder";
|
|
5
|
+
export interface UseAudioRecorderState {
|
|
6
|
+
startRecording: (_: RecordingConfig) => Promise<StartRecordingResult>;
|
|
7
|
+
stopRecording: () => Promise<AudioRecordingResult | null>;
|
|
8
|
+
pauseRecording: () => void;
|
|
9
|
+
resumeRecording: () => void;
|
|
10
|
+
isRecording: boolean;
|
|
11
|
+
isPaused: boolean;
|
|
12
|
+
durationMs: number;
|
|
13
|
+
size: number;
|
|
14
|
+
analysisData?: AudioAnalysisData;
|
|
15
|
+
}
|
|
3
16
|
interface AudioRecorderProviderProps {
|
|
4
17
|
children: React.ReactNode;
|
|
5
18
|
config?: UseAudioRecorderProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AudioRecorder.provider.d.ts","sourceRoot":"","sources":["../src/AudioRecorder.provider.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AudioRecorder.provider.d.ts","sourceRoot":"","sources":["../src/AudioRecorder.provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAEzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,oBAAoB,EACrB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,qBAAqB,EAAoB,MAAM,oBAAoB,CAAC;AAE7E,MAAM,WAAW,qBAAqB;IACpC,cAAc,EAAE,CAAC,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACtE,aAAa,EAAE,MAAM,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;IAC1D,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,iBAAiB,CAAC;CAClC;AAuBD,UAAU,0BAA0B;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,MAAM,CAAC,EAAE,qBAAqB,CAAC;CAChC;AAED,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAUtE,CAAC;AAEF,eAAO,MAAM,sBAAsB,6BAQlC,CAAC"}
|
|
@@ -1,12 +1,25 @@
|
|
|
1
|
+
// packages/expo-audio-stream/src/AudioRecorder.provider.tsx
|
|
1
2
|
import React, { createContext, useContext } from "react";
|
|
2
|
-
import { useAudioRecorder
|
|
3
|
-
const
|
|
3
|
+
import { useAudioRecorder } from "./useAudioRecorder";
|
|
4
|
+
const initContext = {
|
|
4
5
|
isRecording: false,
|
|
5
6
|
isPaused: false,
|
|
6
7
|
durationMs: 0,
|
|
7
8
|
size: 0,
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
startRecording: async () => {
|
|
10
|
+
throw new Error("AudioRecorderProvider not found");
|
|
11
|
+
},
|
|
12
|
+
stopRecording: async () => {
|
|
13
|
+
throw new Error("AudioRecorderProvider not found");
|
|
14
|
+
},
|
|
15
|
+
pauseRecording: () => {
|
|
16
|
+
throw new Error("AudioRecorderProvider not found");
|
|
17
|
+
},
|
|
18
|
+
resumeRecording: () => {
|
|
19
|
+
throw new Error("AudioRecorderProvider not found");
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
const AudioRecorderContext = createContext(initContext);
|
|
10
23
|
export const AudioRecorderProvider = ({ children, config = {}, }) => {
|
|
11
24
|
const audioRecorder = useAudioRecorder(config);
|
|
12
25
|
return (<AudioRecorderContext.Provider value={audioRecorder}>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AudioRecorder.provider.js","sourceRoot":"","sources":["../src/AudioRecorder.provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;
|
|
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,CAAC;AAQzD,OAAO,EAAyB,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAc7E,MAAM,WAAW,GAA0B;IACzC,WAAW,EAAE,KAAK;IAClB,QAAQ,EAAE,KAAK;IACf,UAAU,EAAE,CAAC;IACb,IAAI,EAAE,CAAC;IACP,cAAc,EAAE,KAAK,IAAI,EAAE;QACzB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IACD,aAAa,EAAE,KAAK,IAAI,EAAE;QACxB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IACD,cAAc,EAAE,GAAG,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IACD,eAAe,EAAE,GAAG,EAAE;QACpB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;CACF,CAAC;AAEF,MAAM,oBAAoB,GAAG,aAAa,CAAwB,WAAW,CAAC,CAAC;AAO/E,MAAM,CAAC,MAAM,qBAAqB,GAAyC,CAAC,EAC1E,QAAQ,EACR,MAAM,GAAG,EAAE,GACZ,EAAE,EAAE;IACH,MAAM,aAAa,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC/C,OAAO,CACL,CAAC,oBAAoB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,aAAa,CAAC,CAClD;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,oBAAoB,CAAC,QAAQ,CAAC,CACjC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,EAAE;IACzC,MAAM,OAAO,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACjD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,qEAAqE,CACtE,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["// packages/expo-audio-stream/src/AudioRecorder.provider.tsx\nimport React, { createContext, useContext } from \"react\";\n\nimport { AudioAnalysisData } from \"./AudioAnalysis/AudioAnalysis.types\";\nimport {\n AudioRecordingResult,\n RecordingConfig,\n StartRecordingResult,\n} from \"./ExpoAudioStream.types\";\nimport { UseAudioRecorderProps, useAudioRecorder } from \"./useAudioRecorder\";\n\nexport interface UseAudioRecorderState {\n startRecording: (_: RecordingConfig) => Promise<StartRecordingResult>;\n stopRecording: () => Promise<AudioRecordingResult | null>;\n pauseRecording: () => void;\n resumeRecording: () => 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 analysisData?: AudioAnalysisData;\n}\n\nconst initContext: UseAudioRecorderState = {\n isRecording: false,\n isPaused: false,\n durationMs: 0,\n size: 0,\n startRecording: async () => {\n throw new Error(\"AudioRecorderProvider not found\");\n },\n stopRecording: async () => {\n throw new Error(\"AudioRecorderProvider not found\");\n },\n pauseRecording: () => {\n throw new Error(\"AudioRecorderProvider not found\");\n },\n resumeRecording: () => {\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,3 +1,19 @@
|
|
|
1
|
+
import { AudioAnalysisData, AudioFeaturesOptions } from "./AudioAnalysis/AudioAnalysis.types";
|
|
2
|
+
export interface AudioStreamStatus {
|
|
3
|
+
isRecording: boolean;
|
|
4
|
+
isPaused: boolean;
|
|
5
|
+
durationMs: number;
|
|
6
|
+
size: number;
|
|
7
|
+
interval: number;
|
|
8
|
+
mimeType: string;
|
|
9
|
+
}
|
|
10
|
+
export interface AudioDataEvent {
|
|
11
|
+
data: string | ArrayBuffer;
|
|
12
|
+
position: number;
|
|
13
|
+
fileUri: string;
|
|
14
|
+
eventDataSize: number;
|
|
15
|
+
totalSize: number;
|
|
16
|
+
}
|
|
1
17
|
export interface AudioEventPayload {
|
|
2
18
|
encoded?: string;
|
|
3
19
|
buffer?: ArrayBuffer;
|
|
@@ -9,105 +25,31 @@ export interface AudioEventPayload {
|
|
|
9
25
|
mimeType: string;
|
|
10
26
|
streamUuid: string;
|
|
11
27
|
}
|
|
12
|
-
export
|
|
28
|
+
export type EncodingType = "pcm_32bit" | "pcm_16bit" | "pcm_8bit";
|
|
29
|
+
export type SampleRate = 16000 | 44100 | 48000;
|
|
30
|
+
export type BitDepth = 8 | 16 | 32;
|
|
31
|
+
export interface AudioRecordingResult {
|
|
13
32
|
fileUri: string;
|
|
14
33
|
webAudioUri?: string;
|
|
15
34
|
durationMs: number;
|
|
16
35
|
size: number;
|
|
17
36
|
mimeType: string;
|
|
18
|
-
channels
|
|
19
|
-
bitDepth
|
|
20
|
-
sampleRate
|
|
37
|
+
channels: number;
|
|
38
|
+
bitDepth: BitDepth;
|
|
39
|
+
sampleRate: SampleRate;
|
|
21
40
|
}
|
|
22
|
-
export interface
|
|
41
|
+
export interface StartRecordingResult {
|
|
23
42
|
fileUri: string;
|
|
24
43
|
mimeType: string;
|
|
25
44
|
channels?: number;
|
|
26
|
-
bitDepth?:
|
|
27
|
-
sampleRate?:
|
|
28
|
-
}
|
|
29
|
-
export interface AudioStreamStatus {
|
|
30
|
-
isRecording: boolean;
|
|
31
|
-
isPaused: boolean;
|
|
32
|
-
durationMs: number;
|
|
33
|
-
size: number;
|
|
34
|
-
interval: number;
|
|
35
|
-
mimeType: string;
|
|
36
|
-
}
|
|
37
|
-
export interface AudioDataEvent {
|
|
38
|
-
data: string | ArrayBuffer;
|
|
39
|
-
position: number;
|
|
40
|
-
fileUri: string;
|
|
41
|
-
eventDataSize: number;
|
|
42
|
-
totalSize: number;
|
|
43
|
-
}
|
|
44
|
-
export interface AudioFeatures {
|
|
45
|
-
energy: number;
|
|
46
|
-
mfcc: number[];
|
|
47
|
-
rms: number;
|
|
48
|
-
minAmplitude: number;
|
|
49
|
-
maxAmplitude: number;
|
|
50
|
-
zcr: number;
|
|
51
|
-
spectralCentroid: number;
|
|
52
|
-
spectralFlatness: number;
|
|
53
|
-
spectralRolloff: number;
|
|
54
|
-
spectralBandwidth: number;
|
|
55
|
-
chromagram: number[];
|
|
56
|
-
tempo: number;
|
|
57
|
-
hnr: number;
|
|
58
|
-
}
|
|
59
|
-
export interface AudioFeaturesOptions {
|
|
60
|
-
energy?: boolean;
|
|
61
|
-
mfcc?: boolean;
|
|
62
|
-
rms?: boolean;
|
|
63
|
-
zcr?: boolean;
|
|
64
|
-
spectralCentroid?: boolean;
|
|
65
|
-
spectralFlatness?: boolean;
|
|
66
|
-
spectralRolloff?: boolean;
|
|
67
|
-
spectralBandwidth?: boolean;
|
|
68
|
-
chromagram?: boolean;
|
|
69
|
-
tempo?: boolean;
|
|
70
|
-
hnr?: boolean;
|
|
71
|
-
}
|
|
72
|
-
export interface DataPoint {
|
|
73
|
-
id: number;
|
|
74
|
-
amplitude: number;
|
|
75
|
-
activeSpeech?: boolean;
|
|
76
|
-
dB?: number;
|
|
77
|
-
silent?: boolean;
|
|
78
|
-
features?: AudioFeatures;
|
|
79
|
-
startTime?: number;
|
|
80
|
-
endTime?: number;
|
|
81
|
-
startPosition?: number;
|
|
82
|
-
endPosition?: number;
|
|
83
|
-
samples?: number;
|
|
84
|
-
speaker?: number;
|
|
85
|
-
}
|
|
86
|
-
export interface AudioAnalysisData {
|
|
87
|
-
pointsPerSecond: number;
|
|
88
|
-
durationMs: number;
|
|
89
|
-
bitDepth: number;
|
|
90
|
-
samples: number;
|
|
91
|
-
numberOfChannels: number;
|
|
92
|
-
sampleRate: number;
|
|
93
|
-
dataPoints: DataPoint[];
|
|
94
|
-
amplitudeRange: {
|
|
95
|
-
min: number;
|
|
96
|
-
max: number;
|
|
97
|
-
};
|
|
98
|
-
speakerChanges?: {
|
|
99
|
-
timestamp: number;
|
|
100
|
-
speaker: number;
|
|
101
|
-
}[];
|
|
45
|
+
bitDepth?: BitDepth;
|
|
46
|
+
sampleRate?: SampleRate;
|
|
102
47
|
}
|
|
103
|
-
export type EncodingType = "pcm_32bit" | "pcm_16bit" | "pcm_8bit";
|
|
104
|
-
export type SampleRate = 16000 | 44100 | 48000;
|
|
105
48
|
export interface RecordingConfig {
|
|
106
49
|
sampleRate?: SampleRate;
|
|
107
50
|
channels?: 1 | 2;
|
|
108
51
|
encoding?: EncodingType;
|
|
109
52
|
interval?: number;
|
|
110
|
-
maxRecentDataDuration?: number;
|
|
111
53
|
enableProcessing?: boolean;
|
|
112
54
|
pointsPerSecond?: number;
|
|
113
55
|
algorithm?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoAudioStream.types.d.ts","sourceRoot":"","sources":["../src/ExpoAudioStream.types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ExpoAudioStream.types.d.ts","sourceRoot":"","sources":["../src/ExpoAudioStream.types.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,qCAAqC,CAAC;AAE7C,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,WAAW,GAAG,UAAU,CAAC;AAClE,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAC/C,MAAM,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC;AAEnC,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,UAAU,CAAC;CACxB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACjB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,oBAAoB,CAAC;IAGhC,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,kBAAkB,CAAC,EAAE,CAAC,CAAC,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoAudioStream.types.js","sourceRoot":"","sources":["../src/ExpoAudioStream.types.ts"],"names":[],"mappings":"","sourcesContent":["
|
|
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 AudioAnalysisData,\n AudioFeaturesOptions,\n} from \"./AudioAnalysis/AudioAnalysis.types\";\n\nexport interface AudioStreamStatus {\n isRecording: boolean;\n isPaused: boolean;\n durationMs: number;\n size: number;\n interval: number;\n mimeType: string;\n}\n\nexport interface AudioDataEvent {\n data: string | ArrayBuffer;\n position: number;\n fileUri: string;\n eventDataSize: number;\n totalSize: number;\n}\n\nexport interface AudioEventPayload {\n encoded?: string;\n buffer?: ArrayBuffer;\n fileUri: string;\n lastEmittedSize: number;\n position: number;\n deltaSize: number;\n totalSize: number;\n mimeType: string;\n streamUuid: string;\n}\n\nexport type EncodingType = \"pcm_32bit\" | \"pcm_16bit\" | \"pcm_8bit\";\nexport type SampleRate = 16000 | 44100 | 48000;\nexport type BitDepth = 8 | 16 | 32;\n\nexport interface AudioRecordingResult {\n fileUri: string;\n webAudioUri?: string;\n durationMs: number;\n size: number;\n mimeType: string;\n channels: number;\n bitDepth: BitDepth;\n sampleRate: SampleRate;\n}\n\nexport interface StartRecordingResult {\n fileUri: string;\n mimeType: string;\n channels?: number;\n bitDepth?: BitDepth;\n sampleRate?: SampleRate;\n}\n\nexport interface RecordingConfig {\n sampleRate?: SampleRate; // Sample rate for recording\n channels?: 1 | 2; // 1 or 2 (MONO or STEREO)\n encoding?: EncodingType; // Encoding type for the recording\n interval?: number; // Interval in milliseconds at which to emit recording data\n\n // Optional parameters for audio processing\n enableProcessing?: boolean; // Boolean to enable/disable audio processing (default is false)\n pointsPerSecond?: number; // Number of data points to extract per second of audio (default is 1000)\n algorithm?: string; // Algorithm to use for extraction (default is \"rms\")\n features?: AudioFeaturesOptions; // Feature options to extract (default is empty)\n\n // Optional paramters from web\n onAudioStream?: (_: AudioDataEvent) => Promise<void>; // Callback function to handle audio stream\n onProcessingResult?: (_: AudioAnalysisData) => Promise<void>; // Callback function to handle processing results\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EventEmitter } from "expo-modules-core";
|
|
2
|
-
import { AudioAnalysisData
|
|
3
|
-
import {
|
|
2
|
+
import { AudioAnalysisData } from "./AudioAnalysis/AudioAnalysis.types";
|
|
3
|
+
import { AudioRecordingResult, AudioStreamStatus, BitDepth, RecordingConfig, StartRecordingResult } from "./ExpoAudioStream.types";
|
|
4
|
+
import { WebRecorder } from "./WebRecorder.web";
|
|
4
5
|
export interface EmitAudioEventProps {
|
|
5
6
|
data: ArrayBuffer;
|
|
6
7
|
position: number;
|
|
@@ -26,14 +27,14 @@ export declare class ExpoAudioStreamWeb extends EventEmitter {
|
|
|
26
27
|
streamUuid: string | null;
|
|
27
28
|
extension: "webm" | "wav";
|
|
28
29
|
recordingConfig?: RecordingConfig;
|
|
29
|
-
bitDepth:
|
|
30
|
+
bitDepth: BitDepth;
|
|
30
31
|
audioWorkletUrl: string;
|
|
31
32
|
featuresExtratorUrl: string;
|
|
32
33
|
constructor({ audioWorkletUrl, featuresExtratorUrl, }: ExpoAudioStreamWebProps);
|
|
33
34
|
getMediaStream(): Promise<MediaStream>;
|
|
34
|
-
startRecording(recordingConfig?: RecordingConfig): Promise<
|
|
35
|
+
startRecording(recordingConfig?: RecordingConfig): Promise<StartRecordingResult>;
|
|
35
36
|
emitAudioEvent({ data, position }: EmitAudioEventProps): void;
|
|
36
|
-
stopRecording(): Promise<
|
|
37
|
+
stopRecording(): Promise<AudioRecordingResult | null>;
|
|
37
38
|
pauseRecording(): Promise<void>;
|
|
38
39
|
resumeRecording(): Promise<void>;
|
|
39
40
|
status(): AudioStreamStatus;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoAudioStream.web.d.ts","sourceRoot":"","sources":["../src/ExpoAudioStream.web.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ExpoAudioStream.web.d.ts","sourceRoot":"","sources":["../src/ExpoAudioStream.web.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,iBA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GAAE,eAAoB;IA8D1D,cAAc,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,mBAAmB;IAiBhD,aAAa,IAAI,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAqBrD,cAAc;IAad,eAAe;IAarB,MAAM;CAWP"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
// src/ExpoAudioStreamModule.web.ts
|
|
1
2
|
import { EventEmitter } from "expo-modules-core";
|
|
2
|
-
import { WebRecorder } from "./WebRecorder";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
const
|
|
3
|
+
import { WebRecorder } from "./WebRecorder.web";
|
|
4
|
+
import { getLogger } from "./logger";
|
|
5
|
+
import { encodingToBitDepth } from "./utils/encodingToBitDepth";
|
|
6
|
+
const logger = getLogger("ExpoAudioStreamWeb");
|
|
6
7
|
export class ExpoAudioStreamWeb extends EventEmitter {
|
|
7
8
|
customRecorder;
|
|
8
9
|
audioChunks;
|
|
@@ -84,7 +85,7 @@ export class ExpoAudioStreamWeb extends EventEmitter {
|
|
|
84
85
|
this.lastEmittedSize = this.currentSize;
|
|
85
86
|
},
|
|
86
87
|
emitAudioAnalysisCallback: (audioAnalysisData) => {
|
|
87
|
-
|
|
88
|
+
logger.log(`Emitted AudioAnalysis:`, audioAnalysisData);
|
|
88
89
|
this.emit("AudioAnalysis", audioAnalysisData);
|
|
89
90
|
},
|
|
90
91
|
});
|
|
@@ -92,7 +93,7 @@ export class ExpoAudioStreamWeb extends EventEmitter {
|
|
|
92
93
|
this.customRecorder.start();
|
|
93
94
|
// // Set a timer to stop recording after 5 seconds
|
|
94
95
|
// setTimeout(() => {
|
|
95
|
-
//
|
|
96
|
+
// logger.log("AUTO Stopping recording");
|
|
96
97
|
// this.customRecorder?.stopAndPlay();
|
|
97
98
|
// this.isRecording = false;
|
|
98
99
|
// }, 3000);
|
|
@@ -131,7 +132,7 @@ export class ExpoAudioStreamWeb extends EventEmitter {
|
|
|
131
132
|
async stopRecording() {
|
|
132
133
|
if (this.customRecorder) {
|
|
133
134
|
const fullPcmBuffer = await this.customRecorder.stop();
|
|
134
|
-
|
|
135
|
+
logger.debug(`Stopped recording`, fullPcmBuffer);
|
|
135
136
|
}
|
|
136
137
|
this.isRecording = false;
|
|
137
138
|
this.currentDurationMs = Date.now() - this.recordingStartTime;
|
|
@@ -152,7 +153,7 @@ export class ExpoAudioStreamWeb extends EventEmitter {
|
|
|
152
153
|
throw new Error("Recording is not active or already paused");
|
|
153
154
|
}
|
|
154
155
|
if (this.customRecorder) {
|
|
155
|
-
this.customRecorder.
|
|
156
|
+
this.customRecorder.pause();
|
|
156
157
|
}
|
|
157
158
|
this.isPaused = true;
|
|
158
159
|
this.pausedTime = Date.now();
|