@siteed/expo-audio-studio 2.4.1 → 2.5.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.
Files changed (80) hide show
  1. package/CHANGELOG.md +10 -1
  2. package/README.md +25 -0
  3. package/android/src/main/java/net/siteed/audiostream/AudioAnalysisData.kt +22 -0
  4. package/android/src/main/java/net/siteed/audiostream/AudioDeviceManager.kt +1501 -0
  5. package/android/src/main/java/net/siteed/audiostream/AudioFileHandler.kt +10 -5
  6. package/android/src/main/java/net/siteed/audiostream/AudioNotificationsManager.kt +27 -25
  7. package/android/src/main/java/net/siteed/audiostream/AudioProcessor.kt +73 -71
  8. package/android/src/main/java/net/siteed/audiostream/AudioRecorderManager.kt +576 -252
  9. package/android/src/main/java/net/siteed/audiostream/Constants.kt +17 -1
  10. package/android/src/main/java/net/siteed/audiostream/ExpoAudioStreamModule.kt +419 -155
  11. package/android/src/main/java/net/siteed/audiostream/LogUtils.kt +65 -0
  12. package/android/src/main/java/net/siteed/audiostream/RecordingConfig.kt +9 -1
  13. package/build/AudioAnalysis/AudioAnalysis.types.js.map +1 -1
  14. package/build/AudioDeviceManager.d.ts +107 -0
  15. package/build/AudioDeviceManager.d.ts.map +1 -0
  16. package/build/AudioDeviceManager.js +493 -0
  17. package/build/AudioDeviceManager.js.map +1 -0
  18. package/build/AudioRecorder.provider.d.ts.map +1 -1
  19. package/build/AudioRecorder.provider.js +3 -0
  20. package/build/AudioRecorder.provider.js.map +1 -1
  21. package/build/ExpoAudioStream.types.d.ts +90 -1
  22. package/build/ExpoAudioStream.types.d.ts.map +1 -1
  23. package/build/ExpoAudioStream.types.js +7 -1
  24. package/build/ExpoAudioStream.types.js.map +1 -1
  25. package/build/ExpoAudioStream.web.d.ts +37 -0
  26. package/build/ExpoAudioStream.web.d.ts.map +1 -1
  27. package/build/ExpoAudioStream.web.js +399 -54
  28. package/build/ExpoAudioStream.web.js.map +1 -1
  29. package/build/ExpoAudioStreamModule.d.ts.map +1 -1
  30. package/build/ExpoAudioStreamModule.js +20 -0
  31. package/build/ExpoAudioStreamModule.js.map +1 -1
  32. package/build/WebRecorder.web.d.ts +63 -10
  33. package/build/WebRecorder.web.d.ts.map +1 -1
  34. package/build/WebRecorder.web.js +277 -68
  35. package/build/WebRecorder.web.js.map +1 -1
  36. package/build/hooks/useAudioDevices.d.ts +14 -0
  37. package/build/hooks/useAudioDevices.d.ts.map +1 -0
  38. package/build/hooks/useAudioDevices.js +151 -0
  39. package/build/hooks/useAudioDevices.js.map +1 -0
  40. package/build/index.d.ts +2 -0
  41. package/build/index.d.ts.map +1 -1
  42. package/build/index.js +4 -0
  43. package/build/index.js.map +1 -1
  44. package/build/useAudioRecorder.d.ts +1 -0
  45. package/build/useAudioRecorder.d.ts.map +1 -1
  46. package/build/useAudioRecorder.js +20 -1
  47. package/build/useAudioRecorder.js.map +1 -1
  48. package/build/utils/BlobFix.d.ts.map +1 -1
  49. package/build/utils/BlobFix.js +2 -2
  50. package/build/utils/BlobFix.js.map +1 -1
  51. package/build/workers/InlineFeaturesExtractor.web.d.ts +1 -1
  52. package/build/workers/InlineFeaturesExtractor.web.d.ts.map +1 -1
  53. package/build/workers/InlineFeaturesExtractor.web.js +27 -26
  54. package/build/workers/InlineFeaturesExtractor.web.js.map +1 -1
  55. package/build/workers/inlineAudioWebWorker.web.d.ts +1 -1
  56. package/build/workers/inlineAudioWebWorker.web.d.ts.map +1 -1
  57. package/build/workers/inlineAudioWebWorker.web.js +25 -1
  58. package/build/workers/inlineAudioWebWorker.web.js.map +1 -1
  59. package/ios/AudioDeviceManager.swift +654 -0
  60. package/ios/AudioStreamManager.swift +964 -760
  61. package/ios/ExpoAudioStreamModule.swift +174 -19
  62. package/ios/Features.swift +1 -1
  63. package/ios/ISSUE_IOS.md +45 -0
  64. package/ios/Logger.swift +13 -1
  65. package/ios/RecordingSettings.swift +12 -0
  66. package/package.json +2 -2
  67. package/src/AudioAnalysis/AudioAnalysis.types.ts +2 -2
  68. package/src/AudioDeviceManager.ts +571 -0
  69. package/src/AudioRecorder.provider.tsx +3 -0
  70. package/src/ExpoAudioStream.types.ts +97 -1
  71. package/src/ExpoAudioStream.web.ts +513 -63
  72. package/src/ExpoAudioStreamModule.ts +23 -0
  73. package/src/WebRecorder.web.ts +346 -81
  74. package/src/hooks/useAudioDevices.ts +180 -0
  75. package/src/index.ts +6 -0
  76. package/src/types/crc-32.d.ts +6 -6
  77. package/src/useAudioRecorder.tsx +27 -1
  78. package/src/utils/BlobFix.ts +6 -4
  79. package/src/workers/InlineFeaturesExtractor.web.tsx +27 -26
  80. package/src/workers/inlineAudioWebWorker.web.tsx +25 -1
