@layercode/js-sdk 2.1.3 → 2.1.4
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.
|
@@ -801,6 +801,8 @@ class AudioProcessor extends AudioWorkletProcessor {
|
|
|
801
801
|
constructor() {
|
|
802
802
|
super();
|
|
803
803
|
this.port.onmessage = this.receive.bind(this);
|
|
804
|
+
this.downsampleRatio = 1;
|
|
805
|
+
this.downsampleOffset = 0;
|
|
804
806
|
this.initialize();
|
|
805
807
|
}
|
|
806
808
|
|
|
@@ -808,7 +810,6 @@ class AudioProcessor extends AudioWorkletProcessor {
|
|
|
808
810
|
this.foundAudio = false;
|
|
809
811
|
this.recording = false;
|
|
810
812
|
this.chunks = [];
|
|
811
|
-
this.downsampleRatio = 1;
|
|
812
813
|
this.downsampleOffset = 0;
|
|
813
814
|
}
|
|
814
815
|
|
|
@@ -4017,22 +4018,14 @@ registerProcessor('audio_processor', AudioProcessor);
|
|
|
4017
4018
|
this.stopRecorderAmplitude = undefined;
|
|
4018
4019
|
}
|
|
4019
4020
|
/**
|
|
4020
|
-
* Connects to the Layercode agent and starts the audio conversation
|
|
4021
|
+
* Connects to the Layercode agent using the stored conversation ID and starts the audio conversation
|
|
4021
4022
|
* @async
|
|
4022
4023
|
* @returns {Promise<void>}
|
|
4023
4024
|
*/
|
|
4024
|
-
async connect(
|
|
4025
|
+
async connect() {
|
|
4025
4026
|
if (this.status === 'connecting') {
|
|
4026
4027
|
return;
|
|
4027
4028
|
}
|
|
4028
|
-
if (opts === null || opts === void 0 ? void 0 : opts.newConversation) {
|
|
4029
|
-
this.options.conversationId = null;
|
|
4030
|
-
this.conversationId = null;
|
|
4031
|
-
}
|
|
4032
|
-
else if (opts === null || opts === void 0 ? void 0 : opts.conversationId) {
|
|
4033
|
-
this.options.conversationId = opts.conversationId;
|
|
4034
|
-
this.conversationId = opts.conversationId;
|
|
4035
|
-
}
|
|
4036
4029
|
try {
|
|
4037
4030
|
this._setStatus('connecting');
|
|
4038
4031
|
// Reset turn tracking for clean start
|
|
@@ -4121,7 +4114,7 @@ registerProcessor('audio_processor', AudioProcessor);
|
|
|
4121
4114
|
this.currentTurnId = null;
|
|
4122
4115
|
console.debug('Reset turn tracking state');
|
|
4123
4116
|
}
|
|
4124
|
-
async disconnect(
|
|
4117
|
+
async disconnect() {
|
|
4125
4118
|
if (this.status === 'disconnected') {
|
|
4126
4119
|
return;
|
|
4127
4120
|
}
|
|
@@ -4133,7 +4126,7 @@ registerProcessor('audio_processor', AudioProcessor);
|
|
|
4133
4126
|
this.ws.close();
|
|
4134
4127
|
this.ws = null;
|
|
4135
4128
|
}
|
|
4136
|
-
await this._performDisconnectCleanup(
|
|
4129
|
+
await this._performDisconnectCleanup();
|
|
4137
4130
|
}
|
|
4138
4131
|
/**
|
|
4139
4132
|
* Gets the microphone MediaStream used by this client
|
|
@@ -4280,7 +4273,10 @@ registerProcessor('audio_processor', AudioProcessor);
|
|
|
4280
4273
|
_teardownDeviceListeners() {
|
|
4281
4274
|
this.wavRecorder.listenForDeviceChange(null);
|
|
4282
4275
|
}
|
|
4283
|
-
|
|
4276
|
+
/**
|
|
4277
|
+
* Releases audio resources and listeners after a disconnect
|
|
4278
|
+
*/
|
|
4279
|
+
async _performDisconnectCleanup() {
|
|
4284
4280
|
var _a, _b;
|
|
4285
4281
|
this.deviceId = null;
|
|
4286
4282
|
this.activeDeviceId = null;
|
|
@@ -4300,13 +4296,7 @@ registerProcessor('audio_processor', AudioProcessor);
|
|
|
4300
4296
|
(_b = (_a = this.wavPlayer).stop) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
4301
4297
|
this.wavPlayer.disconnect();
|
|
4302
4298
|
this._resetTurnTracking();
|
|
4303
|
-
|
|
4304
|
-
this.options.conversationId = null;
|
|
4305
|
-
this.conversationId = null;
|
|
4306
|
-
}
|
|
4307
|
-
else {
|
|
4308
|
-
this.options.conversationId = this.conversationId;
|
|
4309
|
-
}
|
|
4299
|
+
this.options.conversationId = this.conversationId;
|
|
4310
4300
|
this.userAudioAmplitude = 0;
|
|
4311
4301
|
this.agentAudioAmplitude = 0;
|
|
4312
4302
|
this._setStatus('disconnected');
|