speaker-calibration 2.2.268 → 2.2.269
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/dist/example/i18n.js +6144 -5199
- package/dist/listener.js +1 -1
- package/dist/main.js +1 -1
- package/dist/phonePeer.js +2 -2
- package/package.json +1 -1
- package/src/listener-app/PhonePeer.js +19 -14
- package/src/peer-connection/speaker.js +11 -1
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@ export class PhonePeer {
|
|
|
9
9
|
targetElementId: 'display',
|
|
10
10
|
microphoneFromAPI: '',
|
|
11
11
|
microphoneDeviceId: '',
|
|
12
|
+
lang: 'en',
|
|
12
13
|
};
|
|
13
14
|
this.listener = null;
|
|
14
15
|
this.connectionManager = null;
|
|
@@ -38,7 +39,7 @@ export class PhonePeer {
|
|
|
38
39
|
this.listenerParameters.speakerPeerId = payload.speakerPeerId;
|
|
39
40
|
this.listenerParameters.hz = payload.hz;
|
|
40
41
|
this.listenerParameters.bits = payload.bits;
|
|
41
|
-
this.listenerParameters.lang = payload.lang;
|
|
42
|
+
this.listenerParameters.lang = payload.lang ?? 'en';
|
|
42
43
|
this.listenerParameters.deviceId = payload.deviceId;
|
|
43
44
|
this.listenerParameters.sp = payload.sp;
|
|
44
45
|
this.listenerParameters.microphoneDeviceId = payload.deviceId;
|
|
@@ -128,7 +129,8 @@ export class PhonePeer {
|
|
|
128
129
|
await this.checkAndRequestMicrophonePermission();
|
|
129
130
|
} else {
|
|
130
131
|
const allowMicrophoneElement = document.getElementById('allowMicrophone');
|
|
131
|
-
|
|
132
|
+
let language = this.listenerParameters.lang;
|
|
133
|
+
allowMicrophoneElement.innerText = this.phrases.RC_microphonePermissionDenied[language];
|
|
132
134
|
this.listener.sendPermissionStatus({
|
|
133
135
|
type: 'error',
|
|
134
136
|
error: 'Connection setup timed out after 30 seconds',
|
|
@@ -141,7 +143,8 @@ export class PhonePeer {
|
|
|
141
143
|
const allowMicrophoneElement = document.getElementById('allowMicrophone');
|
|
142
144
|
|
|
143
145
|
// Show permission request message
|
|
144
|
-
|
|
146
|
+
let language = this.listenerParameters.lang;
|
|
147
|
+
allowMicrophoneElement.innerText = this.phrases.RC_microphonePermission[language];
|
|
145
148
|
container.style.display = 'block';
|
|
146
149
|
|
|
147
150
|
// Function to request microphone access
|
|
@@ -154,7 +157,7 @@ export class PhonePeer {
|
|
|
154
157
|
if (err.name === 'NotAllowedError') {
|
|
155
158
|
console.log('Permission explicitly denied');
|
|
156
159
|
// Permission explicitly denied
|
|
157
|
-
allowMicrophoneElement.innerText = this.phrases.RC_microphonePermissionDenied[
|
|
160
|
+
allowMicrophoneElement.innerText = this.phrases.RC_microphonePermissionDenied[language];
|
|
158
161
|
// Send denied status and end study
|
|
159
162
|
let error = JSON.stringify(err);
|
|
160
163
|
this.listener.sendPermissionStatus({type: 'denied', error: error});
|
|
@@ -169,7 +172,7 @@ export class PhonePeer {
|
|
|
169
172
|
} else {
|
|
170
173
|
console.log('All retries failed, treating as denied');
|
|
171
174
|
// After all retries failed, treat as denied
|
|
172
|
-
allowMicrophoneElement.innerText = this.phrases.RC_microphonePermissionDenied[
|
|
175
|
+
allowMicrophoneElement.innerText = this.phrases.RC_microphonePermissionDenied[language];
|
|
173
176
|
let error = JSON.stringify(err);
|
|
174
177
|
this.listener.sendPermissionStatus({type: 'error', error: error});
|
|
175
178
|
}
|
|
@@ -180,7 +183,7 @@ export class PhonePeer {
|
|
|
180
183
|
await requestMicAccess();
|
|
181
184
|
} catch (err) {
|
|
182
185
|
console.error('Error requesting microphone permission:', err);
|
|
183
|
-
allowMicrophoneElement.innerText = this.phrases.RC_microphonePermissionDenied[
|
|
186
|
+
allowMicrophoneElement.innerText = this.phrases.RC_microphonePermissionDenied[language];
|
|
184
187
|
let error = JSON.stringify(err);
|
|
185
188
|
this.listener.sendPermissionStatus({type: 'error', error: error});
|
|
186
189
|
}
|
|
@@ -190,8 +193,9 @@ export class PhonePeer {
|
|
|
190
193
|
const container = document.getElementById('listenerContainer');
|
|
191
194
|
const allowMicrophoneElement = document.getElementById('allowMicrophone');
|
|
192
195
|
const turnMessageElement = document.getElementById('turnMeToReadBelow');
|
|
193
|
-
|
|
194
|
-
const
|
|
196
|
+
let language = this.listenerParameters.lang;
|
|
197
|
+
const placeSmartphoneMicrophone = this.phrases.RC_placeSmartphoneMicrophone[language];
|
|
198
|
+
const turnMeToReadBelow = this.phrases.RC_turnMeToReadBelow[language];
|
|
195
199
|
|
|
196
200
|
allowMicrophoneElement.innerText = placeSmartphoneMicrophone;
|
|
197
201
|
allowMicrophoneElement.style.lineHeight = '1.2rem';
|
|
@@ -241,7 +245,7 @@ export class PhonePeer {
|
|
|
241
245
|
const allowMicrophoneElement = document.getElementById('allowMicrophone');
|
|
242
246
|
const container = document.getElementById('listenerContainer');
|
|
243
247
|
const targetElement = document.getElementById('display');
|
|
244
|
-
|
|
248
|
+
let language = this.listenerParameters.lang;
|
|
245
249
|
// Clear unnecessary elements
|
|
246
250
|
calibrationBeginButton.remove();
|
|
247
251
|
turnMessageElement.remove();
|
|
@@ -263,8 +267,8 @@ export class PhonePeer {
|
|
|
263
267
|
const title = document.createElement('h1');
|
|
264
268
|
const titleText =
|
|
265
269
|
window.innerWidth >= 1366
|
|
266
|
-
? this.phrases.RC_soundRecording[
|
|
267
|
-
: this.phrases.RC_soundRecordingSmallScreen[
|
|
270
|
+
? this.phrases.RC_soundRecording[language]
|
|
271
|
+
: this.phrases.RC_soundRecordingSmallScreen[language];
|
|
268
272
|
|
|
269
273
|
// Split small screen title into lines if needed
|
|
270
274
|
if (window.innerWidth < 1366 && titleText.includes('\n')) {
|
|
@@ -441,9 +445,10 @@ export class PhonePeer {
|
|
|
441
445
|
const container = document.getElementById('listenerContainer');
|
|
442
446
|
const recordingInProgressElement = document.getElementById('recordingInProgress');
|
|
443
447
|
const allowMicrophoneElement = document.getElementById('allowMicrophone');
|
|
444
|
-
|
|
445
|
-
const
|
|
446
|
-
const
|
|
448
|
+
let language = this.listenerParameters.lang;
|
|
449
|
+
const recordingInProgress = this.phrases.RC_soundRecording[language];
|
|
450
|
+
const backToExperimentWindow = this.phrases.RC_backToExperimentWindow[language];
|
|
451
|
+
const allowMicrophone = this.phrases.RC_allowMicrophoneUse[language];
|
|
447
452
|
|
|
448
453
|
// remove the button
|
|
449
454
|
const calibrationBeginButton = document.getElementById('calibrationBeginButton');
|
|
@@ -251,10 +251,20 @@ class Speaker extends AudioPeer {
|
|
|
251
251
|
message: 'Text',
|
|
252
252
|
text: 'Loading...',
|
|
253
253
|
});
|
|
254
|
+
//only send the following fields, RC_microphonePermissionDenied, RC_microphonePermission, RC_placeSmartphoneMicrophone, RC_turnMeToReadBelow, RC_soundRecording, RC_soundRecordingSmallScreen, RC_soundRecording, RC_backToExperimentWindow, RC_allowMicrophoneUse
|
|
254
255
|
speaker.connectionManager.send({
|
|
255
256
|
name: 'SoundCalibration',
|
|
256
257
|
message: 'phrases',
|
|
257
|
-
payload:
|
|
258
|
+
payload: {
|
|
259
|
+
RC_microphonePermissionDenied: speaker.phrases.RC_microphonePermissionDenied,
|
|
260
|
+
RC_microphonePermission: speaker.phrases.RC_microphonePermission,
|
|
261
|
+
RC_placeSmartphoneMicrophone: speaker.phrases.RC_placeSmartphoneMicrophone,
|
|
262
|
+
RC_turnMeToReadBelow: speaker.phrases.RC_turnMeToReadBelow,
|
|
263
|
+
RC_soundRecording: speaker.phrases.RC_soundRecording,
|
|
264
|
+
RC_soundRecordingSmallScreen: speaker.phrases.RC_soundRecordingSmallScreen,
|
|
265
|
+
RC_backToExperimentWindow: speaker.phrases.RC_backToExperimentWindow,
|
|
266
|
+
RC_allowMicrophoneUse: speaker.phrases.RC_allowMicrophoneUse,
|
|
267
|
+
},
|
|
258
268
|
});
|
|
259
269
|
|
|
260
270
|
// Send connection parameters to the listener
|