package/CHANGELOG.md CHANGED
@@ -8,6 +8,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8
8
  ## [Unreleased]
9
9
 
10
10
 
11
+ ## [2.5.0] - 2025-04-30
12
+ ### Changed
13
+ - fix(ios): ensure complete audio data emission on recording stop/pause (#215) ([236e7aa](https://github.com/deeeed/expo-audio-stream/commit/236e7aa040d11626f06da9bbf5746cdcb6f2b457))
14
+ - feat(audio-device): Complete Android implementation for audio device API (#214) ([cedc8d2](https://github.com/deeeed/expo-audio-stream/commit/cedc8d2fbdd5317652ee31c70ee596ec946cf22e))
15
+ - feat(audio-device): Implement cross-platform audio device detection, selection, and fallback handling (#213) ([023b8a1](https://github.com/deeeed/expo-audio-stream/commit/023b8a1d9844bff9f57781860e38a53eb4684fda))
16
+ - feat: Add Zero-Latency Audio Recording with `prepareRecording` API (#211) ([30cb56c](https://github.com/deeeed/expo-audio-stream/commit/30cb56c07d14e7012bff9a4c4d458d5a49cf494e))
17
+ - docs: update api references for v2.4.1 ([b15daef](https://github.com/deeeed/expo-audio-stream/commit/b15daef29a631eb696d5a28422f9cf32b080027e))
18
+ - chore(sherpa-onnx-demo): Restructure WebAssembly Setup and Clean Up Assets (#208) ([7c2adff](https://github.com/deeeed/expo-audio-stream/commit/7c2adffc5ff59391315cb8edaeaae2ab676dd2ba))
11
19
  ## [2.4.1] - 2025-04-08
12
20
  ### Changed
13
21
  - feat(audio-stream): enhance background audio handling and permission checks (#200) ([60befbe](https://github.com/deeeed/expo-audio-stream/commit/60befbedc9d3cbcc1fc684254d812381e5905e43))
@@ -192,7 +200,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
192
200
  - Feature: Audio features extraction during recording.
193
201
  - Feature: Consistent WAV PCM recording format across all platforms.
194
202
 
195
- [unreleased]: https://github.com/deeeed/expo-audio-stream/compare/@siteed/expo-audio-studio@2.4.1...HEAD
203
+ [unreleased]: https://github.com/deeeed/expo-audio-stream/compare/@siteed/expo-audio-studio@2.5.0...HEAD
204
+ [2.5.0]: https://github.com/deeeed/expo-audio-stream/compare/@siteed/expo-audio-studio@2.4.1...@siteed/expo-audio-studio@2.5.0
196
205
  [2.4.1]: https://github.com/deeeed/expo-audio-stream/compare/@siteed/expo-audio-studio@2.4.0...@siteed/expo-audio-studio@2.4.1
197
206
  [2.4.0]: https://github.com/deeeed/expo-audio-stream/compare/@siteed/expo-audio-studio@2.3.1...@siteed/expo-audio-studio@2.4.0
198
207
  [2.3.1]: https://github.com/deeeed/expo-audio-stream/compare/@siteed/expo-audio-studio@2.3.0...@siteed/expo-audio-studio@2.3.1
package/README.md CHANGED
@@ -36,6 +36,12 @@
36
36
  ## Features
37
37
 
38
38
  - Real-time audio streaming across iOS, Android, and web.
39
+ - Audio input device detection and selection:
40
+ - List and select from available audio input devices
41
+ - View detailed device capabilities (sample rates, channels, bit depths)
42
+ - Support for Bluetooth, USB, and wired devices
43
+ - Automatic device management with fallback options
44
+ - Intelligent detection refresh for Bluetooth devices
39
45
  - Dual-stream recording capabilities:
40
46
  - Simultaneous raw PCM and compressed audio recording
41
47
  - Compression formats: OPUS or AAC
@@ -51,6 +57,10 @@
51
57
  - Audio features extraction during recording.
52
58
  - Consistent WAV PCM recording format across all platforms.
53
59
  - Keep recording active while app is in background
60
+ - Zero-latency recording with preparation API:
61
+ - Pre-initialize audio recording to eliminate startup delay
62
+ - Prepare permissions, audio buffers, and sessions in advance
63
+ - Start recording instantly when needed
54
64
  - Rich notification system for recording status:
55
65
  - Android: Live waveform visualization in notifications
56
66
  - Android: Fully customizable notification appearance and actions
@@ -127,6 +137,19 @@ const { startRecording, stopRecording, isRecording, recordingUri } = useAudioRec
127
137
  outputFormat: 'wav',
128
138
  });
129
139
 
140
+ // Use the prepare API for zero-latency recording
141
+ const { prepareRecording, startRecording, stopRecording } = useSharedAudioRecorder();
142
+
143
+ // First prepare the recording - this initializes all resources
144
+ await prepareRecording({
145
+ sampleRate: 44100,
146
+ channels: 2,
147
+ encoding: 'pcm_16bit'
148
+ });
149
+
150
+ // Later when needed, start instantly with no delay
151
+ await startRecording(/* same config as prepare */);
152
+
130
153
  // Share recording state across components
131
154
  const AudioApp = () => (
132
155
  <AudioRecorderProvider>
@@ -228,6 +251,8 @@ const permissions = await ExpoAudioStreamModule.getPermissionsAsync();
228
251
 
229
252
  For detailed documentation, please refer to the [Getting Started Guide](https://deeeed.github.io/expo-audio-stream/docs/).
230
253
 
254
+ For developers interested in contributing or debugging the library, please see the [Contribution Guide](./CONTRIBUTE.md).
255
+
231
256
  ## Companion Resources
232
257
 
233
258
  ### AudioPlayground Application
@@ -3,11 +3,19 @@ package net.siteed.audiostream
3
3
 
4
4
  import android.os.Bundle
5
5
  import androidx.core.os.bundleOf
6
+ import net.siteed.audiostream.LogUtils
6
7
 
8
+ /**
9
+ * Represents speech-related features of an audio segment
10
+ */
7
11
  data class SpeechFeatures(
8
12
  val isActive: Boolean,
9
13
  val speakerId: Int? = null
10
14
  ) {
15
+ companion object {
16
+ private const val CLASS_NAME = "SpeechFeatures"
17
+ }
18
+
11
19
  fun toDictionary(): Map<String, Any?> {
12
20
  return mapOf(
13
21
  "isActive" to isActive,
@@ -23,6 +31,9 @@ data class SpeechFeatures(
23
31
  }
24
32
  }
25
33
 
34
+ /**
35
+ * A single data point in the audio analysis result
36
+ */
26
37
  data class DataPoint(
27
38
  val id: Long,
28
39
  val amplitude: Float,
@@ -37,6 +48,10 @@ data class DataPoint(
37
48
  val endPosition: Int? = null,
38
49
  val samples: Int = 0
39
50
  ) {
51
+ companion object {
52
+ private const val CLASS_NAME = "DataPoint"
53
+ }
54
+
40
55
  fun toDictionary(): Map<String, Any?> {
41
56
  return mapOf(
42
57
  "id" to id,
@@ -72,6 +87,9 @@ data class DataPoint(
72
87
  }
73
88
  }
74
89
 
90
+ /**
91
+ * Primary class to hold audio analysis results
92
+ */
75
93
  data class AudioAnalysisData(
76
94
  val segmentDurationMs: Int,
77
95
  val durationMs: Int,
@@ -85,6 +103,10 @@ data class AudioAnalysisData(
85
103
  val speechAnalysis: SpeechAnalysis? = null,
86
104
  val extractionTimeMs: Float
87
105
  ) {
106
+ companion object {
107
+ private const val CLASS_NAME = "AudioAnalysisData"
108
+ }
109
+
88
110
  data class AmplitudeRange(val min: Float, val max: Float) {
89
111
  fun toDictionary(): Map<String, Float> {
90
112
  return mapOf("min" to min, "max" to max)