@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.
Files changed (114) hide show
  1. package/.size-limit.json +4 -4
  2. package/README.md +18 -176
  3. package/android/src/main/java/net/siteed/audiostream/AudioRecorderManager.kt +1 -0
  4. package/app.plugin.js +1 -1
  5. package/build/AudioAnalysis/AudioAnalysis.types.d.ts +3 -5
  6. package/build/AudioAnalysis/AudioAnalysis.types.d.ts.map +1 -1
  7. package/build/AudioAnalysis/AudioAnalysis.types.js.map +1 -1
  8. package/build/AudioAnalysis/extractAudioAnalysis.d.ts +19 -3
  9. package/build/AudioAnalysis/extractAudioAnalysis.d.ts.map +1 -1
  10. package/build/AudioAnalysis/extractAudioAnalysis.js +14 -27
  11. package/build/AudioAnalysis/extractAudioAnalysis.js.map +1 -1
  12. package/build/AudioAnalysis/extractWaveform.d.ts.map +1 -1
  13. package/build/AudioAnalysis/extractWaveform.js +3 -3
  14. package/build/AudioAnalysis/extractWaveform.js.map +1 -1
  15. package/build/AudioRecorder.provider.d.ts +6 -6
  16. package/build/AudioRecorder.provider.d.ts.map +1 -1
  17. package/build/AudioRecorder.provider.js +9 -9
  18. package/build/AudioRecorder.provider.js.map +1 -1
  19. package/build/ExpoAudioStream.native.d.ts.map +1 -1
  20. package/build/ExpoAudioStream.native.js +2 -2
  21. package/build/ExpoAudioStream.native.js.map +1 -1
  22. package/build/ExpoAudioStream.types.d.ts +20 -18
  23. package/build/ExpoAudioStream.types.d.ts.map +1 -1
  24. package/build/ExpoAudioStream.types.js.map +1 -1
  25. package/build/ExpoAudioStream.web.d.ts +8 -8
  26. package/build/ExpoAudioStream.web.d.ts.map +1 -1
  27. package/build/ExpoAudioStream.web.js +40 -22
  28. package/build/ExpoAudioStream.web.js.map +1 -1
  29. package/build/ExpoAudioStreamModule.d.ts.map +1 -1
  30. package/build/ExpoAudioStreamModule.js +8 -7
  31. package/build/ExpoAudioStreamModule.js.map +1 -1
  32. package/build/WebRecorder.web.d.ts +8 -8
  33. package/build/WebRecorder.web.d.ts.map +1 -1
  34. package/build/WebRecorder.web.js +60 -50
  35. package/build/WebRecorder.web.js.map +1 -1
  36. package/build/constants.d.ts +1 -1
  37. package/build/constants.d.ts.map +1 -1
  38. package/build/constants.js +3 -3
  39. package/build/constants.js.map +1 -1
  40. package/build/events.d.ts +16 -4
  41. package/build/events.d.ts.map +1 -1
  42. package/build/events.js +8 -8
  43. package/build/events.js.map +1 -1
  44. package/build/index.d.ts +8 -8
  45. package/build/index.d.ts.map +1 -1
  46. package/build/index.js +6 -6
  47. package/build/index.js.map +1 -1
  48. package/build/logger.d.ts +2 -2
  49. package/build/logger.d.ts.map +1 -1
  50. package/build/logger.js +7 -11
  51. package/build/logger.js.map +1 -1
  52. package/build/useAudioRecorder.d.ts +4 -21
  53. package/build/useAudioRecorder.d.ts.map +1 -1
  54. package/build/useAudioRecorder.js +33 -33
  55. package/build/useAudioRecorder.js.map +1 -1
  56. package/build/utils/BlobFix.d.ts +9 -0
  57. package/build/utils/BlobFix.d.ts.map +1 -0
  58. package/build/utils/BlobFix.js +494 -0
  59. package/build/utils/BlobFix.js.map +1 -0
  60. package/build/utils/concatenateBuffers.d.ts +8 -0
  61. package/build/utils/concatenateBuffers.d.ts.map +1 -0
  62. package/build/utils/concatenateBuffers.js +21 -0
  63. package/build/utils/concatenateBuffers.js.map +1 -0
  64. package/build/utils/convertPCMToFloat32.d.ts +2 -2
  65. package/build/utils/convertPCMToFloat32.d.ts.map +1 -1
  66. package/build/utils/convertPCMToFloat32.js +49 -36
  67. package/build/utils/convertPCMToFloat32.js.map +1 -1
  68. package/build/utils/encodingToBitDepth.d.ts +1 -1
  69. package/build/utils/encodingToBitDepth.d.ts.map +1 -1
  70. package/build/utils/encodingToBitDepth.js +3 -3
  71. package/build/utils/encodingToBitDepth.js.map +1 -1
  72. package/build/utils/getWavFileInfo.d.ts +4 -3
  73. package/build/utils/getWavFileInfo.d.ts.map +1 -1
  74. package/build/utils/getWavFileInfo.js +18 -15
  75. package/build/utils/getWavFileInfo.js.map +1 -1
  76. package/build/utils/writeWavHeader.d.ts.map +1 -1
  77. package/build/utils/writeWavHeader.js +4 -4
  78. package/build/utils/writeWavHeader.js.map +1 -1
  79. package/build/workers/InlineFeaturesExtractor.web.d.ts.map +1 -1
  80. package/build/workers/InlineFeaturesExtractor.web.js.map +1 -1
  81. package/build/workers/inlineAudioWebWorker.web.d.ts.map +1 -1
  82. package/build/workers/inlineAudioWebWorker.web.js.map +1 -1
  83. package/expo-module.config.json +8 -17
  84. package/ios/AudioStreamManager.swift +1 -0
  85. package/ios/ExpoAudioStreamModule.swift +1 -0
  86. package/ios/RecordingResult.swift +1 -0
  87. package/package.json +72 -65
  88. package/plugin/build/index.d.ts +1 -1
  89. package/plugin/build/index.js +7 -7
  90. package/plugin/src/index.ts +47 -47
  91. package/plugin/tsconfig.json +8 -13
  92. package/src/AudioAnalysis/AudioAnalysis.types.ts +59 -60
  93. package/src/AudioAnalysis/extractAudioAnalysis.ts +132 -121
  94. package/src/AudioAnalysis/extractWaveform.ts +18 -18
  95. package/src/AudioRecorder.provider.tsx +53 -53
  96. package/src/ExpoAudioStream.native.ts +2 -2
  97. package/src/ExpoAudioStream.types.ts +56 -53
  98. package/src/ExpoAudioStream.web.ts +232 -205
  99. package/src/ExpoAudioStreamModule.ts +17 -16
  100. package/src/WebRecorder.web.ts +407 -390
  101. package/src/constants.ts +11 -11
  102. package/src/events.ts +27 -13
  103. package/src/index.ts +15 -15
  104. package/src/logger.ts +15 -18
  105. package/src/useAudioRecorder.tsx +394 -389
  106. package/src/utils/BlobFix.ts +550 -0
  107. package/src/utils/concatenateBuffers.ts +24 -0
  108. package/src/utils/convertPCMToFloat32.ts +72 -45
  109. package/src/utils/encodingToBitDepth.ts +14 -14
  110. package/src/utils/getWavFileInfo.ts +106 -99
  111. package/src/utils/writeWavHeader.ts +45 -45
  112. package/src/workers/InlineFeaturesExtractor.web.tsx +1 -1
  113. package/src/workers/inlineAudioWebWorker.web.tsx +1 -1
  114. package/tsconfig.json +12 -7
