uneeq-js 2.47.4 → 2.47.6
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 -1
- package/dist/src/service/speech-handler.d.ts +6 -0
- package/dist/src/uneeq.d.ts +10 -0
- package/dist/umd/index.js +78 -4
- package/package.json +1 -1
- package/readme.md +6 -0
|
@@ -23,7 +23,7 @@ export declare class API {
|
|
|
23
23
|
avatarAsk(text: string): Promise<void>;
|
|
24
24
|
avatarStartRecording(): Promise<void>;
|
|
25
25
|
avatarStopRecording(): Promise<void>;
|
|
26
|
-
|
|
26
|
+
stopSpeaking(): Promise<void>;
|
|
27
27
|
getAvailableAvatarCount(): Promise<AvatarAvailableCountResponse>;
|
|
28
28
|
startSessionWithToken(data: NewSessionRequest): Promise<NewSessionResponse>;
|
|
29
29
|
setAvatarDebug(enabled: boolean): Promise<any>;
|
|
@@ -9,9 +9,15 @@ export declare class SpeechHandler {
|
|
|
9
9
|
private recordingLive;
|
|
10
10
|
private headerBlob;
|
|
11
11
|
private scriptsLoadedPromise;
|
|
12
|
+
private digitalHumanSpeaking;
|
|
13
|
+
private stream;
|
|
12
14
|
constructor(options: SpeechHandlerOptions);
|
|
15
|
+
stopRecognition(): void;
|
|
16
|
+
pause(): boolean;
|
|
17
|
+
resume(): boolean;
|
|
13
18
|
private loadScript;
|
|
14
19
|
private loadScripts;
|
|
20
|
+
private handleAppMessages;
|
|
15
21
|
private initWebsocket;
|
|
16
22
|
private loadSavedAudioHeaders;
|
|
17
23
|
private initVoiceActivityDetection;
|
package/dist/src/uneeq.d.ts
CHANGED
|
@@ -102,6 +102,16 @@ export declare class Uneeq {
|
|
|
102
102
|
* When successful a corresponding AvatarRequestCompleted should be received.
|
|
103
103
|
*/
|
|
104
104
|
stopSpeaking(): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Pause speech recognition. The users speech will not be processed, or sent off their device.
|
|
107
|
+
* This is the equivilent of muting the users microphone.
|
|
108
|
+
*/
|
|
109
|
+
pauseSpeechRecognition(): boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Resume speech recognition. The users speech will being being processed again.
|
|
112
|
+
* This is the equivilent of unmuting the users microphone.
|
|
113
|
+
*/
|
|
114
|
+
resumeSpeechRecognition(): boolean;
|
|
105
115
|
/**
|
|
106
116
|
* Pauses a live session. Local video and audio will stop being sent and remote avatar video audio will be stopped.
|
|
107
117
|
* On success, SessionPausedMessage will be sent.
|
package/dist/umd/index.js
CHANGED
|
@@ -3900,7 +3900,27 @@ class Uneeq {
|
|
|
3900
3900
|
* When successful a corresponding AvatarRequestCompleted should be received.
|
|
3901
3901
|
*/
|
|
3902
3902
|
stopSpeaking() {
|
|
3903
|
-
return this.api.
|
|
3903
|
+
return this.api.stopSpeaking();
|
|
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;
|
|
3904
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.
|
|
@@ -13240,7 +13260,7 @@ exports.race = race;
|
|
|
13240
13260
|
/***/ ((module) => {
|
|
13241
13261
|
|
|
13242
13262
|
"use strict";
|
|
13243
|
-
module.exports = JSON.parse('{"name":"uneeq-js","version":"2.47.
|
|
13263
|
+
module.exports = JSON.parse('{"name":"uneeq-js","version":"2.47.6","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
13264
|
|
|
13245
13265
|
/***/ }),
|
|
13246
13266
|
/* 242 */
|
|
@@ -13293,7 +13313,7 @@ class API {
|
|
|
13293
13313
|
avatarStopRecording() {
|
|
13294
13314
|
return this.postRequest('/api/v1/avatar/' + this._callId + '/audioCapture/stop');
|
|
13295
13315
|
}
|
|
13296
|
-
|
|
13316
|
+
stopSpeaking() {
|
|
13297
13317
|
return this.postRequest('/api/v1/avatar/' + this._callId + '/stopSpeaking');
|
|
13298
13318
|
}
|
|
13299
13319
|
getAvailableAvatarCount() {
|
|
@@ -51174,11 +51194,44 @@ class SpeechHandler {
|
|
|
51174
51194
|
this.logPrefix = 'UneeQ: Speech Recognition: ';
|
|
51175
51195
|
this.speechBuffer = new ring_buffer_ts_1.RingBuffer(speechBufferLength);
|
|
51176
51196
|
this.recordingLive = false;
|
|
51177
|
-
|
|
51197
|
+
this.digitalHumanSpeaking = false;
|
|
51198
|
+
console.warn(this.logPrefix + 'SPEECH_RECOGNITION input mode is in development, you may experience issues.');
|
|
51178
51199
|
this.options.assetBasePath = this.options.assetBasePath || defaultAssetPath;
|
|
51179
51200
|
this.loadSavedAudioHeaders();
|
|
51180
51201
|
this.loadScripts();
|
|
51181
51202
|
this.initWebsocket(this.options);
|
|
51203
|
+
this.handleAppMessages();
|
|
51204
|
+
}
|
|
51205
|
+
stopRecognition() {
|
|
51206
|
+
if (this.mediaRecorder) {
|
|
51207
|
+
this.mediaRecorder.stop();
|
|
51208
|
+
}
|
|
51209
|
+
if (this.stream) {
|
|
51210
|
+
this.stream.getTracks().forEach((track) => {
|
|
51211
|
+
track.stop();
|
|
51212
|
+
});
|
|
51213
|
+
}
|
|
51214
|
+
if (this.micVad) {
|
|
51215
|
+
this.micVad.pause();
|
|
51216
|
+
}
|
|
51217
|
+
}
|
|
51218
|
+
pause() {
|
|
51219
|
+
if (this.stream && this.micVad) {
|
|
51220
|
+
this.stream.getTracks().forEach((track) => track.enabled = false);
|
|
51221
|
+
this.micVad.pause();
|
|
51222
|
+
return true;
|
|
51223
|
+
}
|
|
51224
|
+
logger_1.logger.warn(this.logPrefix + 'Could not pause speech recognition.');
|
|
51225
|
+
return false;
|
|
51226
|
+
}
|
|
51227
|
+
resume() {
|
|
51228
|
+
if (this.stream && this.micVad) {
|
|
51229
|
+
this.stream.getTracks().forEach((track) => track.enabled = true);
|
|
51230
|
+
this.micVad.start();
|
|
51231
|
+
return true;
|
|
51232
|
+
}
|
|
51233
|
+
logger_1.logger.warn(this.logPrefix + 'Could not resume speech recognition.');
|
|
51234
|
+
return false;
|
|
51182
51235
|
}
|
|
51183
51236
|
loadScript(url) {
|
|
51184
51237
|
return new Promise((resolve) => {
|
|
@@ -51201,6 +51254,22 @@ class SpeechHandler {
|
|
|
51201
51254
|
});
|
|
51202
51255
|
});
|
|
51203
51256
|
}
|
|
51257
|
+
handleAppMessages() {
|
|
51258
|
+
this.options.messages.subscribe((msg) => {
|
|
51259
|
+
switch (msg.uneeqMessageType) {
|
|
51260
|
+
case MessageTypes_1.UneeqMessageType.StartedSpeaking:
|
|
51261
|
+
this.digitalHumanSpeaking = true;
|
|
51262
|
+
break;
|
|
51263
|
+
case MessageTypes_1.UneeqMessageType.FinishedSpeaking:
|
|
51264
|
+
this.digitalHumanSpeaking = false;
|
|
51265
|
+
break;
|
|
51266
|
+
case MessageTypes_1.UneeqMessageType.SessionEnded:
|
|
51267
|
+
this.stopRecognition();
|
|
51268
|
+
break;
|
|
51269
|
+
default:
|
|
51270
|
+
}
|
|
51271
|
+
});
|
|
51272
|
+
}
|
|
51204
51273
|
initWebsocket(options) {
|
|
51205
51274
|
let connectionUrl = options.apiUrl.replace('https://api.', 'wss://speech-recognition-service.');
|
|
51206
51275
|
connectionUrl += '/ws/recognize?session_id=' + options.sessionId;
|
|
@@ -51304,6 +51373,7 @@ class SpeechHandler {
|
|
|
51304
51373
|
initMicrophone() {
|
|
51305
51374
|
navigator.mediaDevices.getUserMedia({ audio: { sampleRate: audioSampleRate, channelCount: audioChannelCount } })
|
|
51306
51375
|
.then((stream) => {
|
|
51376
|
+
this.stream = stream;
|
|
51307
51377
|
this.initVoiceActivityDetection(stream);
|
|
51308
51378
|
this.initMediaRecorder(stream);
|
|
51309
51379
|
})
|
|
@@ -51343,6 +51413,10 @@ class SpeechHandler {
|
|
|
51343
51413
|
if (result.final) {
|
|
51344
51414
|
this.options.api.avatarAsk(result.transcript);
|
|
51345
51415
|
}
|
|
51416
|
+
else if (this.digitalHumanSpeaking) {
|
|
51417
|
+
this.options.api.stopSpeaking();
|
|
51418
|
+
this.digitalHumanSpeaking = false;
|
|
51419
|
+
}
|
|
51346
51420
|
this.options.messages.next(new MessageTypes_1.SpeechTranscriptionMessage(result));
|
|
51347
51421
|
}
|
|
51348
51422
|
}
|
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.6
|
|
12
|
+
* Speech Recognition: added support for pause and resume.
|
|
13
|
+
|
|
14
|
+
#### 2.47.5
|
|
15
|
+
* Speech Recognition mode: Stop the digital human from speaking when an interim speech result is received.
|
|
16
|
+
|
|
11
17
|
#### 2.47.4
|
|
12
18
|
* Fixed a race condition when loading speech recognition assets
|
|
13
19
|
|