@hivegpt/hiveai-angular 0.0.430 → 0.0.432
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/bundles/hivegpt-hiveai-angular.umd.js +62 -20
- package/bundles/hivegpt-hiveai-angular.umd.js.map +1 -1
- package/bundles/hivegpt-hiveai-angular.umd.min.js +1 -1
- package/bundles/hivegpt-hiveai-angular.umd.min.js.map +1 -1
- package/esm2015/lib/components/chat-drawer/chat-drawer.component.js +3 -3
- package/esm2015/lib/components/voice-agent/services/daily-voice-client.service.js +47 -5
- package/fesm2015/hivegpt-hiveai-angular.js +48 -6
- package/fesm2015/hivegpt-hiveai-angular.js.map +1 -1
- package/hivegpt-hiveai-angular.metadata.json +1 -1
- package/lib/components/voice-agent/services/daily-voice-client.service.d.ts +8 -0
- package/lib/components/voice-agent/services/daily-voice-client.service.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1271,6 +1271,8 @@
|
|
|
1271
1271
|
this.callObject = null;
|
|
1272
1272
|
this.localStream = null;
|
|
1273
1273
|
this.localSessionId = null;
|
|
1274
|
+
/** Explicit playback of remote (bot) audio; required in some browsers. */
|
|
1275
|
+
this.remoteAudioElement = null;
|
|
1274
1276
|
this.speakingSubject = new rxjs.BehaviorSubject(false);
|
|
1275
1277
|
this.userSpeakingSubject = new rxjs.BehaviorSubject(false);
|
|
1276
1278
|
this.micMutedSubject = new rxjs.BehaviorSubject(false);
|
|
@@ -1292,19 +1294,19 @@
|
|
|
1292
1294
|
DailyVoiceClientService.prototype.connect = function (roomUrl, token) {
|
|
1293
1295
|
return __awaiter(this, void 0, void 0, function () {
|
|
1294
1296
|
var stream, audioTrack, callObject, joinOptions, participants, err_1;
|
|
1295
|
-
return __generator(this, function (
|
|
1296
|
-
switch (
|
|
1297
|
+
return __generator(this, function (_e) {
|
|
1298
|
+
switch (_e.label) {
|
|
1297
1299
|
case 0:
|
|
1298
1300
|
if (!this.callObject) return [3 /*break*/, 2];
|
|
1299
1301
|
return [4 /*yield*/, this.disconnect()];
|
|
1300
1302
|
case 1:
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
+
_e.sent();
|
|
1304
|
+
_e.label = 2;
|
|
1303
1305
|
case 2:
|
|
1304
|
-
|
|
1306
|
+
_e.trys.push([2, 5, , 6]);
|
|
1305
1307
|
return [4 /*yield*/, navigator.mediaDevices.getUserMedia({ audio: true })];
|
|
1306
1308
|
case 3:
|
|
1307
|
-
stream =
|
|
1309
|
+
stream = _e.sent();
|
|
1308
1310
|
audioTrack = stream.getAudioTracks()[0];
|
|
1309
1311
|
if (!audioTrack) {
|
|
1310
1312
|
stream.getTracks().forEach(function (t) { return t.stop(); });
|
|
@@ -1324,7 +1326,7 @@
|
|
|
1324
1326
|
}
|
|
1325
1327
|
return [4 /*yield*/, callObject.join(joinOptions)];
|
|
1326
1328
|
case 4:
|
|
1327
|
-
|
|
1329
|
+
_e.sent();
|
|
1328
1330
|
participants = callObject.participants();
|
|
1329
1331
|
if (participants === null || participants === void 0 ? void 0 : participants.local) {
|
|
1330
1332
|
this.localSessionId = participants.local.session_id;
|
|
@@ -1333,7 +1335,7 @@
|
|
|
1333
1335
|
this.micMutedSubject.next(!callObject.localAudio());
|
|
1334
1336
|
return [3 /*break*/, 6];
|
|
1335
1337
|
case 5:
|
|
1336
|
-
err_1 =
|
|
1338
|
+
err_1 = _e.sent();
|
|
1337
1339
|
this.cleanup();
|
|
1338
1340
|
throw err_1;
|
|
1339
1341
|
case 6: return [2 /*return*/];
|
|
@@ -1359,16 +1361,21 @@
|
|
|
1359
1361
|
_this.speakingSubject.next(!isLocal);
|
|
1360
1362
|
});
|
|
1361
1363
|
});
|
|
1362
|
-
// track-started / track-stopped:
|
|
1363
|
-
// remote
|
|
1364
|
-
//
|
|
1364
|
+
// track-started / track-stopped: play remote (bot) audio explicitly and update speaking state.
|
|
1365
|
+
// Browsers often do not auto-play remote WebRTC audio; attaching to an HTMLAudioElement and
|
|
1366
|
+
// calling play() ensures the user hears the agent.
|
|
1365
1367
|
call.on('track-started', function (event) {
|
|
1366
1368
|
_this.ngZone.run(function () {
|
|
1367
|
-
var _a, _b;
|
|
1369
|
+
var _a, _b, _c, _d;
|
|
1368
1370
|
var p = event === null || event === void 0 ? void 0 : event.participant;
|
|
1369
1371
|
var type = (_a = event === null || event === void 0 ? void 0 : event.type) !== null && _a !== void 0 ? _a : (_b = event === null || event === void 0 ? void 0 : event.track) === null || _b === void 0 ? void 0 : _b.kind;
|
|
1372
|
+
var track = event === null || event === void 0 ? void 0 : event.track;
|
|
1370
1373
|
if (p && !p.local && type === 'audio') {
|
|
1371
1374
|
_this.speakingSubject.next(true);
|
|
1375
|
+
var audioTrack = track !== null && track !== void 0 ? track : (_d = (_c = p.tracks) === null || _c === void 0 ? void 0 : _c.audio) === null || _d === void 0 ? void 0 : _d.track;
|
|
1376
|
+
if (audioTrack && typeof audioTrack === 'object') {
|
|
1377
|
+
_this.playRemoteTrack(audioTrack);
|
|
1378
|
+
}
|
|
1372
1379
|
}
|
|
1373
1380
|
});
|
|
1374
1381
|
});
|
|
@@ -1379,6 +1386,7 @@
|
|
|
1379
1386
|
var type = (_a = event === null || event === void 0 ? void 0 : event.type) !== null && _a !== void 0 ? _a : (_b = event === null || event === void 0 ? void 0 : event.track) === null || _b === void 0 ? void 0 : _b.kind;
|
|
1380
1387
|
if (p && !p.local && type === 'audio') {
|
|
1381
1388
|
_this.speakingSubject.next(false);
|
|
1389
|
+
_this.stopRemoteAudio();
|
|
1382
1390
|
}
|
|
1383
1391
|
});
|
|
1384
1392
|
});
|
|
@@ -1393,6 +1401,39 @@
|
|
|
1393
1401
|
});
|
|
1394
1402
|
});
|
|
1395
1403
|
};
|
|
1404
|
+
/**
|
|
1405
|
+
* Play remote (bot) audio track via a dedicated audio element.
|
|
1406
|
+
* Required in many browsers where Daily's internal playback does not output to speakers.
|
|
1407
|
+
*/
|
|
1408
|
+
DailyVoiceClientService.prototype.playRemoteTrack = function (track) {
|
|
1409
|
+
this.stopRemoteAudio();
|
|
1410
|
+
try {
|
|
1411
|
+
var stream = new MediaStream([track]);
|
|
1412
|
+
var audio = new Audio();
|
|
1413
|
+
audio.autoplay = true;
|
|
1414
|
+
audio.srcObject = stream;
|
|
1415
|
+
this.remoteAudioElement = audio;
|
|
1416
|
+
var p = audio.play();
|
|
1417
|
+
if (p && typeof p.catch === 'function') {
|
|
1418
|
+
p.catch(function (err) {
|
|
1419
|
+
console.warn('DailyVoiceClient: remote audio play failed (may need user gesture)', err);
|
|
1420
|
+
});
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
catch (err) {
|
|
1424
|
+
console.warn('DailyVoiceClient: failed to create remote audio element', err);
|
|
1425
|
+
}
|
|
1426
|
+
};
|
|
1427
|
+
DailyVoiceClientService.prototype.stopRemoteAudio = function () {
|
|
1428
|
+
if (this.remoteAudioElement) {
|
|
1429
|
+
try {
|
|
1430
|
+
this.remoteAudioElement.pause();
|
|
1431
|
+
this.remoteAudioElement.srcObject = null;
|
|
1432
|
+
}
|
|
1433
|
+
catch (_) { }
|
|
1434
|
+
this.remoteAudioElement = null;
|
|
1435
|
+
}
|
|
1436
|
+
};
|
|
1396
1437
|
/** Set mic muted state. */
|
|
1397
1438
|
DailyVoiceClientService.prototype.setMuted = function (muted) {
|
|
1398
1439
|
if (!this.callObject)
|
|
@@ -1404,22 +1445,22 @@
|
|
|
1404
1445
|
DailyVoiceClientService.prototype.disconnect = function () {
|
|
1405
1446
|
return __awaiter(this, void 0, void 0, function () {
|
|
1406
1447
|
var e_1;
|
|
1407
|
-
return __generator(this, function (
|
|
1408
|
-
switch (
|
|
1448
|
+
return __generator(this, function (_e) {
|
|
1449
|
+
switch (_e.label) {
|
|
1409
1450
|
case 0:
|
|
1410
1451
|
if (!this.callObject) {
|
|
1411
1452
|
this.cleanup();
|
|
1412
1453
|
return [2 /*return*/];
|
|
1413
1454
|
}
|
|
1414
|
-
|
|
1455
|
+
_e.label = 1;
|
|
1415
1456
|
case 1:
|
|
1416
|
-
|
|
1457
|
+
_e.trys.push([1, 3, , 4]);
|
|
1417
1458
|
return [4 /*yield*/, this.callObject.leave()];
|
|
1418
1459
|
case 2:
|
|
1419
|
-
|
|
1460
|
+
_e.sent();
|
|
1420
1461
|
return [3 /*break*/, 4];
|
|
1421
1462
|
case 3:
|
|
1422
|
-
e_1 =
|
|
1463
|
+
e_1 = _e.sent();
|
|
1423
1464
|
return [3 /*break*/, 4];
|
|
1424
1465
|
case 4:
|
|
1425
1466
|
this.cleanup();
|
|
@@ -1429,6 +1470,7 @@
|
|
|
1429
1470
|
});
|
|
1430
1471
|
};
|
|
1431
1472
|
DailyVoiceClientService.prototype.cleanup = function () {
|
|
1473
|
+
this.stopRemoteAudio();
|
|
1432
1474
|
if (this.callObject) {
|
|
1433
1475
|
this.callObject.destroy().catch(function () { });
|
|
1434
1476
|
this.callObject = null;
|
|
@@ -3422,7 +3464,7 @@
|
|
|
3422
3464
|
ChatDrawerComponent.prototype.makeAskRequest = function (inputMsg, agents, conversationId, msg, chat, workflowId, workflow_inputs) {
|
|
3423
3465
|
var _this = this;
|
|
3424
3466
|
var _a;
|
|
3425
|
-
var url =
|
|
3467
|
+
var url = "https://48c6-2405-201-5c02-991e-d91c-8adf-399c-abdc.ngrok-free.app/ai/ask";
|
|
3426
3468
|
var body = {
|
|
3427
3469
|
user_question: inputMsg,
|
|
3428
3470
|
user_id: this.userId,
|
|
@@ -3489,7 +3531,7 @@
|
|
|
3489
3531
|
ChatDrawerComponent.prototype.makeAskRequestold = function (inputMsg, agents, conversationId, msg, chat, workflowId, workflow_inputs) {
|
|
3490
3532
|
var _this = this;
|
|
3491
3533
|
var _a;
|
|
3492
|
-
var url =
|
|
3534
|
+
var url = "https://48c6-2405-201-5c02-991e-d91c-8adf-399c-abdc.ngrok-free.app/ai/ask";
|
|
3493
3535
|
var body = {
|
|
3494
3536
|
user_question: inputMsg,
|
|
3495
3537
|
user_id: this.userId,
|