@pie-players/tts-server-google 0.3.61 → 0.3.62

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.
@@ -484,4 +484,3 @@ export class GoogleCloudTTSProvider extends BaseTTSProvider {
484
484
  await super.destroy();
485
485
  }
486
486
  }
487
- //# sourceMappingURL=GoogleCloudTTSProvider.js.map
package/dist/index.js CHANGED
@@ -3,4 +3,3 @@
3
3
  * @module @pie-players/tts-server-google
4
4
  */
5
5
  export { GoogleCloudTTSProvider } from "./GoogleCloudTTSProvider.js";
6
- //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-players/tts-server-google",
3
- "version": "0.3.61",
3
+ "version": "0.3.62",
4
4
  "description": "Google Cloud Text-to-Speech provider for server-side TTS with speech marks support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -40,11 +40,11 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@google-cloud/text-to-speech": "^6.4.0",
43
- "@pie-players/tts-server-core": "0.3.61"
43
+ "@pie-players/tts-server-core": "0.3.62"
44
44
  },
45
45
  "devDependencies": {
46
46
  "typescript": "^5.9.3",
47
- "vitest": "^4.1.4"
47
+ "vitest": "^4.1.10"
48
48
  },
49
49
  "sideEffects": false,
50
50
  "homepage": "https://github.com/pie-framework/pie-players/tree/master/packages/tts-server-google#readme",
