playkit-sdk 1.3.0 → 1.4.0-beta.1

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.
@@ -413,6 +413,8 @@ interface SDKConfig {
413
413
  defaultImageModel?: string;
414
414
  /** Default transcription model to use */
415
415
  defaultTranscriptionModel?: string;
416
+ /** Default text-to-speech model to use */
417
+ defaultTTSModel?: string;
416
418
  /**
417
419
  * Enable debug logging
418
420
  * @deprecated Use `logging.level` instead. Will be removed in v2.0.
@@ -876,6 +878,85 @@ interface TranscriptionResponse {
876
878
  segments?: TranscriptionSegment[];
877
879
  }
878
880
 
881
+ /**
882
+ * Text-to-speech (TTS) type definitions
883
+ */
884
+ /**
885
+ * Configuration for text-to-speech requests
886
+ */
887
+ interface TTSConfig {
888
+ /**
889
+ * Text to synthesize into speech (max 10000 characters)
890
+ */
891
+ text: string;
892
+ /**
893
+ * Model to use for synthesis
894
+ * Defaults to 'default-tts-model' (alias resolved by the backend)
895
+ */
896
+ model?: string;
897
+ /**
898
+ * Voice id to use (e.g., 'male-qn-qingse')
899
+ */
900
+ voice?: string;
901
+ /**
902
+ * Playback speed multiplier
903
+ */
904
+ speed?: number;
905
+ /**
906
+ * Volume
907
+ */
908
+ vol?: number;
909
+ /**
910
+ * Pitch adjustment
911
+ */
912
+ pitch?: number;
913
+ /**
914
+ * Emotion of the speech (e.g., 'happy', 'sad')
915
+ */
916
+ emotion?: string;
917
+ /**
918
+ * Output audio format (e.g., 'mp3', 'wav')
919
+ */
920
+ format?: string;
921
+ /**
922
+ * Language boost hint to improve pronunciation for a specific language
923
+ */
924
+ languageBoost?: string;
925
+ /**
926
+ * Passthrough voice settings object for advanced configuration
927
+ */
928
+ voiceSetting?: Record<string, unknown>;
929
+ /**
930
+ * Passthrough audio settings object for advanced configuration
931
+ */
932
+ audioSetting?: Record<string, unknown>;
933
+ }
934
+ /**
935
+ * Options for simplified text-to-speech methods (everything except the text)
936
+ */
937
+ type TTSOptions = Omit<TTSConfig, 'text'>;
938
+ /**
939
+ * Result of a text-to-speech request
940
+ */
941
+ interface TTSResult {
942
+ /**
943
+ * Raw audio bytes
944
+ */
945
+ audio: ArrayBuffer;
946
+ /**
947
+ * Audio format / content type (e.g., 'audio/mpeg' or 'mp3')
948
+ */
949
+ format: string;
950
+ /**
951
+ * Number of characters billed for this request
952
+ */
953
+ usageCharacters: number;
954
+ /**
955
+ * Length of the generated audio in milliseconds (if reported)
956
+ */
957
+ audioLengthMs?: number;
958
+ }
959
+
879
960
  /**
880
961
  * Device Authorization Flow Manager
881
962
  * Manages Device Auth polling flow for desktop/CLI/Unity applications
@@ -1911,6 +1992,59 @@ declare class TranscriptionClient {
1911
1992
  transcribeFile(file: File, options?: TranscriptionOptions): Promise<TranscriptionResult>;
1912
1993
  }
1913
1994
 
1995
+ /**
1996
+ * TTS provider for HTTP communication with the text-to-speech API
1997
+ */
1998
+
1999
+ declare class TTSProvider {
2000
+ private authManager;
2001
+ private config;
2002
+ private baseURL;
2003
+ private playerClient?;
2004
+ constructor(authManager: AuthManager, config: SDKConfig);
2005
+ /**
2006
+ * Set player client for balance checking
2007
+ */
2008
+ setPlayerClient(playerClient: PlayerClient): void;
2009
+ /**
2010
+ * Synthesize text into speech audio
2011
+ */
2012
+ synthesize(ttsConfig: TTSConfig): Promise<TTSResult>;
2013
+ }
2014
+
2015
+ /**
2016
+ * High-level client for text-to-speech synthesis
2017
+ */
2018
+
2019
+ declare class TTSClient {
2020
+ private provider;
2021
+ private model;
2022
+ constructor(provider: TTSProvider, model?: string);
2023
+ /**
2024
+ * Get the current model name
2025
+ */
2026
+ get modelName(): string;
2027
+ /**
2028
+ * Synthesize text into speech audio
2029
+ * @param config - Full TTS configuration
2030
+ * @returns TTS result containing raw audio bytes and usage metadata
2031
+ */
2032
+ synthesize(config: TTSConfig): Promise<TTSResult>;
2033
+ /**
2034
+ * Synthesize text into speech and return it as a Blob (browser-friendly)
2035
+ * @param config - Full TTS configuration
2036
+ * @returns Audio Blob with the appropriate MIME type
2037
+ */
2038
+ synthesizeToBlob(config: TTSConfig): Promise<Blob>;
2039
+ /**
2040
+ * Synthesize text into speech and return an object URL (browser only)
2041
+ * @param config - Full TTS configuration
2042
+ * @returns An object URL that can be assigned to an <audio> element
2043
+ * @throws PlayKitError if URL.createObjectURL is unavailable (e.g. Node.js)
2044
+ */
2045
+ synthesizeToObjectURL(config: TTSConfig): Promise<string>;
2046
+ }
2047
+
1914
2048
  /**
1915
2049
  * NPC Client for simplified conversation management
1916
2050
  * Automatically handles conversation history
@@ -2359,6 +2493,7 @@ declare class PlayKitSDK extends EventEmitter {
2359
2493
  private chatProvider;
2360
2494
  private imageProvider;
2361
2495
  private transcriptionProvider;
2496
+ private ttsProvider;
2362
2497
  private contextManager;
2363
2498
  private schemaLibrary;
2364
2499
  private initialized;
@@ -2428,6 +2563,11 @@ declare class PlayKitSDK extends EventEmitter {
2428
2563
  * @param model - Transcription model to use (default: 'whisper-large')
2429
2564
  */
2430
2565
  createTranscriptionClient(model?: string): TranscriptionClient;
2566
+ /**
2567
+ * Create a TTS client for text-to-speech
2568
+ * @param model - TTS model to use (default: 'default-tts-model')
2569
+ */
2570
+ createTTSClient(model?: string): TTSClient;
2431
2571
  /**
2432
2572
  * Create an NPC client
2433
2573
  * Automatically registers with AIContextManager
@@ -2957,5 +3097,5 @@ declare global {
2957
3097
  }
2958
3098
  }
2959
3099
 
2960
- export { AIContextManager, AuthFlowManager, AuthManager, BrowserStorage, BufferLogHandler, CallbackLogHandler, ChatClient, DeviceAuthFlowManager, ImageClient, LogLevel, Logger, MemoryStorage, NPCClient, PlayKitError, PlayKitSDK, PlayerClient, RechargeManager, SchemaLibrary, StreamParser, TokenStorage, TokenValidator, TranscriptionClient, createMultimodalMessage, createStorage, createTextMessage, PlayKitSDK as default, defaultContextManager, defaultSchemaLibrary, defaultTokenValidator, isLocalStorageAvailable };
2961
- export type { AIContextManagerConfig, AIContextManagerEvents, APIResult, AudioContentPart, AuthState, ChatCompletionResponse, ChatConfig, ChatResult, ChatStreamConfig, ChatWithToolsConfig, ChatWithToolsStreamConfig, ConversationSaveData, DeveloperTokenFallbackConfig, DeviceAuthFlowOptions, DeviceAuthInitResult, DeviceAuthResult, GameInfo, GeneratedImage, IStorage, ImageContentPart, ImageGenerationConfig, ImageGenerationResponse, ImageInput, ImageSize, LogConfig, LogEntry, LogHandler, MemoryEntry, Message, MessageContent, MessageContentPart, MessageRole, NPCConfig, PlayerInfo, RechargeConfig, RechargeEvents, RechargeModalOptions, SDKConfig, SDKMode, SchemaEntry, SetNicknameRequest, SetNicknameResponse, StreamChunk, StructuredGenerationConfig, StructuredOutputConfig, StructuredResult, TextContentPart, TokenRefreshResult, TokenScope, TokenStorageOptions, TokenValidatorOptions, TokenVerificationResult, TranscriptionConfig, TranscriptionOptions, TranscriptionResult, TranscriptionSegment, ValidatedPlayerInfo };
3100
+ export { AIContextManager, AuthFlowManager, AuthManager, BrowserStorage, BufferLogHandler, CallbackLogHandler, ChatClient, DeviceAuthFlowManager, ImageClient, LogLevel, Logger, MemoryStorage, NPCClient, PlayKitError, PlayKitSDK, PlayerClient, RechargeManager, SchemaLibrary, StreamParser, TTSClient, TokenStorage, TokenValidator, TranscriptionClient, createMultimodalMessage, createStorage, createTextMessage, PlayKitSDK as default, defaultContextManager, defaultSchemaLibrary, defaultTokenValidator, isLocalStorageAvailable };
3101
+ export type { AIContextManagerConfig, AIContextManagerEvents, APIResult, AudioContentPart, AuthState, ChatCompletionResponse, ChatConfig, ChatResult, ChatStreamConfig, ChatWithToolsConfig, ChatWithToolsStreamConfig, ConversationSaveData, DeveloperTokenFallbackConfig, DeviceAuthFlowOptions, DeviceAuthInitResult, DeviceAuthResult, GameInfo, GeneratedImage, IStorage, ImageContentPart, ImageGenerationConfig, ImageGenerationResponse, ImageInput, ImageSize, LogConfig, LogEntry, LogHandler, MemoryEntry, Message, MessageContent, MessageContentPart, MessageRole, NPCConfig, PlayerInfo, RechargeConfig, RechargeEvents, RechargeModalOptions, SDKConfig, SDKMode, SchemaEntry, SetNicknameRequest, SetNicknameResponse, StreamChunk, StructuredGenerationConfig, StructuredOutputConfig, StructuredResult, TTSConfig, TTSOptions, TTSResult, TextContentPart, TokenRefreshResult, TokenScope, TokenStorageOptions, TokenValidatorOptions, TokenVerificationResult, TranscriptionConfig, TranscriptionOptions, TranscriptionResult, TranscriptionSegment, ValidatedPlayerInfo };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * playkit-sdk v1.3.0
2
+ * playkit-sdk v1.4.0-beta.1
3
3
  * PlayKit SDK for JavaScript
4
4
  * @license SEE LICENSE IN LICENSE
5
5
  */
@@ -826,7 +826,7 @@ class TokenStorage {
826
826
  }
827
827
 
828
828
  const SDK_TYPE = 'Javascript';
829
- const SDK_VERSION = '"1.3.0"';
829
+ const SDK_VERSION = '"1.4.0-beta.1"';
830
830
  function getSDKHeaders() {
831
831
  return {
832
832
  'X-SDK-Type': SDK_TYPE,
@@ -2422,7 +2422,7 @@ DeviceAuthFlowManager.activeInstance = null;
2422
2422
  * Handles JWT exchange and token management
2423
2423
  */
2424
2424
  // @ts-ignore - replaced at build time
2425
- const DEFAULT_BASE_URL$5 = "https://api.playkit.ai";
2425
+ const DEFAULT_BASE_URL$6 = "https://api.playkit.ai";
2426
2426
  const JWT_EXCHANGE_ENDPOINT = '/api/external/exchange-jwt';
2427
2427
  const TOKEN_REFRESH_ENDPOINT = '/api/auth/refresh';
2428
2428
  class AuthManager extends EventEmitter {
@@ -2440,7 +2440,7 @@ class AuthManager extends EventEmitter {
2440
2440
  this.storage = new TokenStorage({
2441
2441
  mode: config.mode === 'server' ? 'server' : 'browser',
2442
2442
  });
2443
- this.baseURL = config.baseURL || DEFAULT_BASE_URL$5;
2443
+ this.baseURL = config.baseURL || DEFAULT_BASE_URL$6;
2444
2444
  this.authState = {
2445
2445
  isAuthenticated: false,
2446
2446
  };
@@ -3529,7 +3529,7 @@ class RechargeManager extends EventEmitter {
3529
3529
  * Player client for managing player information and credits
3530
3530
  */
3531
3531
  // @ts-ignore - replaced at build time
3532
- const DEFAULT_BASE_URL$4 = "https://api.playkit.ai";
3532
+ const DEFAULT_BASE_URL$5 = "https://api.playkit.ai";
3533
3533
  const PLAYER_INFO_ENDPOINT = '/api/external/player-info';
3534
3534
  const SET_NICKNAME_ENDPOINT = '/api/external/set-game-player-nickname';
3535
3535
  class PlayerClient extends EventEmitter {
@@ -3541,7 +3541,7 @@ class PlayerClient extends EventEmitter {
3541
3541
  this.balanceCheckInterval = null;
3542
3542
  this.logger = Logger.getLogger('PlayerClient');
3543
3543
  this.authManager = authManager;
3544
- this.baseURL = config.baseURL || DEFAULT_BASE_URL$4;
3544
+ this.baseURL = config.baseURL || DEFAULT_BASE_URL$5;
3545
3545
  this.gameId = config.gameId;
3546
3546
  this.rechargeConfig = {
3547
3547
  autoShowBalanceModal: (_a = rechargeConfig.autoShowBalanceModal) !== null && _a !== void 0 ? _a : true,
@@ -3889,12 +3889,12 @@ function contentToString$1(content) {
3889
3889
  return textParts.map(part => part.text).join('');
3890
3890
  }
3891
3891
  // @ts-ignore - replaced at build time
3892
- const DEFAULT_BASE_URL$3 = "https://api.playkit.ai";
3892
+ const DEFAULT_BASE_URL$4 = "https://api.playkit.ai";
3893
3893
  class ChatProvider {
3894
3894
  constructor(authManager, config) {
3895
3895
  this.authManager = authManager;
3896
3896
  this.config = config;
3897
- this.baseURL = config.baseURL || DEFAULT_BASE_URL$3;
3897
+ this.baseURL = config.baseURL || DEFAULT_BASE_URL$4;
3898
3898
  }
3899
3899
  /**
3900
3900
  * Set player client for balance checking
@@ -4221,12 +4221,12 @@ class ChatProvider {
4221
4221
  * Image generation provider for HTTP communication with image API
4222
4222
  */
4223
4223
  // @ts-ignore - replaced at build time
4224
- const DEFAULT_BASE_URL$2 = "https://api.playkit.ai";
4224
+ const DEFAULT_BASE_URL$3 = "https://api.playkit.ai";
4225
4225
  class ImageProvider {
4226
4226
  constructor(authManager, config) {
4227
4227
  this.authManager = authManager;
4228
4228
  this.config = config;
4229
- this.baseURL = config.baseURL || DEFAULT_BASE_URL$2;
4229
+ this.baseURL = config.baseURL || DEFAULT_BASE_URL$3;
4230
4230
  }
4231
4231
  /**
4232
4232
  * Set player client for balance checking
@@ -4310,12 +4310,12 @@ class ImageProvider {
4310
4310
  * Transcription provider for HTTP communication with audio transcription API
4311
4311
  */
4312
4312
  // @ts-ignore - replaced at build time
4313
- const DEFAULT_BASE_URL$1 = "https://api.playkit.ai";
4313
+ const DEFAULT_BASE_URL$2 = "https://api.playkit.ai";
4314
4314
  class TranscriptionProvider {
4315
4315
  constructor(authManager, config) {
4316
4316
  this.authManager = authManager;
4317
4317
  this.config = config;
4318
- this.baseURL = config.baseURL || DEFAULT_BASE_URL$1;
4318
+ this.baseURL = config.baseURL || DEFAULT_BASE_URL$2;
4319
4319
  }
4320
4320
  /**
4321
4321
  * Set player client for balance checking
@@ -4409,6 +4409,116 @@ class TranscriptionProvider {
4409
4409
  }
4410
4410
  }
4411
4411
 
4412
+ /**
4413
+ * TTS provider for HTTP communication with the text-to-speech API
4414
+ */
4415
+ // @ts-ignore - replaced at build time
4416
+ const DEFAULT_BASE_URL$1 = "https://api.playkit.ai";
4417
+ class TTSProvider {
4418
+ constructor(authManager, config) {
4419
+ this.authManager = authManager;
4420
+ this.config = config;
4421
+ this.baseURL = config.baseURL || DEFAULT_BASE_URL$1;
4422
+ }
4423
+ /**
4424
+ * Set player client for balance checking
4425
+ */
4426
+ setPlayerClient(playerClient) {
4427
+ this.playerClient = playerClient;
4428
+ }
4429
+ /**
4430
+ * Synthesize text into speech audio
4431
+ */
4432
+ async synthesize(ttsConfig) {
4433
+ // Ensure token is valid, auto-refresh if needed (browser mode only)
4434
+ await this.authManager.ensureValidToken();
4435
+ const token = this.authManager.getToken();
4436
+ if (!token) {
4437
+ throw new PlayKitError('Not authenticated', 'NOT_AUTHENTICATED');
4438
+ }
4439
+ const model = ttsConfig.model || this.config.defaultTTSModel || 'default-tts-model';
4440
+ const endpoint = `/ai/${this.config.gameId}/v2/audio/speech`;
4441
+ const requestBody = {
4442
+ model,
4443
+ text: ttsConfig.text,
4444
+ };
4445
+ // Add optional parameters (only when defined)
4446
+ if (ttsConfig.voice !== undefined) {
4447
+ requestBody.voice = ttsConfig.voice;
4448
+ }
4449
+ if (ttsConfig.speed !== undefined) {
4450
+ requestBody.speed = ttsConfig.speed;
4451
+ }
4452
+ if (ttsConfig.vol !== undefined) {
4453
+ requestBody.vol = ttsConfig.vol;
4454
+ }
4455
+ if (ttsConfig.pitch !== undefined) {
4456
+ requestBody.pitch = ttsConfig.pitch;
4457
+ }
4458
+ if (ttsConfig.emotion !== undefined) {
4459
+ requestBody.emotion = ttsConfig.emotion;
4460
+ }
4461
+ if (ttsConfig.languageBoost !== undefined) {
4462
+ requestBody.language_boost = ttsConfig.languageBoost;
4463
+ }
4464
+ if (ttsConfig.format !== undefined) {
4465
+ requestBody.response_format = ttsConfig.format;
4466
+ }
4467
+ if (ttsConfig.voiceSetting !== undefined) {
4468
+ requestBody.voice_setting = ttsConfig.voiceSetting;
4469
+ }
4470
+ if (ttsConfig.audioSetting !== undefined) {
4471
+ requestBody.audio_setting = ttsConfig.audioSetting;
4472
+ }
4473
+ try {
4474
+ const response = await fetch(`${this.baseURL}${endpoint}`, {
4475
+ method: 'POST',
4476
+ headers: Object.assign({ Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' }, getSDKHeaders()),
4477
+ body: JSON.stringify(requestBody),
4478
+ });
4479
+ if (!response.ok) {
4480
+ const error = await response.json().catch(() => ({ message: 'Speech synthesis failed' }));
4481
+ const playKitError = new PlayKitError(error.message || 'Speech synthesis failed', error.code, response.status);
4482
+ // Check for insufficient credits error
4483
+ if (error.code === 'INSUFFICIENT_CREDITS' ||
4484
+ error.code === 'PLAYER_INSUFFICIENT_CREDIT' ||
4485
+ response.status === 402) {
4486
+ if (this.playerClient) {
4487
+ await this.playerClient.handleInsufficientCredits(playKitError);
4488
+ }
4489
+ }
4490
+ throw playKitError;
4491
+ }
4492
+ // SUCCESS: response is raw audio bytes, NOT JSON.
4493
+ const audio = await response.arrayBuffer();
4494
+ const contentType = response.headers.get('Content-Type');
4495
+ const usageHeader = response.headers.get('X-Usage-Characters');
4496
+ const audioLengthHeader = response.headers.get('X-Audio-Length-Ms');
4497
+ const result = {
4498
+ audio,
4499
+ format: contentType || ttsConfig.format || 'mp3',
4500
+ usageCharacters: Number(usageHeader) || 0,
4501
+ };
4502
+ if (audioLengthHeader !== null) {
4503
+ result.audioLengthMs = Number(audioLengthHeader) || 0;
4504
+ }
4505
+ // Check balance after successful API call
4506
+ if (this.playerClient) {
4507
+ this.playerClient.checkBalanceAfterApiCall().catch(() => {
4508
+ // Silently fail
4509
+ });
4510
+ }
4511
+ return result;
4512
+ }
4513
+ catch (error) {
4514
+ if (error instanceof PlayKitError) {
4515
+ throw error;
4516
+ }
4517
+ throw new PlayKitError(error instanceof Error ? error.message : 'Unknown error', 'TTS_ERROR');
4518
+ }
4519
+ }
4520
+ }
4521
+
4412
4522
  /******************************************************************************
4413
4523
  Copyright (c) Microsoft Corporation.
4414
4524
 
@@ -5073,6 +5183,80 @@ class TranscriptionClient {
5073
5183
  }
5074
5184
  }
5075
5185
 
5186
+ /**
5187
+ * High-level client for text-to-speech synthesis
5188
+ */
5189
+ /**
5190
+ * Resolve an audio format/content-type string into a valid MIME type.
5191
+ * The provider's `result.format` may be a full MIME (e.g. 'audio/mpeg' from
5192
+ * the Content-Type header) or a bare token (e.g. 'mp3' from the fallback).
5193
+ * Full MIME strings pass through; bare tokens are mapped.
5194
+ */
5195
+ function contentTypeFor(format) {
5196
+ if (format.includes('/')) {
5197
+ return format;
5198
+ }
5199
+ switch (format.toLowerCase()) {
5200
+ case 'mp3':
5201
+ return 'audio/mpeg';
5202
+ case 'wav':
5203
+ return 'audio/wav';
5204
+ case 'ogg':
5205
+ return 'audio/ogg';
5206
+ case 'flac':
5207
+ return 'audio/flac';
5208
+ case 'aac':
5209
+ return 'audio/aac';
5210
+ case 'pcm':
5211
+ return 'audio/pcm';
5212
+ default:
5213
+ return 'audio/mpeg';
5214
+ }
5215
+ }
5216
+ class TTSClient {
5217
+ constructor(provider, model) {
5218
+ this.provider = provider;
5219
+ this.model = model || 'default-tts-model';
5220
+ }
5221
+ /**
5222
+ * Get the current model name
5223
+ */
5224
+ get modelName() {
5225
+ return this.model;
5226
+ }
5227
+ /**
5228
+ * Synthesize text into speech audio
5229
+ * @param config - Full TTS configuration
5230
+ * @returns TTS result containing raw audio bytes and usage metadata
5231
+ */
5232
+ async synthesize(config) {
5233
+ return this.provider.synthesize(Object.assign(Object.assign({}, config), { model: config.model || this.model }));
5234
+ }
5235
+ /**
5236
+ * Synthesize text into speech and return it as a Blob (browser-friendly)
5237
+ * @param config - Full TTS configuration
5238
+ * @returns Audio Blob with the appropriate MIME type
5239
+ */
5240
+ async synthesizeToBlob(config) {
5241
+ const result = await this.synthesize(config);
5242
+ return new Blob([result.audio], { type: contentTypeFor(result.format) });
5243
+ }
5244
+ /**
5245
+ * Synthesize text into speech and return an object URL (browser only)
5246
+ * @param config - Full TTS configuration
5247
+ * @returns An object URL that can be assigned to an <audio> element
5248
+ * @throws PlayKitError if URL.createObjectURL is unavailable (e.g. Node.js)
5249
+ */
5250
+ async synthesizeToObjectURL(config) {
5251
+ if (typeof URL === 'undefined' || typeof URL.createObjectURL !== 'function') {
5252
+ throw new PlayKitError('URL.createObjectURL is not available in this environment. ' +
5253
+ 'Use synthesize() to access the raw audio bytes instead.', 'TTS_OBJECT_URL_UNAVAILABLE');
5254
+ }
5255
+ const blob = await this.synthesizeToBlob(config);
5256
+ return URL.createObjectURL(blob);
5257
+ }
5258
+ }
5259
+
5076
5260
  /**
5077
5261
  * Global AI Context Manager for managing NPC conversations and player context.
5078
5262
  *
@@ -6396,10 +6580,12 @@ class PlayKitSDK extends EventEmitter {
6396
6580
  this.chatProvider = new ChatProvider(this.authManager, this.config);
6397
6581
  this.imageProvider = new ImageProvider(this.authManager, this.config);
6398
6582
  this.transcriptionProvider = new TranscriptionProvider(this.authManager, this.config);
6583
+ this.ttsProvider = new TTSProvider(this.authManager, this.config);
6399
6584
  // Connect providers to player client for balance checking
6400
6585
  this.chatProvider.setPlayerClient(this.playerClient);
6401
6586
  this.imageProvider.setPlayerClient(this.playerClient);
6402
6587
  this.transcriptionProvider.setPlayerClient(this.playerClient);
6588
+ this.ttsProvider.setPlayerClient(this.playerClient);
6403
6589
  // Initialize AI context manager
6404
6590
  this.contextManager = new AIContextManager(this.config.aiContext);
6405
6591
  // Set chat client factory for compaction
@@ -6648,6 +6834,14 @@ class PlayKitSDK extends EventEmitter {
6648
6834
  this.ensureInitialized();
6649
6835
  return new TranscriptionClient(this.transcriptionProvider, model || this.config.defaultTranscriptionModel);
6650
6836
  }
6837
+ /**
6838
+ * Create a TTS client for text-to-speech
6839
+ * @param model - TTS model to use (default: 'default-tts-model')
6840
+ */
6841
+ createTTSClient(model) {
6842
+ this.ensureInitialized();
6843
+ return new TTSClient(this.ttsProvider, model || this.config.defaultTTSModel);
6844
+ }
6651
6845
  /**
6652
6846
  * Create an NPC client
6653
6847
  * Automatically registers with AIContextManager
@@ -7038,5 +7232,5 @@ class TokenValidator {
7038
7232
  */
7039
7233
  const defaultTokenValidator = new TokenValidator();
7040
7234
 
7041
- export { AIContextManager, AuthFlowManager, AuthManager, BrowserStorage, BufferLogHandler, CallbackLogHandler, ChatClient, DeviceAuthFlowManager, ImageClient, LogLevel, Logger, MemoryStorage, NPCClient, PlayKitSDK, PlayerClient, RechargeManager, SchemaLibrary, StreamParser, TokenStorage, TokenValidator, TranscriptionClient, createMultimodalMessage, createStorage, createTextMessage, PlayKitSDK as default, defaultContextManager, defaultSchemaLibrary, defaultTokenValidator, isLocalStorageAvailable };
7235
+ export { AIContextManager, AuthFlowManager, AuthManager, BrowserStorage, BufferLogHandler, CallbackLogHandler, ChatClient, DeviceAuthFlowManager, ImageClient, LogLevel, Logger, MemoryStorage, NPCClient, PlayKitSDK, PlayerClient, RechargeManager, SchemaLibrary, StreamParser, TTSClient, TokenStorage, TokenValidator, TranscriptionClient, createMultimodalMessage, createStorage, createTextMessage, PlayKitSDK as default, defaultContextManager, defaultSchemaLibrary, defaultTokenValidator, isLocalStorageAvailable };
7042
7236
  //# sourceMappingURL=playkit-sdk.esm.js.map