package/package.json CHANGED
@@ -1,67 +1,74 @@
1
1
  {
2
- "name": "@siteed/expo-audio-stream",
3
- "version": "1.0.3",
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
- "prepare": "expo-module prepare",
30
- "prepublishOnly": "expo-module prepublishOnly",
31
- "expo-module": "expo-module",
32
- "open:ios": "open -a \"Xcode\" ../../apps/playground/ios",
33
- "open:android": "open -a \"Android Studio\" ../../apps/playground/android",
34
- "size": "bundle-size && size-limit"
35
- },
36
- "devDependencies": {
37
- "@expo/config-plugins": "^7.9.1",
38
- "@size-limit/preset-big-lib": "^11.1.4",
39
- "@types/debug": "^4.1.12",
40
- "@types/node": "^20.12.7",
41
- "@types/react": "^18.0.25",
42
- "@typescript-eslint/eslint-plugin": "^7.7.0",
43
- "@typescript-eslint/parser": "^7.7.0",
44
- "bundle-size": "^1.1.5",
45
- "eslint": "^8.56.0",
46
- "eslint-config-prettier": "^9.1.0",
47
- "eslint-config-universe": "^12.0.0",
48
- "eslint-plugin-import": "^2.29.1",
49
- "eslint-plugin-prettier": "^5.1.3",
50
- "eslint-plugin-promise": "^6.1.1",
51
- "eslint-plugin-react": "^7.34.1",
52
- "expo-module-scripts": "^3.5.2",
53
- "expo-modules-core": "^1.12.19",
54
- "prettier": "^3.2.5",
55
- "react-native": "^0.74.3",
56
- "size-limit": "^11.1.4"
57
- },
58
- "peerDependencies": {
59
- "expo": "*",
60
- "react": "*",
61
- "react-native": "*"
62
- },
63
- "publishConfig": {
64
- "access": "public",
65
- "registry": "https://registry.npmjs.org"
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
  }
