@frequencytalk/agent 0.1.1 → 0.1.2

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/README.md CHANGED
@@ -37,7 +37,8 @@ const { frequency } = await agent.frequencies.tuneByNumber(118025);
37
37
  const session = await agent.session(frequency!.id);
38
38
  await agent.speaker(session).speakWav("hello.wav");
39
39
 
40
- // Hear the reply for ten seconds. Receiving is off until you listen to a channel.
40
+ // Hear the reply for ten seconds. Receiving is off until you listen to a channel. Your own
41
+ // stream is not recorded (pass { includeOwn: true } to the listener if you want it).
41
42
  for (const c of await agent.frequencies.channels(frequency!.id)) session.listen(c.id);
42
43
  const listener = agent.listener(session);
43
44
  await listener.start();
package/dist/cli.js CHANGED
@@ -5115,18 +5115,21 @@ var Speaker = class {
5115
5115
 
5116
5116
  // src/listener.ts
5117
5117
  var Listener = class {
5118
- constructor(session) {
5118
+ constructor(session, options = {}) {
5119
5119
  this.session = session;
5120
+ this.options = options;
5120
5121
  }
5121
5122
  session;
5123
+ options;
5122
5124
  codec = null;
5123
5125
  streams = /* @__PURE__ */ new Map();
5124
5126
  detach = null;
5125
- /** Start recording everything the session hears. */
5127
+ /** Start recording everything the session hears (its own stream excepted, see `ListenerOptions`). */
5126
5128
  async start() {
5127
5129
  this.codec ??= await createOpus();
5128
5130
  const codec = this.codec;
5129
5131
  const handler = (frame) => {
5132
+ if (!this.options.includeOwn && frame.connectionId === this.session.connectionId) return;
5130
5133
  let s = this.streams.get(frame.streamId);
5131
5134
  if (!s) {
5132
5135
  s = { connectionId: frame.connectionId, chunks: [], lastTimestamp: null, first: frame.timestamp };
@@ -5221,8 +5224,8 @@ var Agent = class _Agent {
5221
5224
  speaker(session) {
5222
5225
  return new Speaker(session);
5223
5226
  }
5224
- listener(session) {
5225
- return new Listener(session);
5227
+ listener(session, options) {
5228
+ return new Listener(session, options);
5226
5229
  }
5227
5230
  async close() {
5228
5231
  for (const id of [...this.sessions.keys()]) await this.closeSession(id);