@furious.luke/argus-js 0.5.6 → 0.5.7

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.cts CHANGED
@@ -79,6 +79,11 @@ type SignalMessage = {
79
79
  track: TrackType;
80
80
  track_id?: string;
81
81
  reason?: string;
82
+ } | {
83
+ type: "speech_slow";
84
+ realtime_factor: number;
85
+ } | {
86
+ type: "speech_recovered";
82
87
  } | {
83
88
  type: "recovery_event";
84
89
  event: "recovery_started" | "recovery_retry" | "recovery_failed";
@@ -131,6 +136,19 @@ interface PublisherCallbacks {
131
136
  onUserTextResult?: (event: UserTextResultEvent) => void;
132
137
  /** Called once the explicitly requested outbound speech track arrives. */
133
138
  onSpeechTrack?: (track: MediaStreamTrack, streams: readonly MediaStream[]) => void;
139
+ /**
140
+ * Called when server-side text-to-speech generation crosses the realtime
141
+ * boundary: `degraded: true` when the TTS provider drops below realtime
142
+ * (`realtimeFactor` < 1.0), synthesizing audio slower than it plays and starving
143
+ * playout regardless of the network, and `degraded: false` when a later utterance
144
+ * climbs comfortably back above realtime. The degraded transition is raised live
145
+ * during synthesis — a long, slow utterance is reported while it is happening, not
146
+ * once it finishes. Edge-triggered — fires only on the transition, not per
147
+ * utterance, and a factor hovering at the boundary does not flap it. This is a
148
+ * distinct axis from {@link onConnectionQualityChange} (which is network health);
149
+ * react by, e.g., warning the user or offering a text fallback.
150
+ */
151
+ onSpeechQualityChange?: (event: SpeechQualityEvent) => void;
134
152
  /**
135
153
  * Called for every periodic connection-stats sample while connected — the raw
136
154
  * feed behind {@link onConnectionQualityChange}. Fires at
@@ -157,6 +175,17 @@ interface UserTextResultEvent {
157
175
  accepted: boolean;
158
176
  reason?: string;
159
177
  }
178
+ /**
179
+ * A change in server-side text-to-speech generation health, delivered to
180
+ * {@link PublisherCallbacks.onSpeechQualityChange}. `degraded` is `true` on the
181
+ * transition into below-realtime synthesis (`realtimeFactor` < 1.0) and `false`
182
+ * once synthesis climbs comfortably back above realtime. `realtimeFactor` (audio
183
+ * produced ÷ wall-clock to produce it) accompanies a degraded transition.
184
+ */
185
+ interface SpeechQualityEvent {
186
+ degraded: boolean;
187
+ realtimeFactor?: number;
188
+ }
160
189
  /**
161
190
  * A coarse assessment of the uplink to the media server, derived from periodic
162
191
  * WebRTC stats. Ordered worst-last by severity: `"good"` is a healthy
@@ -811,4 +840,4 @@ interface CaptureMicrophoneOptions {
811
840
  */
812
841
  declare function captureMicrophone(opts?: CaptureMicrophoneOptions): Promise<MediaStream>;
813
842
 
814
- export { type AssistantTextEvent, type CaptureCameraOptions, type CaptureMicrophoneOptions, type CaptureScreenOptions, type ConnectionQuality, type ConnectionQualityLevel, type ConnectionQualityThresholds, type ConnectionStatsSample, type GatewayReadyInfo, Publisher, type PublisherCallbacks, type PublisherOptions, type PublisherRecoveryAction, type PublisherRecoveryEvent, type PublisherRecoveryFailureReason, type PublisherRecoveryState, type SignalMessage, type TrackLabel, type TrackType, type TurnTransportPolicy, type UserTextResultEvent, type VideoTrackType, captureCamera, captureMicrophone, captureScreen };
843
+ export { type AssistantTextEvent, type CaptureCameraOptions, type CaptureMicrophoneOptions, type CaptureScreenOptions, type ConnectionQuality, type ConnectionQualityLevel, type ConnectionQualityThresholds, type ConnectionStatsSample, type GatewayReadyInfo, Publisher, type PublisherCallbacks, type PublisherOptions, type PublisherRecoveryAction, type PublisherRecoveryEvent, type PublisherRecoveryFailureReason, type PublisherRecoveryState, type SignalMessage, type SpeechQualityEvent, type TrackLabel, type TrackType, type TurnTransportPolicy, type UserTextResultEvent, type VideoTrackType, captureCamera, captureMicrophone, captureScreen };
package/dist/index.d.ts CHANGED
@@ -79,6 +79,11 @@ type SignalMessage = {
79
79
  track: TrackType;
80
80
  track_id?: string;
81
81
  reason?: string;
82
+ } | {
83
+ type: "speech_slow";
84
+ realtime_factor: number;
85
+ } | {
86
+ type: "speech_recovered";
82
87
  } | {
83
88
  type: "recovery_event";
84
89
  event: "recovery_started" | "recovery_retry" | "recovery_failed";
@@ -131,6 +136,19 @@ interface PublisherCallbacks {
131
136
  onUserTextResult?: (event: UserTextResultEvent) => void;
132
137
  /** Called once the explicitly requested outbound speech track arrives. */
133
138
  onSpeechTrack?: (track: MediaStreamTrack, streams: readonly MediaStream[]) => void;
139
+ /**
140
+ * Called when server-side text-to-speech generation crosses the realtime
141
+ * boundary: `degraded: true` when the TTS provider drops below realtime
142
+ * (`realtimeFactor` < 1.0), synthesizing audio slower than it plays and starving
143
+ * playout regardless of the network, and `degraded: false` when a later utterance
144
+ * climbs comfortably back above realtime. The degraded transition is raised live
145
+ * during synthesis — a long, slow utterance is reported while it is happening, not
146
+ * once it finishes. Edge-triggered — fires only on the transition, not per
147
+ * utterance, and a factor hovering at the boundary does not flap it. This is a
148
+ * distinct axis from {@link onConnectionQualityChange} (which is network health);
149
+ * react by, e.g., warning the user or offering a text fallback.
150
+ */
151
+ onSpeechQualityChange?: (event: SpeechQualityEvent) => void;
134
152
  /**
135
153
  * Called for every periodic connection-stats sample while connected — the raw
136
154
  * feed behind {@link onConnectionQualityChange}. Fires at
@@ -157,6 +175,17 @@ interface UserTextResultEvent {
157
175
  accepted: boolean;
158
176
  reason?: string;
159
177
  }
178
+ /**
179
+ * A change in server-side text-to-speech generation health, delivered to
180
+ * {@link PublisherCallbacks.onSpeechQualityChange}. `degraded` is `true` on the
181
+ * transition into below-realtime synthesis (`realtimeFactor` < 1.0) and `false`
182
+ * once synthesis climbs comfortably back above realtime. `realtimeFactor` (audio
183
+ * produced ÷ wall-clock to produce it) accompanies a degraded transition.
184
+ */
185
+ interface SpeechQualityEvent {
186
+ degraded: boolean;
187
+ realtimeFactor?: number;
188
+ }
160
189
  /**
161
190
  * A coarse assessment of the uplink to the media server, derived from periodic
162
191
  * WebRTC stats. Ordered worst-last by severity: `"good"` is a healthy
@@ -811,4 +840,4 @@ interface CaptureMicrophoneOptions {
811
840
  */
812
841
  declare function captureMicrophone(opts?: CaptureMicrophoneOptions): Promise<MediaStream>;
813
842
 
814
- export { type AssistantTextEvent, type CaptureCameraOptions, type CaptureMicrophoneOptions, type CaptureScreenOptions, type ConnectionQuality, type ConnectionQualityLevel, type ConnectionQualityThresholds, type ConnectionStatsSample, type GatewayReadyInfo, Publisher, type PublisherCallbacks, type PublisherOptions, type PublisherRecoveryAction, type PublisherRecoveryEvent, type PublisherRecoveryFailureReason, type PublisherRecoveryState, type SignalMessage, type TrackLabel, type TrackType, type TurnTransportPolicy, type UserTextResultEvent, type VideoTrackType, captureCamera, captureMicrophone, captureScreen };
843
+ export { type AssistantTextEvent, type CaptureCameraOptions, type CaptureMicrophoneOptions, type CaptureScreenOptions, type ConnectionQuality, type ConnectionQualityLevel, type ConnectionQualityThresholds, type ConnectionStatsSample, type GatewayReadyInfo, Publisher, type PublisherCallbacks, type PublisherOptions, type PublisherRecoveryAction, type PublisherRecoveryEvent, type PublisherRecoveryFailureReason, type PublisherRecoveryState, type SignalMessage, type SpeechQualityEvent, type TrackLabel, type TrackType, type TurnTransportPolicy, type UserTextResultEvent, type VideoTrackType, captureCamera, captureMicrophone, captureScreen };
package/dist/index.js CHANGED
@@ -1092,6 +1092,17 @@ var Publisher = class {
1092
1092
  this.completeMediaRecovery(msg.track);
1093
1093
  break;
1094
1094
  }
1095
+ case "speech_slow": {
1096
+ this.opts.callbacks?.onSpeechQualityChange?.({
1097
+ degraded: true,
1098
+ realtimeFactor: msg.realtime_factor
1099
+ });
1100
+ break;
1101
+ }
1102
+ case "speech_recovered": {
1103
+ this.opts.callbacks?.onSpeechQualityChange?.({ degraded: false });
1104
+ break;
1105
+ }
1095
1106
  case "error": {
1096
1107
  const err = new ReportedPublisherError(msg.error, msg.fatal === true);
1097
1108
  const pending = this.pendingAnswer;