@siteed/expo-audio-stream 1.0.3 → 1.0.5
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 +4 -4
- package/README.md +18 -176
- package/android/src/main/java/net/siteed/audiostream/AudioRecorderManager.kt +1 -0
- package/app.plugin.js +1 -1
- package/build/AudioAnalysis/AudioAnalysis.types.d.ts +3 -5
- package/build/AudioAnalysis/AudioAnalysis.types.d.ts.map +1 -1
- package/build/AudioAnalysis/AudioAnalysis.types.js.map +1 -1
- package/build/AudioAnalysis/extractAudioAnalysis.d.ts +19 -3
- package/build/AudioAnalysis/extractAudioAnalysis.d.ts.map +1 -1
- package/build/AudioAnalysis/extractAudioAnalysis.js +14 -27
- package/build/AudioAnalysis/extractAudioAnalysis.js.map +1 -1
- package/build/AudioAnalysis/extractWaveform.d.ts.map +1 -1
- package/build/AudioAnalysis/extractWaveform.js +3 -3
- package/build/AudioAnalysis/extractWaveform.js.map +1 -1
- package/build/AudioRecorder.provider.d.ts +6 -6
- package/build/AudioRecorder.provider.d.ts.map +1 -1
- package/build/AudioRecorder.provider.js +9 -9
- package/build/AudioRecorder.provider.js.map +1 -1
- package/build/ExpoAudioStream.native.d.ts.map +1 -1
- package/build/ExpoAudioStream.native.js +2 -2
- package/build/ExpoAudioStream.native.js.map +1 -1
- package/build/ExpoAudioStream.types.d.ts +20 -18
- package/build/ExpoAudioStream.types.d.ts.map +1 -1
- package/build/ExpoAudioStream.types.js.map +1 -1
- package/build/ExpoAudioStream.web.d.ts +8 -8
- package/build/ExpoAudioStream.web.d.ts.map +1 -1
- package/build/ExpoAudioStream.web.js +40 -22
- package/build/ExpoAudioStream.web.js.map +1 -1
- package/build/ExpoAudioStreamModule.d.ts.map +1 -1
- package/build/ExpoAudioStreamModule.js +8 -7
- package/build/ExpoAudioStreamModule.js.map +1 -1
- package/build/WebRecorder.web.d.ts +8 -8
- package/build/WebRecorder.web.d.ts.map +1 -1
- package/build/WebRecorder.web.js +60 -50
- package/build/WebRecorder.web.js.map +1 -1
- package/build/constants.d.ts +1 -1
- package/build/constants.d.ts.map +1 -1
- package/build/constants.js +3 -3
- package/build/constants.js.map +1 -1
- package/build/events.d.ts +16 -4
- package/build/events.d.ts.map +1 -1
- package/build/events.js +8 -8
- package/build/events.js.map +1 -1
- package/build/index.d.ts +8 -8
- package/build/index.d.ts.map +1 -1
- package/build/index.js +6 -6
- package/build/index.js.map +1 -1
- package/build/logger.d.ts +2 -2
- package/build/logger.d.ts.map +1 -1
- package/build/logger.js +7 -11
- package/build/logger.js.map +1 -1
- package/build/useAudioRecorder.d.ts +4 -21
- package/build/useAudioRecorder.d.ts.map +1 -1
- package/build/useAudioRecorder.js +33 -33
- package/build/useAudioRecorder.js.map +1 -1
- package/build/utils/BlobFix.d.ts +9 -0
- package/build/utils/BlobFix.d.ts.map +1 -0
- package/build/utils/BlobFix.js +494 -0
- package/build/utils/BlobFix.js.map +1 -0
- package/build/utils/concatenateBuffers.d.ts +8 -0
- package/build/utils/concatenateBuffers.d.ts.map +1 -0
- package/build/utils/concatenateBuffers.js +21 -0
- package/build/utils/concatenateBuffers.js.map +1 -0
- package/build/utils/convertPCMToFloat32.d.ts +2 -2
- package/build/utils/convertPCMToFloat32.d.ts.map +1 -1
- package/build/utils/convertPCMToFloat32.js +49 -36
- package/build/utils/convertPCMToFloat32.js.map +1 -1
- package/build/utils/encodingToBitDepth.d.ts +1 -1
- package/build/utils/encodingToBitDepth.d.ts.map +1 -1
- package/build/utils/encodingToBitDepth.js +3 -3
- package/build/utils/encodingToBitDepth.js.map +1 -1
- package/build/utils/getWavFileInfo.d.ts +4 -3
- package/build/utils/getWavFileInfo.d.ts.map +1 -1
- package/build/utils/getWavFileInfo.js +18 -15
- package/build/utils/getWavFileInfo.js.map +1 -1
- package/build/utils/writeWavHeader.d.ts.map +1 -1
- package/build/utils/writeWavHeader.js +4 -4
- package/build/utils/writeWavHeader.js.map +1 -1
- package/build/workers/InlineFeaturesExtractor.web.d.ts.map +1 -1
- package/build/workers/InlineFeaturesExtractor.web.js.map +1 -1
- package/build/workers/inlineAudioWebWorker.web.d.ts.map +1 -1
- package/build/workers/inlineAudioWebWorker.web.js.map +1 -1
- package/expo-module.config.json +8 -17
- package/ios/AudioStreamManager.swift +1 -0
- package/ios/ExpoAudioStreamModule.swift +1 -0
- package/ios/RecordingResult.swift +1 -0
- package/package.json +72 -65
- package/plugin/build/index.d.ts +1 -1
- package/plugin/build/index.js +7 -7
- package/plugin/src/index.ts +47 -47
- package/plugin/tsconfig.json +8 -13
- package/src/AudioAnalysis/AudioAnalysis.types.ts +59 -60
- package/src/AudioAnalysis/extractAudioAnalysis.ts +132 -121
- package/src/AudioAnalysis/extractWaveform.ts +18 -18
- package/src/AudioRecorder.provider.tsx +53 -53
- package/src/ExpoAudioStream.native.ts +2 -2
- package/src/ExpoAudioStream.types.ts +56 -53
- package/src/ExpoAudioStream.web.ts +232 -205
- package/src/ExpoAudioStreamModule.ts +17 -16
- package/src/WebRecorder.web.ts +407 -390
- package/src/constants.ts +11 -11
- package/src/events.ts +27 -13
- package/src/index.ts +15 -15
- package/src/logger.ts +15 -18
- package/src/useAudioRecorder.tsx +394 -389
- package/src/utils/BlobFix.ts +550 -0
- package/src/utils/concatenateBuffers.ts +24 -0
- package/src/utils/convertPCMToFloat32.ts +72 -45
- package/src/utils/encodingToBitDepth.ts +14 -14
- package/src/utils/getWavFileInfo.ts +106 -99
- package/src/utils/writeWavHeader.ts +45 -45
- package/src/workers/InlineFeaturesExtractor.web.tsx +1 -1
- package/src/workers/inlineAudioWebWorker.web.tsx +1 -1
- package/tsconfig.json +12 -7
package/package.json
CHANGED
|
@@ -1,67 +1,74 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
2
|
+
"name": "@siteed/expo-audio-stream",
|
|
3
|
+
"version": "1.0.5",
|
|
4
|
+
"description": "stream audio crossplatform",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "build/index.js",
|
|
7
|
+
"types": "build/index.d.ts",
|
|
8
|
+
"author": "Arthur Breton <abreton@siteed.net> (https://github.com/deeeed)",
|
|
9
|
+
"homepage": "https://github.com/deeeed/expo-audio-stream#readme",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/deeeed/expo-audio-stream.git",
|
|
13
|
+
"directory": "packages/expo-audio-stream"
|
|
14
|
+
},
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/deeeed/expo-audio-stream/issues"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"react-native",
|
|
20
|
+
"expo",
|
|
21
|
+
"expo-audio-stream",
|
|
22
|
+
"ExpoAudioStream"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "expo-module build",
|
|
26
|
+
"clean": "expo-module clean",
|
|
27
|
+
"lint": "expo-module lint",
|
|
28
|
+
"test": "expo-module test",
|
|
29
|
+
"typecheck": "tsc --noEmit",
|
|
30
|
+
"prepare": "expo-module prepare",
|
|
31
|
+
"prepublishOnly": "expo-module prepublishOnly",
|
|
32
|
+
"expo-module": "expo-module",
|
|
33
|
+
"open:ios": "open -a \"Xcode\" ../../apps/playground/ios",
|
|
34
|
+
"open:android": "open -a \"Android Studio\" ../../apps/playground/android",
|
|
35
|
+
"size": "bundle-size && size-limit",
|
|
36
|
+
"release": "./publish.sh"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@expo/config-plugins": "^7.9.1",
|
|
40
|
+
"@size-limit/preset-big-lib": "^11.1.4",
|
|
41
|
+
"@types/jest": "^29.5.12",
|
|
42
|
+
"@types/node": "^20.12.7",
|
|
43
|
+
"@types/react": "^18.0.25",
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "^7.7.0",
|
|
45
|
+
"@typescript-eslint/parser": "^7.7.0",
|
|
46
|
+
"bundle-size": "^1.1.5",
|
|
47
|
+
"eslint": "^8.56.0",
|
|
48
|
+
"eslint-config-prettier": "^9.1.0",
|
|
49
|
+
"eslint-config-universe": "^12.0.0",
|
|
50
|
+
"eslint-plugin-import": "^2.29.1",
|
|
51
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
52
|
+
"eslint-plugin-promise": "^6.1.1",
|
|
53
|
+
"eslint-plugin-react": "^7.34.1",
|
|
54
|
+
"expo-module-scripts": "^3.5.2",
|
|
55
|
+
"expo-modules-core": "^1.12.19",
|
|
56
|
+
"jest": "^29.7.0",
|
|
57
|
+
"prettier": "^3.2.5",
|
|
58
|
+
"react-native": "^0.74.3",
|
|
59
|
+
"size-limit": "^11.1.4",
|
|
60
|
+
"typescript": "^5.5.4"
|
|
61
|
+
},
|
|
62
|
+
"peerDependencies": {
|
|
63
|
+
"expo": "*",
|
|
64
|
+
"react": "*",
|
|
65
|
+
"react-native": "*"
|
|
66
|
+
},
|
|
67
|
+
"publishConfig": {
|
|
68
|
+
"access": "public",
|
|
69
|
+
"registry": "https://registry.npmjs.org"
|
|
70
|
+
},
|
|
71
|
+
"dependencies": {
|
|
72
|
+
"@siteed/react-native-logger": "^0.9.2"
|
|
73
|
+
}
|
|
67
74
|
}
|
package/plugin/build/index.d.ts
CHANGED
package/plugin/build/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const config_plugins_1 = require("@expo/config-plugins");
|
|
4
|
-
const MICROPHONE_USAGE =
|
|
4
|
+
const MICROPHONE_USAGE = 'Allow $(PRODUCT_NAME) to access your microphone';
|
|
5
5
|
const withRecordingPermission = (config, existingPerms) => {
|
|
6
6
|
if (!existingPerms) {
|
|
7
|
-
console.warn(
|
|
7
|
+
console.warn('No previous permissions provided');
|
|
8
8
|
}
|
|
9
9
|
config = (0, config_plugins_1.withInfoPlist)(config, (config) => {
|
|
10
|
-
config.modResults[
|
|
10
|
+
config.modResults['NSMicrophoneUsageDescription'] = MICROPHONE_USAGE;
|
|
11
11
|
// Add audio to UIBackgroundModes to allow background audio recording
|
|
12
12
|
const existingBackgroundModes = config.modResults.UIBackgroundModes || [];
|
|
13
|
-
if (!existingBackgroundModes.includes(
|
|
14
|
-
existingBackgroundModes.push(
|
|
13
|
+
if (!existingBackgroundModes.includes('audio')) {
|
|
14
|
+
existingBackgroundModes.push('audio');
|
|
15
15
|
}
|
|
16
16
|
config.modResults.UIBackgroundModes = existingBackgroundModes;
|
|
17
17
|
return config;
|
|
18
18
|
});
|
|
19
19
|
config = (0, config_plugins_1.withAndroidManifest)(config, (config) => {
|
|
20
20
|
const mainApplication = config_plugins_1.AndroidConfig.Manifest.getMainApplicationOrThrow(config.modResults);
|
|
21
|
-
config_plugins_1.AndroidConfig.Manifest.addMetaDataItemToMainApplication(mainApplication,
|
|
21
|
+
config_plugins_1.AndroidConfig.Manifest.addMetaDataItemToMainApplication(mainApplication, 'android.permission.RECORD_AUDIO', MICROPHONE_USAGE);
|
|
22
22
|
// Add FOREGROUND_SERVICE permission for handling background recording
|
|
23
|
-
config_plugins_1.AndroidConfig.Manifest.addMetaDataItemToMainApplication(mainApplication,
|
|
23
|
+
config_plugins_1.AndroidConfig.Manifest.addMetaDataItemToMainApplication(mainApplication, 'android.permission.FOREGROUND_SERVICE', 'This apps needs access to the foreground service to record audio in the background');
|
|
24
24
|
return config;
|
|
25
25
|
});
|
|
26
26
|
return config;
|
package/plugin/src/index.ts
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from
|
|
2
|
+
AndroidConfig,
|
|
3
|
+
ConfigPlugin,
|
|
4
|
+
withAndroidManifest,
|
|
5
|
+
withInfoPlist,
|
|
6
|
+
} from '@expo/config-plugins'
|
|
7
7
|
|
|
8
|
-
const MICROPHONE_USAGE =
|
|
8
|
+
const MICROPHONE_USAGE = 'Allow $(PRODUCT_NAME) to access your microphone'
|
|
9
9
|
|
|
10
10
|
const withRecordingPermission: ConfigPlugin<{
|
|
11
|
-
|
|
11
|
+
microphonePermission: string
|
|
12
12
|
}> = (config, existingPerms) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
config = withInfoPlist(config, (config) => {
|
|
17
|
-
config.modResults["NSMicrophoneUsageDescription"] = MICROPHONE_USAGE;
|
|
18
|
-
|
|
19
|
-
// Add audio to UIBackgroundModes to allow background audio recording
|
|
20
|
-
const existingBackgroundModes = config.modResults.UIBackgroundModes || [];
|
|
21
|
-
if (!existingBackgroundModes.includes("audio")) {
|
|
22
|
-
existingBackgroundModes.push("audio");
|
|
13
|
+
if (!existingPerms) {
|
|
14
|
+
console.warn('No previous permissions provided')
|
|
23
15
|
}
|
|
24
|
-
config
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
16
|
+
config = withInfoPlist(config, (config) => {
|
|
17
|
+
config.modResults['NSMicrophoneUsageDescription'] = MICROPHONE_USAGE
|
|
18
|
+
|
|
19
|
+
// Add audio to UIBackgroundModes to allow background audio recording
|
|
20
|
+
const existingBackgroundModes =
|
|
21
|
+
config.modResults.UIBackgroundModes || []
|
|
22
|
+
if (!existingBackgroundModes.includes('audio')) {
|
|
23
|
+
existingBackgroundModes.push('audio')
|
|
24
|
+
}
|
|
25
|
+
config.modResults.UIBackgroundModes = existingBackgroundModes
|
|
26
|
+
|
|
27
|
+
return config
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
config = withAndroidManifest(config, (config) => {
|
|
31
|
+
const mainApplication =
|
|
32
|
+
AndroidConfig.Manifest.getMainApplicationOrThrow(config.modResults)
|
|
33
|
+
|
|
34
|
+
AndroidConfig.Manifest.addMetaDataItemToMainApplication(
|
|
35
|
+
mainApplication,
|
|
36
|
+
'android.permission.RECORD_AUDIO',
|
|
37
|
+
MICROPHONE_USAGE
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
// Add FOREGROUND_SERVICE permission for handling background recording
|
|
41
|
+
AndroidConfig.Manifest.addMetaDataItemToMainApplication(
|
|
42
|
+
mainApplication,
|
|
43
|
+
'android.permission.FOREGROUND_SERVICE',
|
|
44
|
+
'This apps needs access to the foreground service to record audio in the background'
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
return config
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
return config
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default withRecordingPermission
|
package/plugin/tsconfig.json
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
"exclude": [
|
|
11
|
-
"**/__mocks__/*",
|
|
12
|
-
"**/__tests__/*"
|
|
13
|
-
]
|
|
14
|
-
}
|
|
2
|
+
"extends": "expo-module-scripts/tsconfig.plugin",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "build",
|
|
5
|
+
"rootDir": "src"
|
|
6
|
+
},
|
|
7
|
+
"include": ["./src"],
|
|
8
|
+
"exclude": ["**/__mocks__/*", "**/__tests__/*"]
|
|
9
|
+
}
|
|
@@ -4,82 +4,81 @@
|
|
|
4
4
|
* Represents various audio features extracted from an audio signal.
|
|
5
5
|
*/
|
|
6
6
|
export interface AudioFeatures {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
energy: number // The infinite integral of the squared signal, representing the overall energy of the audio.
|
|
8
|
+
mfcc: number[] // Mel-frequency cepstral coefficients, describing the short-term power spectrum of a sound.
|
|
9
|
+
rms: number // Root mean square value, indicating the amplitude of the audio signal.
|
|
10
|
+
minAmplitude: number // Minimum amplitude value in the audio signal.
|
|
11
|
+
maxAmplitude: number // Maximum amplitude value in the audio signal.
|
|
12
|
+
zcr: number // Zero-crossing rate, indicating the rate at which the signal changes sign.
|
|
13
|
+
spectralCentroid: number // The center of mass of the spectrum, indicating the brightness of the sound.
|
|
14
|
+
spectralFlatness: number // Measure of the flatness of the spectrum, indicating how noise-like the signal is.
|
|
15
|
+
spectralRolloff: number // The frequency below which a specified percentage (usually 85%) of the total spectral energy lies.
|
|
16
|
+
spectralBandwidth: number // The width of the spectrum, indicating the range of frequencies present.
|
|
17
|
+
chromagram: number[] // Chromagram, representing the 12 different pitch classes of the audio.
|
|
18
|
+
tempo: number // Estimated tempo of the audio signal, measured in beats per minute (BPM).
|
|
19
|
+
hnr: number // Harmonics-to-noise ratio, indicating the proportion of harmonics to noise in the audio signal.
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Options to specify which audio features to extract.
|
|
24
24
|
*/
|
|
25
25
|
export interface AudioFeaturesOptions {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
energy?: boolean
|
|
27
|
+
mfcc?: boolean
|
|
28
|
+
rms?: boolean
|
|
29
|
+
zcr?: boolean
|
|
30
|
+
spectralCentroid?: boolean
|
|
31
|
+
spectralFlatness?: boolean
|
|
32
|
+
spectralRolloff?: boolean
|
|
33
|
+
spectralBandwidth?: boolean
|
|
34
|
+
chromagram?: boolean
|
|
35
|
+
tempo?: boolean
|
|
36
|
+
hnr?: boolean
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* Represents a single data point in the audio analysis.
|
|
41
41
|
*/
|
|
42
42
|
export interface DataPoint {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
43
|
+
id: number
|
|
44
|
+
amplitude: number
|
|
45
|
+
activeSpeech?: boolean
|
|
46
|
+
dB?: number
|
|
47
|
+
silent?: boolean
|
|
48
|
+
features?: AudioFeatures
|
|
49
|
+
startTime?: number
|
|
50
|
+
endTime?: number
|
|
51
|
+
// start / end position in bytes
|
|
52
|
+
startPosition?: number
|
|
53
|
+
endPosition?: number
|
|
54
|
+
// number of audio samples for this point (samples size depends on bit depth)
|
|
55
|
+
samples?: number
|
|
56
|
+
// TODO: speaker detection
|
|
57
|
+
speaker?: number
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
export type AmplitudeAlgorithm = 'peak' | 'rms'
|
|
61
|
+
|
|
60
62
|
/**
|
|
61
63
|
* Represents the complete data from the audio analysis.
|
|
62
64
|
*/
|
|
63
|
-
export interface
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
65
|
+
export interface AudioAnalysis {
|
|
66
|
+
pointsPerSecond: number // How many consolidated value per second
|
|
67
|
+
durationMs: number // Duration of the audio in milliseconds
|
|
68
|
+
bitDepth: number // Bit depth of the audio
|
|
69
|
+
samples: number // Size of the audio in bytes
|
|
70
|
+
numberOfChannels: number // Number of audio channels
|
|
71
|
+
sampleRate: number // Sample rate of the audio
|
|
72
|
+
dataPoints: DataPoint[] // Array of data points from the analysis.
|
|
73
|
+
amplitudeAlgorithm: AmplitudeAlgorithm // Algorithm used to calculate amplitude values.
|
|
74
|
+
amplitudeRange: {
|
|
75
|
+
min: number
|
|
76
|
+
max: number
|
|
77
|
+
}
|
|
78
|
+
// TODO: speaker detection
|
|
79
|
+
speakerChanges?: {
|
|
80
|
+
timestamp: number // Timestamp of the speaker change in milliseconds.
|
|
81
|
+
speaker: number // Speaker identifier.
|
|
82
|
+
}[]
|
|
80
83
|
}
|
|
81
84
|
|
|
82
|
-
export interface AudioAnalysisEventPayload {
|
|
83
|
-
analysis: AudioAnalysisData;
|
|
84
|
-
visualizationDuration: number;
|
|
85
|
-
}
|