@@ -1 +0,0 @@
1
- {"version":3,"file":"GoogleCloudTTSProvider.js","sourceRoot":"","sources":["../src/GoogleCloudTTSProvider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,EACN,eAAe,EAMf,QAAQ,EACR,YAAY,GAGZ,MAAM,8BAA8B,CAAC;AA2EtC;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,sBAAuB,SAAQ,eAAe;IACjD,UAAU,GAAG,kBAAk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AAC;QAED,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YACtB,qBAAqB;YACrB,OAAO,IAAI,QAAQ,CAClB,YAAY,CAAC,mBAAmB,EAChC,qCAAqC,OAAO,EAAE,EAC9C,EAAE,KAAK,EAAE,EACT,IAAI,CAAC,UAAU,CACf,CAAC;QACH,CAAC;QAED,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YACtB,mBAAmB;YACnB,OAAO,IAAI,QAAQ,CAClB,YAAY,CAAC,eAAe,EAC5B,wCAAwC,OAAO,EAAE,EACjD,EAAE,KAAK,EAAE,EACT,IAAI,CAAC,UAAU,CACf,CAAC;QACH,CAAC;QAED,4BAA4B;QAC5B,OAAO,IAAI,QAAQ,CAClB,YAAY,CAAC,cAAc,EAC3B,2BAA2B,OAAO,EAAE,EACpC,EAAE,KAAK,EAAE,EACT,IAAI,CAAC,UAAU,CACf,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO;QACZ,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAC3B,CAAC;QACD,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC;CACD","sourcesContent":["/**\n * Google Cloud Text-to-Speech server-side TTS provider\n * @module @pie-players/tts-server-google\n */\n\nimport { v1beta1, protos } from \"@google-cloud/text-to-speech\";\n\nimport {\n\tBaseTTSProvider,\n\ttype GetVoicesOptions,\n\ttype ServerProviderCapabilities,\n\ttype SpeechMark,\n\ttype SynthesizeRequest,\n\ttype SynthesizeResponse,\n\tTTSError,\n\tTTSErrorCode,\n\ttype TTSServerConfig,\n\ttype Voice,\n} from \"@pie-players/tts-server-core\";\n\n/**\n * Google Cloud Text-to-Speech provider configuration.\n *\n * This extends the base TTSServerConfig with Google Cloud-specific settings.\n */\nexport interface GoogleCloudTTSConfig extends TTSServerConfig {\n\t/**\n\t * Google Cloud project ID (required)\n\t *\n\t * @example 'my-project-123456'\n\t * @required\n\t */\n\tprojectId: string;\n\n\t/**\n\t * Authentication credentials\n\t *\n\t * Supports multiple authentication methods:\n\t * - Service account JSON file path (recommended for production)\n\t * - Service account key object (for containers/serverless)\n\t * - API key (for simple applications)\n\t * - Omit to use Application Default Credentials (ADC) for local development\n\t *\n\t * @example '/path/to/service-account.json'\n\t * @example { client_email: '...', private_key: '...' }\n\t * @example { apiKey: 'AIza...' }\n\t * @see https://cloud.google.com/docs/authentication\n\t */\n\tcredentials?:\n\t\t| string // Path to service account JSON file\n\t\t| {\n\t\t\t\t// Service account key object\n\t\t\t\tclient_email: string;\n\t\t\t\tprivate_key: string;\n\t\t\t\tproject_id?: string;\n\t\t }\n\t\t| {\n\t\t\t\t// API key\n\t\t\t\tapiKey: string;\n\t\t };\n\n\t/**\n\t * Voice type: 'wavenet' (neural), 'standard', or 'studio' (premium)\n\t *\n\t * @default 'wavenet'\n\t * @note WaveNet: $16/1M chars, Standard: $4/1M chars, Studio: $16/1M chars\n\t */\n\tvoiceType?: \"wavenet\" | \"standard\" | \"studio\";\n\n\t/**\n\t * Default voice name if not specified in synthesis requests\n\t *\n\t * @default 'en-US-Wavenet-A'\n\t * @example 'en-US-Wavenet-A', 'en-GB-Standard-B', 'es-ES-Studio-C'\n\t * @see https://cloud.google.com/text-to-speech/docs/voices\n\t */\n\tdefaultVoice?: string;\n\n\t/**\n\t * Audio encoding format\n\t *\n\t * @default 'MP3'\n\t */\n\taudioEncoding?: \"MP3\" | \"LINEAR16\" | \"OGG_OPUS\";\n\n\t/**\n\t * Enable detailed logging for debugging\n\t *\n\t * @default false\n\t */\n\tenableLogging?: boolean;\n}\n\n/**\n * Google Cloud Text-to-Speech Server Provider\n *\n * Provides high-quality neural text-to-speech with precise word-level timing\n * through Google Cloud Text-to-Speech API.\n *\n * Features:\n * - Speech marks support via SSML mark injection (millisecond precision)\n * - WaveNet (neural), Standard, and Studio voice types\n * - 200+ voices across 50+ languages\n * - Full SSML support\n * - Single API call for audio + speech marks\n */\nexport class GoogleCloudTTSProvider extends BaseTTSProvider {\n\treadonly providerId = \"google-cloud-tts\";\n\treadonly providerName = \"Google Cloud Text-to-Speech\";\n\treadonly version = \"1.0.0\";\n\n\tprivate client!: v1beta1.TextToSpeechClient;\n\tprivate voiceType: \"wavenet\" | \"standard\" | \"studio\" = \"wavenet\";\n\tprivate defaultVoice = \"en-US-Wavenet-A\";\n\tprivate audioEncoding: \"MP3\" | \"LINEAR16\" | \"OGG_OPUS\" = \"MP3\";\n\tprivate enableLogging = false;\n\n\tprivate isStudioVoice(voice: string): boolean {\n\t\treturn /studio/i.test(voice);\n\t}\n\n\tprivate isStudioMarkUnsupportedError(error: unknown): boolean {\n\t\tconst message =\n\t\t\terror instanceof Error\n\t\t\t\t? error.message\n\t\t\t\t: typeof error === \"string\"\n\t\t\t\t\t? error\n\t\t\t\t\t: \"\";\n\t\treturn (\n\t\t\tmessage.includes(\"<mark>\") &&\n\t\t\tmessage.toLowerCase().includes(\"not currently supported\") &&\n\t\t\tmessage.toLowerCase().includes(\"studio\")\n\t\t);\n\t}\n\n\t/**\n\t * Initialize the Google Cloud TTS provider.\n\t *\n\t * This is FAST and lightweight - only validates config and creates the client.\n\t * Does NOT fetch voices or make test API calls.\n\t *\n\t * @param config - Google Cloud TTS configuration\n\t * @performance Completes in ~10-50ms\n\t */\n\tasync initialize(config: GoogleCloudTTSConfig): Promise<void> {\n\t\tif (!config.projectId) {\n\t\t\tthrow new TTSError(\n\t\t\t\tTTSErrorCode.INITIALIZATION_ERROR,\n\t\t\t\t\"Google Cloud project ID is required\",\n\t\t\t\tundefined,\n\t\t\t\tthis.providerId,\n\t\t\t);\n\t\t}\n\n\t\tthis.config = config;\n\t\tthis.voiceType = config.voiceType || \"wavenet\";\n\t\tthis.defaultVoice = config.defaultVoice || \"en-US-Wavenet-A\";\n\t\tthis.audioEncoding = config.audioEncoding || \"MP3\";\n\t\tthis.enableLogging = config.enableLogging || false;\n\n\t\ttry {\n\t\t\t// Initialize Google Cloud TTS client\n\t\t\tconst clientConfig: any = {\n\t\t\t\tprojectId: config.projectId,\n\t\t\t};\n\n\t\t\t// Handle different credential types\n\t\t\tif (config.credentials) {\n\t\t\t\tif (typeof config.credentials === \"string\") {\n\t\t\t\t\t// Path to service account JSON file\n\t\t\t\t\tclientConfig.keyFilename = config.credentials;\n\t\t\t\t} else if (\"apiKey\" in config.credentials) {\n\t\t\t\t\t// API key authentication\n\t\t\t\t\tclientConfig.apiKey = config.credentials.apiKey;\n\t\t\t\t} else {\n\t\t\t\t\t// Service account key object\n\t\t\t\t\tclientConfig.credentials = config.credentials;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Else: Use Application Default Credentials (ADC)\n\n\t\t\tthis.client = new v1beta1.TextToSpeechClient(clientConfig);\n\t\t\tthis.initialized = true;\n\n\t\t\tif (this.enableLogging) {\n\t\t\t\tconsole.log(\"[GoogleCloudTTS] Initialized successfully\");\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthrow new TTSError(\n\t\t\t\tTTSErrorCode.INITIALIZATION_ERROR,\n\t\t\t\t`Failed to initialize Google Cloud TTS: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\t{ error },\n\t\t\t\tthis.providerId,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Synthesize speech with Google Cloud TTS\n\t */\n\tasync synthesize(request: SynthesizeRequest): Promise<SynthesizeResponse> {\n\t\tthis.ensureInitialized();\n\n\t\tconst capabilities = this.getCapabilities();\n\t\tthis.validateRequest(request, capabilities);\n\n\t\tconst voice = request.voice || this.defaultVoice;\n\t\tconst startTime = Date.now();\n\n\t\ttry {\n\t\t\t// Check if speech marks are requested\n\t\t\tif (request.includeSpeechMarks !== false && !this.isStudioVoice(voice)) {\n\t\t\t\t// Use SSML marks injection for precise word timing\n\t\t\t\tconst result = await this.synthesizeWithSpeechMarks(request, voice);\n\t\t\t\tconst duration = (Date.now() - startTime) / 1000;\n\n\t\t\t\treturn {\n\t\t\t\t\taudio: result.audio,\n\t\t\t\t\tcontentType: result.contentType,\n\t\t\t\t\tspeechMarks: result.speechMarks,\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\tproviderId: this.providerId,\n\t\t\t\t\t\tvoice,\n\t\t\t\t\t\tduration,\n\t\t\t\t\t\tcharCount: request.text.length,\n\t\t\t\t\t\tcached: false,\n\t\t\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\t// Audio only (no speech marks)\n\t\t\t\tconst result = await this.synthesizeAudio(request, voice);\n\t\t\t\tconst duration = (Date.now() - startTime) / 1000;\n\n\t\t\t\treturn {\n\t\t\t\t\taudio: result.audio,\n\t\t\t\t\tcontentType: result.contentType,\n\t\t\t\t\tspeechMarks: [],\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\tproviderId: this.providerId,\n\t\t\t\t\t\tvoice,\n\t\t\t\t\t\tduration,\n\t\t\t\t\t\tcharCount: request.text.length,\n\t\t\t\t\t\tcached: false,\n\t\t\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t} catch (error) {\n\t\t\t// Studio voices do not support SSML <mark> tags used for timing extraction.\n\t\t\t// Fall back to audio-only synthesis rather than failing the request.\n\t\t\tif (\n\t\t\t\trequest.includeSpeechMarks !== false &&\n\t\t\t\tthis.isStudioMarkUnsupportedError(error)\n\t\t\t) {\n\t\t\t\tconst result = await this.synthesizeAudio(request, voice);\n\t\t\t\tconst duration = (Date.now() - startTime) / 1000;\n\t\t\t\treturn {\n\t\t\t\t\taudio: result.audio,\n\t\t\t\t\tcontentType: result.contentType,\n\t\t\t\t\tspeechMarks: [],\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\tproviderId: this.providerId,\n\t\t\t\t\t\tvoice,\n\t\t\t\t\t\tduration,\n\t\t\t\t\t\tcharCount: request.text.length,\n\t\t\t\t\t\tcached: false,\n\t\t\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t\tthrow this.mapGoogleErrorToTTSError(error);\n\t\t}\n\t}\n\n\t/**\n\t * Synthesize audio stream only (no speech marks)\n\t */\n\tprivate async synthesizeAudio(\n\t\trequest: SynthesizeRequest,\n\t\tvoice: string,\n\t): Promise<{ audio: Buffer; contentType: string }> {\n\t\t// Detect if text contains SSML tags\n\t\tconst isSsml = this.detectSSML(request.text);\n\n\t\tif (isSsml && this.enableLogging) {\n\t\t\tconsole.log(\"[GoogleCloudTTS] Detected SSML content\");\n\t\t}\n\n\t\t// Parse voice name to extract language code\n\t\tconst languageCode = voice.split(\"-\").slice(0, 2).join(\"-\"); // e.g., \"en-US\" from \"en-US-Wavenet-A\"\n\n\t\t// Map our audio encoding to Google's enum\n\t\tconst audioEncodingMap = {\n\t\t\tMP3: \"MP3\" as const,\n\t\t\tLINEAR16: \"LINEAR16\" as const,\n\t\t\tOGG_OPUS: \"OGG_OPUS\" as const,\n\t\t};\n\n\t\tconst [response] = await this.client.synthesizeSpeech({\n\t\t\tinput: isSsml ? { ssml: request.text } : { text: request.text },\n\t\t\tvoice: {\n\t\t\t\tlanguageCode,\n\t\t\t\tname: voice,\n\t\t\t},\n\t\t\taudioConfig: {\n\t\t\t\taudioEncoding: audioEncodingMap[this.audioEncoding],\n\t\t\t\tsampleRateHertz: request.sampleRate || 24000,\n\t\t\t},\n\t\t});\n\n\t\tif (!response.audioContent) {\n\t\t\tthrow new Error(\"No audio content received from Google Cloud TTS\");\n\t\t}\n\n\t\t// Convert Uint8Array to Buffer\n\t\tconst audioBuffer = Buffer.from(response.audioContent);\n\n\t\tconst contentTypeMap = {\n\t\t\tMP3: \"audio/mpeg\",\n\t\t\tLINEAR16: \"audio/wav\",\n\t\t\tOGG_OPUS: \"audio/ogg\",\n\t\t};\n\n\t\treturn {\n\t\t\taudio: audioBuffer,\n\t\t\tcontentType: contentTypeMap[this.audioEncoding],\n\t\t};\n\t}\n\n\t/**\n\t * Synthesize with speech marks using SSML mark injection\n\t */\n\tprivate async synthesizeWithSpeechMarks(\n\t\trequest: SynthesizeRequest,\n\t\tvoice: string,\n\t): Promise<{\n\t\taudio: Buffer;\n\t\tcontentType: string;\n\t\tspeechMarks: SpeechMark[];\n\t}> {\n\t\t// Check if the text is already SSML\n\t\tconst isUserSSML = this.detectSSML(request.text);\n\n\t\t// If user provided SSML, we need to inject marks within the existing SSML\n\t\t// For simplicity in v1, we'll inject marks for plain text only\n\t\tconst { ssml, wordMap } = isUserSSML\n\t\t\t? this.extractWordsFromSSML(request.text)\n\t\t\t: this.injectSSMLMarks(request.text);\n\n\t\tif (this.enableLogging) {\n\t\t\tconsole.log(`[GoogleCloudTTS] Injected ${wordMap.length} SSML marks`);\n\t\t}\n\n\t\t// Parse voice name to extract language code\n\t\tconst languageCode = voice.split(\"-\").slice(0, 2).join(\"-\");\n\n\t\t// Map our audio encoding to Google's enum\n\t\tconst audioEncodingMap = {\n\t\t\tMP3: \"MP3\" as const,\n\t\t\tLINEAR16: \"LINEAR16\" as const,\n\t\t\tOGG_OPUS: \"OGG_OPUS\" as const,\n\t\t};\n\n\t\t// Single API call with timepoint tracking enabled\n\t\tconst responseArray = await this.client.synthesizeSpeech({\n\t\t\tinput: { ssml },\n\t\t\tvoice: {\n\t\t\t\tlanguageCode,\n\t\t\t\tname: voice,\n\t\t\t},\n\t\t\taudioConfig: {\n\t\t\t\taudioEncoding: audioEncodingMap[this.audioEncoding],\n\t\t\t\tsampleRateHertz: request.sampleRate || 24000,\n\t\t\t},\n\t\t\tenableTimePointing: [\n\t\t\t\tprotos.google.cloud.texttospeech.v1beta1.SynthesizeSpeechRequest\n\t\t\t\t\t.TimepointType.SSML_MARK,\n\t\t\t],\n\t\t});\n\t\tconst response = responseArray[0];\n\n\t\tif (!response.audioContent) {\n\t\t\tthrow new Error(\"No audio content received from Google Cloud TTS\");\n\t\t}\n\n\t\t// Convert Uint8Array to Buffer\n\t\tconst audioBuffer = Buffer.from(response.audioContent);\n\n\t\tconst contentTypeMap = {\n\t\t\tMP3: \"audio/mpeg\",\n\t\t\tLINEAR16: \"audio/wav\",\n\t\t\tOGG_OPUS: \"audio/ogg\",\n\t\t};\n\n\t\t// Extract speech marks from timepoints\n\t\tconst speechMarks = this.extractSpeechMarksFromTimepoints(\n\t\t\tresponse.timepoints || [],\n\t\t\twordMap,\n\t\t);\n\n\t\tif (this.enableLogging) {\n\t\t\tconsole.log(\n\t\t\t\t`[GoogleCloudTTS] Extracted ${speechMarks.length} speech marks`,\n\t\t\t);\n\t\t}\n\n\t\treturn {\n\t\t\taudio: audioBuffer,\n\t\t\tcontentType: contentTypeMap[this.audioEncoding],\n\t\t\tspeechMarks,\n\t\t};\n\t}\n\n\t/**\n\t * Inject SSML marks before each word in plain text\n\t */\n\tprivate injectSSMLMarks(text: string): {\n\t\tssml: string;\n\t\twordMap: Array<{\n\t\t\tword: string;\n\t\t\tstart: number;\n\t\t\tend: number;\n\t\t\tmarkName: string;\n\t\t}>;\n\t} {\n\t\tconst words: Array<{\n\t\t\tword: string;\n\t\t\tstart: number;\n\t\t\tend: number;\n\t\t\tmarkName: string;\n\t\t}> = [];\n\t\tconst wordRegex = /\\b[\\w']+\\b/g;\n\t\tlet match;\n\t\tlet markIndex = 0;\n\n\t\twhile ((match = wordRegex.exec(text)) !== null) {\n\t\t\tconst word = match[0];\n\t\t\tconst start = match.index;\n\t\t\tconst end = start + word.length;\n\t\t\tconst markName = `w${markIndex++}`;\n\n\t\t\twords.push({ word, start, end, markName });\n\t\t}\n\n\t\t// Build SSML with marks\n\t\tlet ssml = \"<speak>\";\n\t\tlet lastEnd = 0;\n\n\t\tfor (const { word, start, end, markName } of words) {\n\t\t\t// Add text before word (including whitespace and punctuation)\n\t\t\tssml += this.escapeSSML(text.slice(lastEnd, start));\n\t\t\t// Add marked word\n\t\t\tssml += `<mark name=\"${markName}\"/>${this.escapeSSML(word)}`;\n\t\t\tlastEnd = end;\n\t\t}\n\n\t\t// Add remaining text\n\t\tssml += this.escapeSSML(text.slice(lastEnd)) + \"</speak>\";\n\n\t\treturn { ssml, wordMap: words };\n\t}\n\n\t/**\n\t * Extract words from existing SSML (simplified version for v1)\n\t */\n\tprivate extractWordsFromSSML(ssmlText: string): {\n\t\tssml: string;\n\t\twordMap: Array<{\n\t\t\tword: string;\n\t\t\tstart: number;\n\t\t\tend: number;\n\t\t\tmarkName: string;\n\t\t}>;\n\t} {\n\t\t// For now, just strip SSML tags and inject marks\n\t\t// More sophisticated SSML parsing can be added in future versions\n\t\tconst plainText = ssmlText\n\t\t\t.replace(/<[^>]+>/g, \" \") // Remove all tags\n\t\t\t.replace(/\\s+/g, \" \") // Normalize whitespace\n\t\t\t.trim();\n\n\t\treturn this.injectSSMLMarks(plainText);\n\t}\n\n\t/**\n\t * Escape special XML characters for SSML\n\t */\n\tprivate escapeSSML(text: string): string {\n\t\treturn text\n\t\t\t.replace(/&/g, \"&amp;\")\n\t\t\t.replace(/</g, \"&lt;\")\n\t\t\t.replace(/>/g, \"&gt;\")\n\t\t\t.replace(/\"/g, \"&quot;\")\n\t\t\t.replace(/'/g, \"&apos;\");\n\t}\n\n\t/**\n\t * Extract speech marks from Google's timepoints\n\t */\n\tprivate extractSpeechMarksFromTimepoints(\n\t\ttimepoints:\n\t\t\t| protos.google.cloud.texttospeech.v1beta1.ITimepoint[]\n\t\t\t| null\n\t\t\t| undefined,\n\t\twordMap: Array<{\n\t\t\tword: string;\n\t\t\tstart: number;\n\t\t\tend: number;\n\t\t\tmarkName: string;\n\t\t}>,\n\t): SpeechMark[] {\n\t\tif (!timepoints || timepoints.length === 0) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst speechMarks: SpeechMark[] = [];\n\n\t\tfor (const timepoint of timepoints) {\n\t\t\t// Find corresponding word in our map\n\t\t\tconst wordInfo = wordMap.find((w) => w.markName === timepoint.markName);\n\n\t\t\tif (\n\t\t\t\twordInfo &&\n\t\t\t\ttimepoint.timeSeconds !== undefined &&\n\t\t\t\ttimepoint.timeSeconds !== null\n\t\t\t) {\n\t\t\t\tspeechMarks.push({\n\t\t\t\t\ttime: Math.round(timepoint.timeSeconds * 1000), // Convert to ms\n\t\t\t\t\ttype: \"word\",\n\t\t\t\t\tstart: wordInfo.start,\n\t\t\t\t\tend: wordInfo.end,\n\t\t\t\t\tvalue: wordInfo.word,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// Sort by time\n\t\treturn speechMarks.sort((a, b) => a.time - b.time);\n\t}\n\n\t/**\n\t * Detect if text contains SSML markup\n\t */\n\tprivate detectSSML(text: string): boolean {\n\t\treturn (\n\t\t\ttext.includes(\"<speak\") ||\n\t\t\ttext.includes(\"<prosody\") ||\n\t\t\ttext.includes(\"<emphasis\") ||\n\t\t\ttext.includes(\"<break\") ||\n\t\t\ttext.includes(\"<phoneme\") ||\n\t\t\ttext.includes(\"<say-as\") ||\n\t\t\ttext.includes(\"<mark\")\n\t\t);\n\t}\n\n\t/**\n\t * Get available voices from Google Cloud TTS\n\t */\n\tasync getVoices(options?: GetVoicesOptions): Promise<Voice[]> {\n\t\tthis.ensureInitialized();\n\n\t\ttry {\n\t\t\tconst [response] = await this.client.listVoices({\n\t\t\t\tlanguageCode: options?.language,\n\t\t\t});\n\n\t\t\tif (!response.voices) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\treturn response.voices\n\t\t\t\t.map((voice) => this.mapGoogleVoiceToVoice(voice))\n\t\t\t\t.filter((voice) => {\n\t\t\t\t\t// Apply filters\n\t\t\t\t\tif (options?.gender && voice.gender !== options.gender) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tif (options?.quality && voice.quality !== options.quality) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\treturn true;\n\t\t\t\t});\n\t\t} catch (error) {\n\t\t\tthrow new TTSError(\n\t\t\t\tTTSErrorCode.PROVIDER_ERROR,\n\t\t\t\t`Failed to get voices: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\t{ error },\n\t\t\t\tthis.providerId,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Map Google Cloud voice to unified Voice interface\n\t */\n\tprivate mapGoogleVoiceToVoice(\n\t\tgoogleVoice: protos.google.cloud.texttospeech.v1beta1.IVoice,\n\t): Voice {\n\t\tconst voiceName = googleVoice.name || \"\";\n\n\t\t// Determine quality based on voice type\n\t\tlet quality: \"standard\" | \"neural\" | \"premium\" = \"standard\";\n\t\tif (voiceName.includes(\"Wavenet\")) {\n\t\t\tquality = \"neural\";\n\t\t} else if (voiceName.includes(\"Studio\")) {\n\t\t\tquality = \"premium\";\n\t\t}\n\n\t\t// Map SSML gender to our gender type\n\t\tconst genderMap: Record<string, \"male\" | \"female\" | \"neutral\"> = {\n\t\t\tMALE: \"male\",\n\t\t\tFEMALE: \"female\",\n\t\t\tNEUTRAL: \"neutral\",\n\t\t};\n\t\tconst gender = genderMap[googleVoice.ssmlGender || \"NEUTRAL\"] || \"neutral\";\n\n\t\treturn {\n\t\t\tid: voiceName,\n\t\t\tname: voiceName,\n\t\t\tlanguage: googleVoice.languageCodes?.[0] || \"Unknown\",\n\t\t\tlanguageCode: googleVoice.languageCodes?.[0] || \"\",\n\t\t\tgender,\n\t\t\tquality,\n\t\t\tsupportedFeatures: {\n\t\t\t\tssml: true,\n\t\t\t\temotions: false, // Google doesn't have built-in emotions\n\t\t\t\tstyles: false, // Google doesn't have speaking styles\n\t\t\t},\n\t\t\tproviderMetadata: {\n\t\t\t\tnaturalSampleRateHertz: googleVoice.naturalSampleRateHertz,\n\t\t\t\tlanguageCodes: googleVoice.languageCodes,\n\t\t\t\tssmlGender: googleVoice.ssmlGender,\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * Get Google Cloud TTS capabilities\n\t */\n\tgetCapabilities(): ServerProviderCapabilities {\n\t\treturn {\n\t\t\t// W3C Standard features\n\t\t\tstandard: {\n\t\t\t\tsupportsSSML: true, // ✅ Full SSML 1.1 support\n\t\t\t\tsupportsPitch: true, // ✅ Via SSML <prosody pitch>\n\t\t\t\tsupportsRate: true, // ✅ Via SSML <prosody rate>\n\t\t\t\tsupportsVolume: false, // ❌ Not supported (handle client-side)\n\t\t\t\tsupportsMultipleVoices: true, // ✅ 200+ voices across 50+ languages\n\t\t\t\tmaxTextLength: 5000, // Google Cloud TTS limit per request\n\t\t\t},\n\n\t\t\t// Provider-specific extensions\n\t\t\textensions: {\n\t\t\t\tsupportsSpeechMarks: true, // ✅ Via SSML marks + timepoints\n\t\t\t\tsupportedFormats: [\"mp3\", \"wav\", \"ogg\"], // MP3, LINEAR16, OGG_OPUS\n\t\t\t\tsupportsSampleRate: true, // ✅ Configurable sample rate\n\n\t\t\t\t// Google Cloud-specific features\n\t\t\t\tproviderSpecific: {\n\t\t\t\t\tvoiceTypes: [\"standard\", \"wavenet\", \"studio\"],\n\t\t\t\t\tvoicesCount: 200, // ~200+ voices available\n\t\t\t\t\tlanguagesCount: 50, // 50+ languages supported\n\t\t\t\t\tsupportsAudioProfiles: true, // Audio device profiles\n\t\t\t\t\tsupportsEffects: false, // No built-in effects\n\t\t\t\t\tsupportsEmotions: false, // No emotion control\n\t\t\t\t\tsupportsStyles: false, // No speaking styles\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * Map Google Cloud errors to TTSError codes\n\t */\n\tprivate mapGoogleErrorToTTSError(error: any): TTSError {\n\t\tconst message = error.message || String(error);\n\n\t\t// Check for specific Google Cloud error codes\n\t\tif (error.code === 7) {\n\t\t\t// PERMISSION_DENIED\n\t\t\treturn new TTSError(\n\t\t\t\tTTSErrorCode.AUTHENTICATION_ERROR,\n\t\t\t\t`Google Cloud authentication failed: ${message}`,\n\t\t\t\t{ error },\n\t\t\t\tthis.providerId,\n\t\t\t);\n\t\t}\n\n\t\tif (error.code === 8) {\n\t\t\t// RESOURCE_EXHAUSTED\n\t\t\treturn new TTSError(\n\t\t\t\tTTSErrorCode.RATE_LIMIT_EXCEEDED,\n\t\t\t\t`Google Cloud rate limit exceeded: ${message}`,\n\t\t\t\t{ error },\n\t\t\t\tthis.providerId,\n\t\t\t);\n\t\t}\n\n\t\tif (error.code === 3) {\n\t\t\t// INVALID_ARGUMENT\n\t\t\treturn new TTSError(\n\t\t\t\tTTSErrorCode.INVALID_REQUEST,\n\t\t\t\t`Invalid request to Google Cloud TTS: ${message}`,\n\t\t\t\t{ error },\n\t\t\t\tthis.providerId,\n\t\t\t);\n\t\t}\n\n\t\t// Default to provider error\n\t\treturn new TTSError(\n\t\t\tTTSErrorCode.PROVIDER_ERROR,\n\t\t\t`Google Cloud TTS error: ${message}`,\n\t\t\t{ error },\n\t\t\tthis.providerId,\n\t\t);\n\t}\n\n\t/**\n\t * Clean up Google Cloud TTS client\n\t */\n\tasync destroy(): Promise<void> {\n\t\tif (this.client) {\n\t\t\tawait this.client.close();\n\t\t}\n\t\tawait super.destroy();\n\t}\n}\n"]}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC","sourcesContent":["/**\n * Google Cloud Text-to-Speech server-side TTS provider\n * @module @pie-players/tts-server-google\n */\n\nexport type { GoogleCloudTTSConfig } from \"./GoogleCloudTTSProvider.js\";\nexport { GoogleCloudTTSProvider } from \"./GoogleCloudTTSProvider.js\";\n"]}