uneeq-js 2.47.5 → 2.47.7
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/index.js +1 -1
- package/dist/src/service/api.d.ts +1 -0
- package/dist/src/service/speech-handler.d.ts +4 -0
- package/dist/src/types/SpeechHandlerOptions.d.ts +1 -0
- package/dist/src/uneeq.d.ts +11 -0
- package/dist/umd/index.js +107 -31
- package/package.json +1 -1
- package/readme.md +6 -0
|
@@ -29,6 +29,7 @@ export declare class API {
|
|
|
29
29
|
setAvatarDebug(enabled: boolean): Promise<any>;
|
|
30
30
|
sendMediaUnavailable(data: MediaUnavailableRequest): Promise<any>;
|
|
31
31
|
getEdgeNodeId(turnServerAddress: string): Promise<any>;
|
|
32
|
+
getSessionJwt(personaId: string): Promise<any>;
|
|
32
33
|
getTimeZone(): string;
|
|
33
34
|
private makeRequest;
|
|
34
35
|
private getRequest;
|
|
@@ -10,7 +10,11 @@ export declare class SpeechHandler {
|
|
|
10
10
|
private headerBlob;
|
|
11
11
|
private scriptsLoadedPromise;
|
|
12
12
|
private digitalHumanSpeaking;
|
|
13
|
+
private stream;
|
|
13
14
|
constructor(options: SpeechHandlerOptions);
|
|
15
|
+
stopRecognition(): void;
|
|
16
|
+
pause(): boolean;
|
|
17
|
+
resume(): boolean;
|
|
14
18
|
private loadScript;
|
|
15
19
|
private loadScripts;
|
|
16
20
|
private handleAppMessages;
|
package/dist/src/uneeq.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export declare class Uneeq {
|
|
|
27
27
|
private readonly messageCallback;
|
|
28
28
|
private readonly startSessionData;
|
|
29
29
|
private metricsService;
|
|
30
|
+
private sessionJwt;
|
|
30
31
|
private startSessionTime;
|
|
31
32
|
private availableResponseTime;
|
|
32
33
|
private streamManager;
|
|
@@ -102,6 +103,16 @@ export declare class Uneeq {
|
|
|
102
103
|
* When successful a corresponding AvatarRequestCompleted should be received.
|
|
103
104
|
*/
|
|
104
105
|
stopSpeaking(): Promise<void>;
|
|
106
|
+
/**
|
|
107
|
+
* Pause speech recognition. The users speech will not be processed, or sent off their device.
|
|
108
|
+
* This is the equivilent of muting the users microphone.
|
|
109
|
+
*/
|
|
110
|
+
pauseSpeechRecognition(): boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Resume speech recognition. The users speech will being being processed again.
|
|
113
|
+
* This is the equivilent of unmuting the users microphone.
|
|
114
|
+
*/
|
|
115
|
+
resumeSpeechRecognition(): boolean;
|
|
105
116
|
/**
|
|
106
117
|
* Pauses a live session. Local video and audio will stop being sent and remote avatar video audio will be stopped.
|
|
107
118
|
* On success, SessionPausedMessage will be sent.
|
package/dist/umd/index.js
CHANGED
|
@@ -3902,6 +3902,26 @@ class Uneeq {
|
|
|
3902
3902
|
stopSpeaking() {
|
|
3903
3903
|
return this.api.stopSpeaking();
|
|
3904
3904
|
}
|
|
3905
|
+
/**
|
|
3906
|
+
* Pause speech recognition. The users speech will not be processed, or sent off their device.
|
|
3907
|
+
* This is the equivilent of muting the users microphone.
|
|
3908
|
+
*/
|
|
3909
|
+
pauseSpeechRecognition() {
|
|
3910
|
+
if (this.speechHandler) {
|
|
3911
|
+
return this.speechHandler.pause();
|
|
3912
|
+
}
|
|
3913
|
+
return false;
|
|
3914
|
+
}
|
|
3915
|
+
/**
|
|
3916
|
+
* Resume speech recognition. The users speech will being being processed again.
|
|
3917
|
+
* This is the equivilent of unmuting the users microphone.
|
|
3918
|
+
*/
|
|
3919
|
+
resumeSpeechRecognition() {
|
|
3920
|
+
if (this.speechHandler) {
|
|
3921
|
+
return this.speechHandler.resume();
|
|
3922
|
+
}
|
|
3923
|
+
return false;
|
|
3924
|
+
}
|
|
3905
3925
|
/**
|
|
3906
3926
|
* Pauses a live session. Local video and audio will stop being sent and remote avatar video audio will be stopped.
|
|
3907
3927
|
* On success, SessionPausedMessage will be sent.
|
|
@@ -4011,34 +4031,41 @@ class Uneeq {
|
|
|
4011
4031
|
});
|
|
4012
4032
|
}
|
|
4013
4033
|
initDeviceManager() {
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4034
|
+
this.sessionJwt
|
|
4035
|
+
.then(({ token }) => {
|
|
4036
|
+
if (this.options.voiceInputMode === VoiceInputMode_1.VoiceInputMode.SPEECH_RECOGNITION) {
|
|
4037
|
+
this.speechHandler = new speech_handler_1.SpeechHandler({
|
|
4038
|
+
api: this.api,
|
|
4039
|
+
apiUrl: this.options.url,
|
|
4040
|
+
sessionId: this.session.id,
|
|
4041
|
+
messages: this.messages,
|
|
4042
|
+
assetBasePath: this.options.assetBasePath,
|
|
4043
|
+
locales: this.options.speechToTextLocales || '',
|
|
4044
|
+
hintPhrases: this.options.speechRecognitionHintPhrases || '',
|
|
4045
|
+
jwtToken: token
|
|
4046
|
+
});
|
|
4047
|
+
}
|
|
4048
|
+
else {
|
|
4049
|
+
// Legacy implementation
|
|
4050
|
+
// Init Voice Input Manager
|
|
4051
|
+
this.voiceInputManager = new voice_input_manager_1.VoiceInputManager(this.options, this.api, this.messages, (enable) => { this.enableMicrophone(enable); });
|
|
4052
|
+
}
|
|
4053
|
+
this.deviceManager = new device_manager_1.DeviceManager({
|
|
4054
|
+
userMessages: this.messages,
|
|
4055
|
+
session: this.session,
|
|
4019
4056
|
messages: this.messages,
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
session: this.session,
|
|
4033
|
-
messages: this.messages,
|
|
4034
|
-
internalMessages$: this.internalMessages$,
|
|
4035
|
-
messaging: this.messaging,
|
|
4036
|
-
uneeqOptions: this.options,
|
|
4037
|
-
streamManager: this.streamManager,
|
|
4038
|
-
voiceInputManager: this.voiceInputManager,
|
|
4039
|
-
digitalHumanVideoElement: this.digitalHumanVideoElement
|
|
4040
|
-
}, this.api);
|
|
4041
|
-
this.messageHandler.setDeviceManager(this.deviceManager);
|
|
4057
|
+
internalMessages$: this.internalMessages$,
|
|
4058
|
+
messaging: this.messaging,
|
|
4059
|
+
uneeqOptions: this.options,
|
|
4060
|
+
streamManager: this.streamManager,
|
|
4061
|
+
voiceInputManager: this.voiceInputManager,
|
|
4062
|
+
digitalHumanVideoElement: this.digitalHumanVideoElement
|
|
4063
|
+
}, this.api);
|
|
4064
|
+
this.messageHandler.setDeviceManager(this.deviceManager);
|
|
4065
|
+
})
|
|
4066
|
+
.catch((err) => {
|
|
4067
|
+
this.messages.next(new MessageTypes_1.SessionErrorMessage(err));
|
|
4068
|
+
});
|
|
4042
4069
|
}
|
|
4043
4070
|
sessionLiveHandler() {
|
|
4044
4071
|
// Send the SessionLive message and play welcome (optional)
|
|
@@ -4116,6 +4143,7 @@ class Uneeq {
|
|
|
4116
4143
|
if (this.session) {
|
|
4117
4144
|
this.initPromMetricsListener();
|
|
4118
4145
|
this.api.callId = this.session.id;
|
|
4146
|
+
this.sessionJwt = this.api.getSessionJwt(this.options.conversationId);
|
|
4119
4147
|
this.initAvatar();
|
|
4120
4148
|
const messagingOptions = {
|
|
4121
4149
|
maxReconnectAttempts: 3,
|
|
@@ -13240,7 +13268,7 @@ exports.race = race;
|
|
|
13240
13268
|
/***/ ((module) => {
|
|
13241
13269
|
|
|
13242
13270
|
"use strict";
|
|
13243
|
-
module.exports = JSON.parse('{"name":"uneeq-js","version":"2.47.
|
|
13271
|
+
module.exports = JSON.parse('{"name":"uneeq-js","version":"2.47.7","description":"","main":"dist/index.js","types":"dist/src/index.d.ts","scripts":{"start":"npx webpack -w","test-local":"npx karma start karma.conf.js -logLevel=DEBUG","test":"npx karma start --browsers ChromeHeadless --single-run","test:windows":"karma start karma.conf.js","build":"webpack --config webpack.config.prod.js && webpack --config webpack.config.umd.js","lint":"npx tslint -p tsconfig.json --fix","docs":"npx typedoc --options"},"files":["dist","!dist/test"],"author":"","license":"ISC","dependencies":{"@stomp/stompjs":"^6.0.0","@uehreka/seriously":"^1.0.1","fast-text-encoding":"^1.0.0","intrinsic-scale":"^3.0.4","onnxruntime-web":"^1.15.1","promjs":"^0.4.1","ring-buffer-ts":"^1.2.0","rxjs":"^7.8.1","rxjs-compat":"^6.6.7","simple-peer":"^9.11.1","webrtc-adapter":"^8.2.3"},"devDependencies":{"@types/dom-mediacapture-record":"^1.0.16","@types/jasmine":"^2.8.8","@types/node":"^10.9.4","fetch-mock":"7.7.3","ignore-styles":"^5.0.1","jasmine":"^5.1.0","jasmine-core":"^5.1.0","karma":"^6.4.2","karma-chrome-launcher":"^3.2.0","karma-firefox-launcher":"^2.1.2","karma-jasmine":"^5.1.0","karma-jasmine-html-reporter":"^2.1.0","karma-requirejs":"^1.1.0","karma-typescript":"^5.5.4","karma-typescript-es6-transform":"^5.5.4","nock":"^9.6.1","requirejs":"^2.3.6","ts-loader":"^9.4.4","ts-node":"^7.0.1","tslint":"^5.11.0","tslint-no-focused-test":"^0.5.0","typedoc":"^0.18.0","typescript":"^5.1.6","webpack":"^5.88.2","webpack-cli":"^5.1.4"}}');
|
|
13244
13272
|
|
|
13245
13273
|
/***/ }),
|
|
13246
13274
|
/* 242 */
|
|
@@ -13316,6 +13344,19 @@ class API {
|
|
|
13316
13344
|
});
|
|
13317
13345
|
return this.makeRequest(request);
|
|
13318
13346
|
}
|
|
13347
|
+
getSessionJwt(personaId) {
|
|
13348
|
+
const request = new Request(this.apiUrl + '/v1/jwt/token', {
|
|
13349
|
+
method: 'POST',
|
|
13350
|
+
headers: {
|
|
13351
|
+
'Content-Type': 'application/json'
|
|
13352
|
+
},
|
|
13353
|
+
body: JSON.stringify({
|
|
13354
|
+
session_id: this._callId,
|
|
13355
|
+
persona_id: personaId
|
|
13356
|
+
})
|
|
13357
|
+
});
|
|
13358
|
+
return this.makeRequest(request);
|
|
13359
|
+
}
|
|
13319
13360
|
getTimeZone() {
|
|
13320
13361
|
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
13321
13362
|
}
|
|
@@ -51175,13 +51216,44 @@ class SpeechHandler {
|
|
|
51175
51216
|
this.speechBuffer = new ring_buffer_ts_1.RingBuffer(speechBufferLength);
|
|
51176
51217
|
this.recordingLive = false;
|
|
51177
51218
|
this.digitalHumanSpeaking = false;
|
|
51178
|
-
console.warn('
|
|
51219
|
+
console.warn(this.logPrefix + 'SPEECH_RECOGNITION input mode is in development, you may experience issues.');
|
|
51179
51220
|
this.options.assetBasePath = this.options.assetBasePath || defaultAssetPath;
|
|
51180
51221
|
this.loadSavedAudioHeaders();
|
|
51181
51222
|
this.loadScripts();
|
|
51182
51223
|
this.initWebsocket(this.options);
|
|
51183
51224
|
this.handleAppMessages();
|
|
51184
51225
|
}
|
|
51226
|
+
stopRecognition() {
|
|
51227
|
+
if (this.mediaRecorder) {
|
|
51228
|
+
this.mediaRecorder.stop();
|
|
51229
|
+
}
|
|
51230
|
+
if (this.stream) {
|
|
51231
|
+
this.stream.getTracks().forEach((track) => {
|
|
51232
|
+
track.stop();
|
|
51233
|
+
});
|
|
51234
|
+
}
|
|
51235
|
+
if (this.micVad) {
|
|
51236
|
+
this.micVad.pause();
|
|
51237
|
+
}
|
|
51238
|
+
}
|
|
51239
|
+
pause() {
|
|
51240
|
+
if (this.stream && this.micVad) {
|
|
51241
|
+
this.stream.getTracks().forEach((track) => track.enabled = false);
|
|
51242
|
+
this.micVad.pause();
|
|
51243
|
+
return true;
|
|
51244
|
+
}
|
|
51245
|
+
logger_1.logger.warn(this.logPrefix + 'Could not pause speech recognition.');
|
|
51246
|
+
return false;
|
|
51247
|
+
}
|
|
51248
|
+
resume() {
|
|
51249
|
+
if (this.stream && this.micVad) {
|
|
51250
|
+
this.stream.getTracks().forEach((track) => track.enabled = true);
|
|
51251
|
+
this.micVad.start();
|
|
51252
|
+
return true;
|
|
51253
|
+
}
|
|
51254
|
+
logger_1.logger.warn(this.logPrefix + 'Could not resume speech recognition.');
|
|
51255
|
+
return false;
|
|
51256
|
+
}
|
|
51185
51257
|
loadScript(url) {
|
|
51186
51258
|
return new Promise((resolve) => {
|
|
51187
51259
|
const script = document.createElement('script');
|
|
@@ -51212,13 +51284,16 @@ class SpeechHandler {
|
|
|
51212
51284
|
case MessageTypes_1.UneeqMessageType.FinishedSpeaking:
|
|
51213
51285
|
this.digitalHumanSpeaking = false;
|
|
51214
51286
|
break;
|
|
51287
|
+
case MessageTypes_1.UneeqMessageType.SessionEnded:
|
|
51288
|
+
this.stopRecognition();
|
|
51289
|
+
break;
|
|
51215
51290
|
default:
|
|
51216
51291
|
}
|
|
51217
51292
|
});
|
|
51218
51293
|
}
|
|
51219
51294
|
initWebsocket(options) {
|
|
51220
|
-
let connectionUrl = options.apiUrl.replace('https://
|
|
51221
|
-
connectionUrl +=
|
|
51295
|
+
let connectionUrl = options.apiUrl.replace('https://', 'wss://');
|
|
51296
|
+
connectionUrl += `/speech-recognition/ws/recognize?jwt=${options.jwtToken}&session_id=${options.sessionId}`;
|
|
51222
51297
|
logger_1.logger.log(this.logPrefix + 'Initializing speech recognition websocket to ' + connectionUrl);
|
|
51223
51298
|
this.ws = new WebSocket(connectionUrl);
|
|
51224
51299
|
this.ws.onopen = () => {
|
|
@@ -51319,6 +51394,7 @@ class SpeechHandler {
|
|
|
51319
51394
|
initMicrophone() {
|
|
51320
51395
|
navigator.mediaDevices.getUserMedia({ audio: { sampleRate: audioSampleRate, channelCount: audioChannelCount } })
|
|
51321
51396
|
.then((stream) => {
|
|
51397
|
+
this.stream = stream;
|
|
51322
51398
|
this.initVoiceActivityDetection(stream);
|
|
51323
51399
|
this.initMediaRecorder(stream);
|
|
51324
51400
|
})
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -8,6 +8,12 @@ https://docs.uneeq.io/build-your-own-experience
|
|
|
8
8
|
To use uneeq-js with a typescript version < 3.8, 'skipLibCheck' must be set to true.
|
|
9
9
|
|
|
10
10
|
## Release Notes
|
|
11
|
+
#### 2.47.7
|
|
12
|
+
* added jwt security to speech recognition
|
|
13
|
+
|
|
14
|
+
#### 2.47.6
|
|
15
|
+
* Speech Recognition: added support for pause and resume.
|
|
16
|
+
|
|
11
17
|
#### 2.47.5
|
|
12
18
|
* Speech Recognition mode: Stop the digital human from speaking when an interim speech result is received.
|
|
13
19
|
|