@dtelecom/agents-js 0.1.6 → 0.1.8

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.d.mts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as _dtelecom_server_sdk_node from '@dtelecom/server-sdk-node';
2
2
  import { Room, AudioSource, RemoteAudioTrack, AudioFrame } from '@dtelecom/server-sdk-node';
3
3
  import { EventEmitter } from 'events';
4
- import { A as AgentConfig, a as AgentStartOptions, M as Message, L as LLMPlugin, P as PipelineOptions, b as AgentState, S as STTStream, T as TranscriptionResult } from './types-Bfz5YQwd.mjs';
5
- export { c as AgentEvents, d as AudioOutput, D as DataMessageHandler, e as LLMChunk, f as MemoryConfig, g as PipelineEvents, R as RespondMode, h as STTPlugin, i as STTStreamOptions, j as TTSPlugin } from './types-Bfz5YQwd.mjs';
4
+ import { A as AgentConfig, a as AgentStartOptions, M as Message, L as LLMPlugin, P as PipelineOptions, b as AgentState, S as STTStream, T as TranscriptionResult } from './types-f6SAlHpW.mjs';
5
+ export { c as AgentEvents, d as AudioOutput, D as DataMessageHandler, e as LLMChunk, f as MemoryConfig, g as PipelineEvents, R as RespondMode, h as STTPlugin, i as STTStreamOptions, j as TTSPlugin } from './types-f6SAlHpW.mjs';
6
6
 
7
7
  declare class VoiceAgent extends EventEmitter {
8
8
  private readonly config;
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as _dtelecom_server_sdk_node from '@dtelecom/server-sdk-node';
2
2
  import { Room, AudioSource, RemoteAudioTrack, AudioFrame } from '@dtelecom/server-sdk-node';
3
3
  import { EventEmitter } from 'events';
4
- import { A as AgentConfig, a as AgentStartOptions, M as Message, L as LLMPlugin, P as PipelineOptions, b as AgentState, S as STTStream, T as TranscriptionResult } from './types-Bfz5YQwd.js';
5
- export { c as AgentEvents, d as AudioOutput, D as DataMessageHandler, e as LLMChunk, f as MemoryConfig, g as PipelineEvents, R as RespondMode, h as STTPlugin, i as STTStreamOptions, j as TTSPlugin } from './types-Bfz5YQwd.js';
4
+ import { A as AgentConfig, a as AgentStartOptions, M as Message, L as LLMPlugin, P as PipelineOptions, b as AgentState, S as STTStream, T as TranscriptionResult } from './types-f6SAlHpW.js';
5
+ export { c as AgentEvents, d as AudioOutput, D as DataMessageHandler, e as LLMChunk, f as MemoryConfig, g as PipelineEvents, R as RespondMode, h as STTPlugin, i as STTStreamOptions, j as TTSPlugin } from './types-f6SAlHpW.js';
6
6
 
7
7
  declare class VoiceAgent extends EventEmitter {
8
8
  private readonly config;
package/dist/index.js CHANGED
@@ -1408,12 +1408,16 @@ var Pipeline = class extends import_events.EventEmitter {
1408
1408
  log7.debug(`Skipping non-word sentence: "${sentence}"`);
1409
1409
  continue;
1410
1410
  }
1411
- await this.synthesizeAndPlay(sentence, signal, (t) => {
1411
+ let processed = sentence;
1412
+ if (this.tts?.preprocessText) {
1413
+ processed = await this.tts.preprocessText(sentence, signal);
1414
+ }
1415
+ await this.synthesizeAndPlay(processed, signal, (t) => {
1412
1416
  if (!tFirstAudioPlayed) {
1413
1417
  tFirstAudioPlayed = t;
1414
1418
  this.setAgentState("speaking");
1415
1419
  }
1416
- this.emit("sentence", this.cleanText(sentence));
1420
+ this.emit("sentence", this.cleanText(processed));
1417
1421
  });
1418
1422
  continue;
1419
1423
  }
@@ -1480,15 +1484,19 @@ var Pipeline = class extends import_events.EventEmitter {
1480
1484
  const signal = this.bargeIn.startCycle();
1481
1485
  this.audioOutput.beginResponse();
1482
1486
  this.setAgentState("thinking");
1483
- await this.synthesizeAndPlay(text, signal, () => {
1487
+ let processed = text;
1488
+ if (this.tts?.preprocessText) {
1489
+ processed = await this.tts.preprocessText(text, signal);
1490
+ }
1491
+ await this.synthesizeAndPlay(processed, signal, () => {
1484
1492
  this.setAgentState("speaking");
1485
- this.emit("sentence", this.cleanText(text));
1493
+ this.emit("sentence", this.cleanText(processed));
1486
1494
  });
1487
1495
  if (!signal.aborted) {
1488
1496
  await this.audioOutput.writeSilence(40);
1489
1497
  this.context.addAgentTurn(text);
1490
1498
  this.memory?.storeTurn("assistant", text, true);
1491
- this.emit("response", this.cleanText(text));
1499
+ this.emit("response", this.cleanText(processed));
1492
1500
  }
1493
1501
  await sleep2(AUDIO_DRAIN_MS);
1494
1502
  this.setAgentState("idle");