@@ -1,4 +1,4 @@
1
- import { ConfigPlugin } from "@expo/config-plugins";
1
+ import { ConfigPlugin } from '@expo/config-plugins';
2
2
  declare const withRecordingPermission: ConfigPlugin<{
3
3
  microphonePermission: string;
4
4
  }>;
@@ -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 = "Allow $(PRODUCT_NAME) to access your microphone";
4
+ const MICROPHONE_USAGE = 'Allow $(PRODUCT_NAME) to access your microphone';
5
5
  const withRecordingPermission = (config, existingPerms) => {
6
6
  if (!existingPerms) {
7
- console.warn("No previous permissions provided");
7
+ console.warn('No previous permissions provided');
8
8
  }
9
9
  config = (0, config_plugins_1.withInfoPlist)(config, (config) => {
10
- config.modResults["NSMicrophoneUsageDescription"] = MICROPHONE_USAGE;
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("audio")) {
14
- existingBackgroundModes.push("audio");
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, "android.permission.RECORD_AUDIO", MICROPHONE_USAGE);
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, "android.permission.FOREGROUND_SERVICE", "This apps needs access to the foreground service to record audio in the background");
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;
@@ -1,53 +1,53 @@
1
1
  import {
2
- AndroidConfig,
3
- ConfigPlugin,
4
- withAndroidManifest,
5
- withInfoPlist,
6
- } from "@expo/config-plugins";
2
+ AndroidConfig,
3
+ ConfigPlugin,
4
+ withAndroidManifest,
5
+ withInfoPlist,
6
+ } from '@expo/config-plugins'
7
7
 
8
- const MICROPHONE_USAGE = "Allow $(PRODUCT_NAME) to access your microphone";
8
+ const MICROPHONE_USAGE = 'Allow $(PRODUCT_NAME) to access your microphone'
9
9
 
10
10
  const withRecordingPermission: ConfigPlugin<{
11
- microphonePermission: string;
11
+ microphonePermission: string
12
12
  }> = (config, existingPerms) => {
13
- if (!existingPerms) {
14
- console.warn("No previous permissions provided");
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.modResults.UIBackgroundModes = existingBackgroundModes;
25
-
26
- return config;
27
- });
28
-
29
- config = withAndroidManifest(config, (config) => {
30
- const mainApplication = AndroidConfig.Manifest.getMainApplicationOrThrow(
31
- config.modResults,
32
- );
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;
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
@@ -1,14 +1,9 @@
1
1
  {
2
- "extends": "expo-module-scripts/tsconfig.plugin",
3
- "compilerOptions": {
4
- "outDir": "build",
5
- "rootDir": "src"
6
- },
7
- "include": [
8
- "./src",
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
- 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.
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
- 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;
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
- 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;
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 AudioAnalysisData {
64
- pointsPerSecond: number; // How many consolidated value per second
65
- durationMs: number; // Duration of the audio in milliseconds
66
- bitDepth: number; // Bit depth of the audio
67
- samples: number; // Size of the audio in bytes
68
- numberOfChannels: number; // Number of audio channels
69
- sampleRate: number; // Sample rate of the audio
70
- dataPoints: DataPoint[]; // Array of data points from the analysis.
71
- amplitudeRange: {
72
- min: number;
73
- max: number;
74
- };
75
- // TODO: speaker detection
76
- speakerChanges?: {
77
- timestamp: number; // Timestamp of the speaker change in milliseconds.
78
- speaker: number; // Speaker identifier.
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
- }