dmed-voice-assistant 1.2.15 → 1.2.16

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 (2) hide show
  1. package/dist/recorder.js +22 -24
  2. package/package.json +1 -1
package/dist/recorder.js CHANGED
@@ -75,6 +75,7 @@ const RecorderBox = _ref => {
75
75
  };
76
76
  const initRecorder = async () => {
77
77
  try {
78
+ fetchAudioInputDevices();
78
79
  const stream = await navigator.mediaDevices.getUserMedia({
79
80
  audio: true
80
81
  });
@@ -86,6 +87,27 @@ const RecorderBox = _ref => {
86
87
  console.error("Unable to access microphone", error);
87
88
  }
88
89
  };
90
+ const fetchAudioInputDevices = async () => {
91
+ try {
92
+ // Request permission to access media devices
93
+ await navigator.mediaDevices.getUserMedia({
94
+ audio: true
95
+ });
96
+
97
+ // Enumerate all media devices
98
+ const devices = await navigator.mediaDevices.enumerateDevices();
99
+
100
+ // Filter only audio input devices
101
+ const audioInputs = devices.filter(device => device.kind === "audioinput");
102
+ let temp = ['Auto-Detect'];
103
+ audioInputs.forEach(device => {
104
+ temp.push(device.label);
105
+ });
106
+ setVoiceList(temp);
107
+ } catch (error) {
108
+ console.error("Error accessing audio devices:", error);
109
+ }
110
+ };
89
111
  const startRecording = async () => {
90
112
  if (!mediaRecorderRef.current) {
91
113
  await initRecorder();
@@ -174,30 +196,6 @@ const RecorderBox = _ref => {
174
196
  clearInterval(intervalId); // Stop the interval using the interval ID
175
197
  setIsRunning(false); // Set the counter as not running
176
198
  };
177
- (0, _react.useEffect)(() => {
178
- const fetchAudioInputDevices = async () => {
179
- try {
180
- // Request permission to access media devices
181
- await navigator.mediaDevices.getUserMedia({
182
- audio: true
183
- });
184
-
185
- // Enumerate all media devices
186
- const devices = await navigator.mediaDevices.enumerateDevices();
187
-
188
- // Filter only audio input devices
189
- const audioInputs = devices.filter(device => device.kind === "audioinput");
190
- let temp = ['Auto-Detect'];
191
- audioInputs.forEach(device => {
192
- temp.push(device.label);
193
- });
194
- setVoiceList(temp);
195
- } catch (error) {
196
- console.error("Error accessing audio devices:", error);
197
- }
198
- };
199
- fetchAudioInputDevices();
200
- }, []);
201
199
  (0, _react.useEffect)(() => {
202
200
  setRecordList([...recordHistoryList]);
203
201
  }, [recordHistoryList]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dmed-voice-assistant",
3
- "version": "1.2.15",
3
+ "version": "1.2.16",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist"