@unith-ai/core-client 2.0.62 → 2.0.63

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.ts CHANGED
@@ -310,6 +310,7 @@ export type ConversationEvents = {
310
310
  type: "toast" | "modal" | "silent";
311
311
  }) => void;
312
312
  onHighDemand: () => void;
313
+ onSpeechRecognitionToken: (token: string) => void;
313
314
  };
314
315
  export type ConversationMode = "chat" | "audio" | "video" | "default";
315
316
  export type Role = "user" | "ai";
@@ -511,6 +512,11 @@ export declare class Conversation {
511
512
  stopResponse(): Promise<void>;
512
513
  toggleMute(): Promise<number>;
513
514
  startSession(): Promise<Connection>;
515
+ /**
516
+ * Returns token for speech recognition.
517
+ * @param provider
518
+ */
519
+ private getSpeechRecognitionToken;
514
520
  toggleMicrophone(): Promise<void>;
515
521
  getMicrophoneStatus(): MicrophoneStatus;
516
522
  endSession(): Promise<void>;
package/dist/lib.js CHANGED
@@ -23784,6 +23784,7 @@ var Conversation = class Conversation {
23784
23784
  onKeepSession: () => {},
23785
23785
  onError: () => {},
23786
23786
  onHighDemand: () => {},
23787
+ onSpeechRecognitionToken: () => {},
23787
23788
  ...partialOptions
23788
23789
  };
23789
23790
  }
@@ -24175,8 +24176,19 @@ var Conversation = class Conversation {
24175
24176
  this.handleMessage(lastResponse.textEventData);
24176
24177
  }
24177
24178
  if (this.options.microphoneProvider !== "custom") this.microphone = await Microphone.initializeMicrophone(this.options.microphoneOptions, this.options.microphoneProvider, this.options.elevenLabsOptions ?? defaultElevenLabsOptions, this.user, this.headInfo, this.microphoneAccess, this.options.voiceInterruptions ?? false);
24179
+ else {
24180
+ const token = await this.getSpeechRecognitionToken("eleven_labs");
24181
+ this.options.onSpeechRecognitionToken(token);
24182
+ }
24178
24183
  return this.connection;
24179
24184
  }
24185
+ /**
24186
+ * Returns token for speech recognition.
24187
+ * @param provider
24188
+ */
24189
+ async getSpeechRecognitionToken(provider) {
24190
+ return (await this.user.getAsrToken(provider === "eleven_labs" ? "elevenlabs" : "azure")).token;
24191
+ }
24180
24192
  async toggleMicrophone() {
24181
24193
  if (this.options.microphoneProvider === "custom") throw new Error("Cannot toggle microphone for custom provider.");
24182
24194
  if (!this.microphone) this.microphone = await Microphone.initializeMicrophone(this.options.microphoneOptions, this.options.microphoneProvider, this.options.elevenLabsOptions ?? defaultElevenLabsOptions, this.user, this.headInfo, this.microphoneAccess, this.options.voiceInterruptions ?? false);