ssml-builder-js 2.7.0 → 2.8.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.
package/dist/index.mjs CHANGED
@@ -3,12 +3,13 @@ import {
3
3
  buildPartialSsml,
4
4
  buildSsml,
5
5
  extractSsmlText,
6
+ isValidAzureAudioDuration,
6
7
  mapSsmlTextNodes,
7
8
  normalizeAzureLanguage,
8
9
  parseSsml,
9
10
  validateAzureSsml,
10
11
  validateSsml
11
- } from "./chunk-D6ITDU3A.mjs";
12
+ } from "./chunk-VCDMKVVT.mjs";
12
13
  import {
13
14
  __privateAdd,
14
15
  __privateGet,
@@ -204,6 +205,7 @@ export {
204
205
  buildPartialSsml,
205
206
  buildSsml,
206
207
  extractSsmlText,
208
+ isValidAzureAudioDuration,
207
209
  mapSsmlTextNodes,
208
210
  normalizeAzureLanguage,
209
211
  parseSsml,
@@ -1 +1 @@
1
- {"version":3,"sources":["../packages/azure-tts-client/src/errors.ts","../packages/azure-tts-client/src/synthesis.ts","../packages/azure-tts-client/src/speechConfig.ts","../packages/azure-tts-client/src/outputFormats.ts","../packages/azure-tts-client/src/client.ts"],"sourcesContent":["export class AzureTtsError extends Error {\n readonly status: number;\n readonly statusText: string;\n readonly responseBody: string;\n readonly requestId: string | null;\n\n constructor(status: number, statusText: string, responseBody: string, requestId: string | null) {\n super(`Azure TTS request failed: ${status} ${statusText}`);\n this.name = \"AzureTtsError\";\n this.status = status;\n this.statusText = statusText;\n this.responseBody = responseBody;\n this.requestId = requestId;\n }\n}\n\nexport class AzureTtsSdkError extends AzureTtsError {\n readonly errorDetails: string;\n\n constructor(errorDetails: string) {\n super(0, \"Speech SDK\", errorDetails, null);\n this.name = \"AzureTtsSdkError\";\n this.message = `Azure TTS synthesis failed: ${errorDetails}`;\n this.errorDetails = errorDetails;\n }\n}\n\nexport function createSpeechSdkError(error: unknown): AzureTtsSdkError {\n const message = error instanceof Error ? error.message : String(error);\n return new AzureTtsSdkError(message);\n}\n","import * as SpeechSDK from \"microsoft-cognitiveservices-speech-sdk\";\nimport { createSpeechSdkError } from \"./errors.ts\";\nimport { createSpeechConfig } from \"./speechConfig.ts\";\nimport type { TtsConfig } from \"./types.ts\";\n\nfunction closeSpeechResources(speechConfig: SpeechSDK.SpeechConfig, synthesizer: SpeechSDK.SpeechSynthesizer): void {\n try {\n synthesizer.close();\n } catch {}\n\n try {\n speechConfig.close();\n } catch {}\n}\n\nexport async function synthesizeSpeech(ssml: string, config: TtsConfig): Promise<ArrayBuffer> {\n if (config.signal?.aborted) {\n throw createSpeechSdkError(\"Speech synthesis was cancelled.\");\n }\n\n const speechConfig = createSpeechConfig(config);\n const synthesizer = new SpeechSDK.SpeechSynthesizer(speechConfig, null);\n\n return await new Promise<ArrayBuffer>((resolve, reject) => {\n let resourcesClosed = false;\n let settled = false;\n let timeout: ReturnType<typeof setTimeout> | undefined;\n let abortHandler: (() => void) | undefined;\n const cleanup = () => {\n if (timeout) clearTimeout(timeout);\n if (abortHandler) config.signal?.removeEventListener(\"abort\", abortHandler);\n };\n const closeResources = () => {\n if (resourcesClosed) return;\n resourcesClosed = true;\n closeSpeechResources(speechConfig, synthesizer);\n };\n const rejectWithError = (error: unknown) => {\n if (settled) return;\n settled = true;\n cleanup();\n closeResources();\n reject(createSpeechSdkError(error));\n };\n\n const cb = (result: SpeechSDK.SpeechSynthesisResult) => {\n if (settled) return;\n const { reason, errorDetails } = result;\n if (reason !== SpeechSDK.ResultReason.SynthesizingAudioCompleted) {\n const err = errorDetails || `Speech synthesis failed with reason ${reason}.`;\n rejectWithError(err);\n return;\n }\n settled = true;\n cleanup();\n closeResources();\n resolve(result.audioData);\n };\n\n try {\n if (config.signal) {\n abortHandler = () => rejectWithError(\"Speech synthesis was cancelled.\");\n config.signal.addEventListener(\"abort\", abortHandler, { once: true });\n }\n if (config.timeoutMs !== undefined && config.timeoutMs > 0) {\n timeout = setTimeout(\n () => rejectWithError(`Speech synthesis timed out after ${config.timeoutMs} ms.`),\n config.timeoutMs,\n );\n }\n synthesizer.speakSsmlAsync(ssml, cb, rejectWithError);\n } catch (error) {\n rejectWithError(error);\n }\n });\n}\n","import { SpeechConfig } from \"microsoft-cognitiveservices-speech-sdk\";\nimport { DEFAULT_OUTPUT_FORMAT, resolveOutputFormat } from \"./outputFormats.ts\";\nimport type { TtsConfig } from \"./types.ts\";\n\nexport function resolveEndpoint(config: TtsConfig): string {\n const endpoint = config.endpoint?.trim() || \"https://{region}.tts.speech.microsoft.com/cognitiveservices/v1\";\n return endpoint.replace(/\\{region\\}/g, encodeURIComponent(config.region));\n}\n\nexport function createSpeechConfig(config: TtsConfig): SpeechConfig {\n const { outputFormat = DEFAULT_OUTPUT_FORMAT, subscriptionKey } = config;\n\n const endpoint = new URL(resolveEndpoint(config));\n const speechConfig = SpeechConfig.fromEndpoint(endpoint, subscriptionKey);\n speechConfig.speechSynthesisOutputFormat = resolveOutputFormat(outputFormat);\n return speechConfig;\n}\n","import * as SpeechSDK from \"microsoft-cognitiveservices-speech-sdk\";\n\nexport const DEFAULT_OUTPUT_FORMAT = \"audio-16khz-128kbitrate-mono-mp3\";\n\nconst OUTPUT_FORMATS: Record<string, SpeechSDK.SpeechSynthesisOutputFormat> = {\n \"raw-8khz-8bit-mono-mulaw\": SpeechSDK.SpeechSynthesisOutputFormat.Raw8Khz8BitMonoMULaw,\n \"riff-16khz-16kbps-mono-siren\": SpeechSDK.SpeechSynthesisOutputFormat.Riff16Khz16KbpsMonoSiren,\n \"audio-16khz-16kbps-mono-siren\": SpeechSDK.SpeechSynthesisOutputFormat.Audio16Khz16KbpsMonoSiren,\n \"audio-16khz-32kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio16Khz32KBitRateMonoMp3,\n \"audio-16khz-128kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio16Khz128KBitRateMonoMp3,\n \"audio-16khz-64kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio16Khz64KBitRateMonoMp3,\n \"audio-24khz-48kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio24Khz48KBitRateMonoMp3,\n \"audio-24khz-96kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio24Khz96KBitRateMonoMp3,\n \"audio-24khz-160kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio24Khz160KBitRateMonoMp3,\n \"raw-16khz-16bit-mono-truesilk\": SpeechSDK.SpeechSynthesisOutputFormat.Raw16Khz16BitMonoTrueSilk,\n \"riff-16khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Riff16Khz16BitMonoPcm,\n \"riff-8khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Riff8Khz16BitMonoPcm,\n \"riff-24khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Riff24Khz16BitMonoPcm,\n \"riff-8khz-8bit-mono-mulaw\": SpeechSDK.SpeechSynthesisOutputFormat.Riff8Khz8BitMonoMULaw,\n \"raw-16khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Raw16Khz16BitMonoPcm,\n \"raw-24khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Raw24Khz16BitMonoPcm,\n \"raw-8khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Raw8Khz16BitMonoPcm,\n \"ogg-16khz-16bit-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Ogg16Khz16BitMonoOpus,\n \"ogg-24khz-16bit-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Ogg24Khz16BitMonoOpus,\n \"raw-48khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Raw48Khz16BitMonoPcm,\n \"riff-48khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Riff48Khz16BitMonoPcm,\n \"audio-48khz-96kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio48Khz96KBitRateMonoMp3,\n \"audio-48khz-192kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio48Khz192KBitRateMonoMp3,\n \"ogg-48khz-16bit-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Ogg48Khz16BitMonoOpus,\n \"webm-16khz-16bit-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Webm16Khz16BitMonoOpus,\n \"webm-24khz-16bit-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Webm24Khz16BitMonoOpus,\n \"webm-24khz-16bit-24kbps-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Webm24Khz16Bit24KbpsMonoOpus,\n \"raw-24khz-16bit-mono-truesilk\": SpeechSDK.SpeechSynthesisOutputFormat.Raw24Khz16BitMonoTrueSilk,\n \"raw-8khz-8bit-mono-alaw\": SpeechSDK.SpeechSynthesisOutputFormat.Raw8Khz8BitMonoALaw,\n \"riff-8khz-8bit-mono-alaw\": SpeechSDK.SpeechSynthesisOutputFormat.Riff8Khz8BitMonoALaw,\n \"audio-16khz-16bit-32kbps-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Audio16Khz16Bit32KbpsMonoOpus,\n \"audio-24khz-16bit-48kbps-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Audio24Khz16Bit48KbpsMonoOpus,\n \"audio-24khz-16bit-24kbps-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Audio24Khz16Bit24KbpsMonoOpus,\n \"raw-22050hz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Raw22050Hz16BitMonoPcm,\n \"riff-22050hz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Riff22050Hz16BitMonoPcm,\n \"raw-44100hz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Raw44100Hz16BitMonoPcm,\n \"riff-44100hz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Riff44100Hz16BitMonoPcm,\n \"amr-wb-16000hz\": SpeechSDK.SpeechSynthesisOutputFormat.AmrWb16000Hz,\n \"g722-16khz-64kbps\": SpeechSDK.SpeechSynthesisOutputFormat.G72216Khz64Kbps,\n};\n\nexport function resolveOutputFormat(outputFormat: string): SpeechSDK.SpeechSynthesisOutputFormat {\n const resolvedFormat = OUTPUT_FORMATS[outputFormat];\n if (resolvedFormat === undefined) {\n throw new Error(`Unsupported Azure Speech output format: ${outputFormat}`);\n }\n\n return resolvedFormat;\n}\n","import { synthesizeSpeech } from \"./synthesis.ts\";\nimport type { AzureTtsClientOptions } from \"./types.ts\";\n\nconst ENDPOINT_TEMPLATE = \"https://{region}.tts.speech.microsoft.com/cognitiveservices/v1\";\n\nexport class AzureTtsClient {\n readonly #options: AzureTtsClientOptions;\n\n constructor(options: AzureTtsClientOptions) {\n this.#options = options;\n }\n\n async synthesize(ssml: string): Promise<ArrayBuffer> {\n const { region, subscriptionKey, outputFormat, signal, timeoutMs } = this.#options;\n const endpoint = this.#options.endpoint?.trim() || ENDPOINT_TEMPLATE.replace(\"{region}\", region);\n this.#options.logger?.debug?.(\"Using Azure TTS endpoint:\", endpoint);\n\n const config = { endpoint, region, subscriptionKey, outputFormat, signal, timeoutMs };\n return synthesizeSpeech(ssml, config);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAMvC,YAAY,QAAgB,YAAoB,cAAsB,WAA0B;AAC9F,UAAM,6BAA6B,MAAM,IAAI,UAAU,EAAE;AACzD,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,aAAa;AAClB,SAAK,eAAe;AACpB,SAAK,YAAY;AAAA,EACnB;AACF;AAEO,IAAM,mBAAN,cAA+B,cAAc;AAAA,EAGlD,YAAY,cAAsB;AAChC,UAAM,GAAG,cAAc,cAAc,IAAI;AACzC,SAAK,OAAO;AACZ,SAA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AM,WAAW,mBAAK,UAAS,UAAU,KAAK,KAAK,kBAAkB,QAAQ,YAAY,MAAM;AAC/F,uBAAK,UAAS,QAAQ,QAAQ,6BAA6B,QAAQ;AAEnE,UAAM,SAAS,EAAE,UAAU,QAAQ,iBAAiB,cAAc,QAAQ,UAAU;AACpF,WAAO,iBAAiB,MAAM,MAAM;AAAA,EACtC;AACF;AAdW;","names":["SpeechSDK"]}
1
+ {"version":3,"sources":["../packages/azure-tts-client/src/errors.ts","../packages/azure-tts-client/src/synthesis.ts","../packages/azure-tts-client/src/speechConfig.ts","../packages/azure-tts-client/src/outputFormats.ts","../packages/azure-tts-client/src/client.ts"],"sourcesContent":["export class AzureTtsError extends Error {\n readonly status: number;\n readonly statusText: string;\n readonly responseBody: string;\n readonly requestId: string | null;\n\n constructor(status: number, statusText: string, responseBody: string, requestId: string | null) {\n super(`Azure TTS request failed: ${status} ${statusText}`);\n this.name = \"AzureTtsError\";\n this.status = status;\n this.statusText = statusText;\n this.responseBody = responseBody;\n this.requestId = requestId;\n }\n}\n\nexport class AzureTtsSdkError extends AzureTtsError {\n readonly errorDetails: string;\n\n constructor(errorDetails: string) {\n super(0, \"Speech SDK\", errorDetails, null);\n this.name = \"AzureTtsSdkError\";\n this.message = `Azure TTS synthesis failed: ${errorDetails}`;\n this.errorDetails = errorDetails;\n }\n}\n\nexport function createSpeechSdkError(error: unknown): AzureTtsSdkError {\n const message = error instanceof Error ? error.message : String(error);\n return new AzureTtsSdkError(message);\n}\n","import * as SpeechSDK from \"microsoft-cognitiveservices-speech-sdk\";\nimport { createSpeechSdkError } from \"./errors.ts\";\nimport { createSpeechConfig } from \"./speechConfig.ts\";\nimport type { TtsConfig } from \"./types.ts\";\n\nfunction closeSpeechResources(speechConfig: SpeechSDK.SpeechConfig, synthesizer: SpeechSDK.SpeechSynthesizer): void {\n try {\n synthesizer.close();\n } catch {}\n\n try {\n speechConfig.close();\n } catch {}\n}\n\nexport async function synthesizeSpeech(ssml: string, config: TtsConfig): Promise<ArrayBuffer> {\n if (config.signal?.aborted) {\n throw createSpeechSdkError(\"Speech synthesis was cancelled.\");\n }\n\n const speechConfig = createSpeechConfig(config);\n const synthesizer = new SpeechSDK.SpeechSynthesizer(speechConfig, null);\n\n return await new Promise<ArrayBuffer>((resolve, reject) => {\n let resourcesClosed = false;\n let settled = false;\n let timeout: ReturnType<typeof setTimeout> | undefined;\n let abortHandler: (() => void) | undefined;\n const cleanup = () => {\n if (timeout) clearTimeout(timeout);\n if (abortHandler) config.signal?.removeEventListener(\"abort\", abortHandler);\n };\n const closeResources = () => {\n if (resourcesClosed) return;\n resourcesClosed = true;\n closeSpeechResources(speechConfig, synthesizer);\n };\n const rejectWithError = (error: unknown) => {\n if (settled) return;\n settled = true;\n cleanup();\n closeResources();\n reject(createSpeechSdkError(error));\n };\n\n const cb = (result: SpeechSDK.SpeechSynthesisResult) => {\n if (settled) return;\n const { reason, errorDetails } = result;\n if (reason !== SpeechSDK.ResultReason.SynthesizingAudioCompleted) {\n const err = errorDetails || `Speech synthesis failed with reason ${reason}.`;\n rejectWithError(err);\n return;\n }\n settled = true;\n cleanup();\n closeResources();\n resolve(result.audioData);\n };\n\n try {\n if (config.signal) {\n abortHandler = () => rejectWithError(\"Speech synthesis was cancelled.\");\n config.signal.addEventListener(\"abort\", abortHandler, { once: true });\n }\n if (config.timeoutMs !== undefined && config.timeoutMs > 0) {\n timeout = setTimeout(\n () => rejectWithError(`Speech synthesis timed out after ${config.timeoutMs} ms.`),\n config.timeoutMs,\n );\n }\n synthesizer.speakSsmlAsync(ssml, cb, rejectWithError);\n } catch (error) {\n rejectWithError(error);\n }\n });\n}\n","import { SpeechConfig } from \"microsoft-cognitiveservices-speech-sdk\";\nimport { DEFAULT_OUTPUT_FORMAT, resolveOutputFormat } from \"./outputFormats.ts\";\nimport type { TtsConfig } from \"./types.ts\";\n\nexport function resolveEndpoint(config: TtsConfig): string {\n const endpoint = config.endpoint?.trim() || \"https://{region}.tts.speech.microsoft.com/cognitiveservices/v1\";\n return endpoint.replace(/\\{region\\}/g, encodeURIComponent(config.region));\n}\n\nexport function createSpeechConfig(config: TtsConfig): SpeechConfig {\n const { outputFormat = DEFAULT_OUTPUT_FORMAT, subscriptionKey } = config;\n\n const endpoint = new URL(resolveEndpoint(config));\n const speechConfig = SpeechConfig.fromEndpoint(endpoint, subscriptionKey);\n speechConfig.speechSynthesisOutputFormat = resolveOutputFormat(outputFormat);\n return speechConfig;\n}\n","import * as SpeechSDK from \"microsoft-cognitiveservices-speech-sdk\";\n\nexport const DEFAULT_OUTPUT_FORMAT = \"audio-16khz-128kbitrate-mono-mp3\";\n\nconst OUTPUT_FORMATS: Record<string, SpeechSDK.SpeechSynthesisOutputFormat> = {\n \"raw-8khz-8bit-mono-mulaw\": SpeechSDK.SpeechSynthesisOutputFormat.Raw8Khz8BitMonoMULaw,\n \"riff-16khz-16kbps-mono-siren\": SpeechSDK.SpeechSynthesisOutputFormat.Riff16Khz16KbpsMonoSiren,\n \"audio-16khz-16kbps-mono-siren\": SpeechSDK.SpeechSynthesisOutputFormat.Audio16Khz16KbpsMonoSiren,\n \"audio-16khz-32kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio16Khz32KBitRateMonoMp3,\n \"audio-16khz-128kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio16Khz128KBitRateMonoMp3,\n \"audio-16khz-64kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio16Khz64KBitRateMonoMp3,\n \"audio-24khz-48kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio24Khz48KBitRateMonoMp3,\n \"audio-24khz-96kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio24Khz96KBitRateMonoMp3,\n \"audio-24khz-160kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio24Khz160KBitRateMonoMp3,\n \"raw-16khz-16bit-mono-truesilk\": SpeechSDK.SpeechSynthesisOutputFormat.Raw16Khz16BitMonoTrueSilk,\n \"riff-16khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Riff16Khz16BitMonoPcm,\n \"riff-8khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Riff8Khz16BitMonoPcm,\n \"riff-24khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Riff24Khz16BitMonoPcm,\n \"riff-8khz-8bit-mono-mulaw\": SpeechSDK.SpeechSynthesisOutputFormat.Riff8Khz8BitMonoMULaw,\n \"raw-16khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Raw16Khz16BitMonoPcm,\n \"raw-24khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Raw24Khz16BitMonoPcm,\n \"raw-8khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Raw8Khz16BitMonoPcm,\n \"ogg-16khz-16bit-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Ogg16Khz16BitMonoOpus,\n \"ogg-24khz-16bit-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Ogg24Khz16BitMonoOpus,\n \"raw-48khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Raw48Khz16BitMonoPcm,\n \"riff-48khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Riff48Khz16BitMonoPcm,\n \"audio-48khz-96kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio48Khz96KBitRateMonoMp3,\n \"audio-48khz-192kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio48Khz192KBitRateMonoMp3,\n \"ogg-48khz-16bit-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Ogg48Khz16BitMonoOpus,\n \"webm-16khz-16bit-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Webm16Khz16BitMonoOpus,\n \"webm-24khz-16bit-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Webm24Khz16BitMonoOpus,\n \"webm-24khz-16bit-24kbps-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Webm24Khz16Bit24KbpsMonoOpus,\n \"raw-24khz-16bit-mono-truesilk\": SpeechSDK.SpeechSynthesisOutputFormat.Raw24Khz16BitMonoTrueSilk,\n \"raw-8khz-8bit-mono-alaw\": SpeechSDK.SpeechSynthesisOutputFormat.Raw8Khz8BitMonoALaw,\n \"riff-8khz-8bit-mono-alaw\": SpeechSDK.SpeechSynthesisOutputFormat.Riff8Khz8BitMonoALaw,\n \"audio-16khz-16bit-32kbps-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Audio16Khz16Bit32KbpsMonoOpus,\n \"audio-24khz-16bit-48kbps-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Audio24Khz16Bit48KbpsMonoOpus,\n \"audio-24khz-16bit-24kbps-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Audio24Khz16Bit24KbpsMonoOpus,\n \"raw-22050hz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Raw22050Hz16BitMonoPcm,\n \"riff-22050hz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Riff22050Hz16BitMonoPcm,\n \"raw-44100hz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Raw44100Hz16BitMonoPcm,\n \"riff-44100hz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Riff44100Hz16BitMonoPcm,\n \"amr-wb-16000hz\": SpeechSDK.SpeechSynthesisOutputFormat.AmrWb16000Hz,\n \"g722-16khz-64kbps\": SpeechSDK.SpeechSynthesisOutputFormat.G72216Khz64Kbps,\n};\n\nexport function resolveOutputFormat(outputFormat: string): SpeechSDK.SpeechSynthesisOutputFormat {\n const resolvedFormat = OUTPUT_FORMATS[outputFormat];\n if (resolvedFormat === undefined) {\n throw new Error(`Unsupported Azure Speech output format: ${outputFormat}`);\n }\n\n return resolvedFormat;\n}\n","import { synthesizeSpeech } from \"./synthesis.ts\";\nimport type { AzureTtsClientOptions } from \"./types.ts\";\n\nconst ENDPOINT_TEMPLATE = \"https://{region}.tts.speech.microsoft.com/cognitiveservices/v1\";\n\nexport class AzureTtsClient {\n readonly #options: AzureTtsClientOptions;\n\n constructor(options: AzureTtsClientOptions) {\n this.#options = options;\n }\n\n async synthesize(ssml: string): Promise<ArrayBuffer> {\n const { region, subscriptionKey, outputFormat, signal, timeoutMs } = this.#options;\n const endpoint = this.#options.endpoint?.trim() || ENDPOINT_TEMPLATE.replace(\"{region}\", region);\n this.#options.logger?.debug?.(\"Using Azure TTS endpoint:\", endpoint);\n\n const config = { endpoint, region, subscriptionKey, outputFormat, signal, timeoutMs };\n return synthesizeSpeech(ssml, config);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAMvC,YAAY,QAAgB,YAAoB,cAAsB,WAA0B;AAC9F,UAAM,6BAA6B,MAAM,IAAI,UAAU,EAAE;AACzD,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,aAAa;AAClB,SAAK,eAAe;AACpB,SAAK,YAAY;AAAA,EACnB;AACF;AAEO,IAAM,mBAAN,cAA+B,cAAc;AAAA,EAGlD,YAAY,cAAsB;AAChC,UAAM,GAAG,cAAc,cAAc,IAAI;AACzC,SAAK,OAAO;AACZ,SAAK,UAAU,+BAA+B,YAAY;AAC1D,SAAK,eAAe;AAAA,EACtB;AACF;AAEO,SAAS,qBAAqB,OAAkC;AACrE,QAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACrE,SAAO,IAAI,iBAAiB,OAAO;AACrC;;;AC9BA,YAAYA,gBAAe;;;ACA3B,SAAS,oBAAoB;;;ACA7B,YAAY,eAAe;AAEpB,IAAM,wBAAwB;AAErC,IAAM,iBAAwE;AAAA,EAC5E,4BAAsC,sC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lElementBase {
103
103
  typeValue?: string;
104
104
  visemeType?: string;
105
105
  }
106
+ interface MsttsAudioDurationElement extends SsmlElementBase {
107
+ type: "mstts:audioduration";
108
+ value?: SsmlAttributeValue;
109
+ }
106
110
  interface CustomElement extends SsmlElementBase {
107
111
  type: "custom" | "element";
108
112
  name: string;
109
113
  }
110
- type SsmlElement = VoiceElement | ProsodyElement | BreakElement | ExpressAsElement | SayAsElement | PhonemeElement | EmphasisElement | AudioElement | SubElement | LangElement | MarkElement | BookmarkElement | LexiconElement | ParagraphElement | SentenceElement | WordElement | MsttsSilenceElement | MsttsVisemeElement | CustomElement;
114
+ type SsmlElement = VoiceElement | ProsodyElement | BreakElement | ExpressAsElement | SayAsElement | PhonemeElement | EmphasisElement | AudioElement | SubElement | LangElement | MarkElement | BookmarkElement | LexiconElement | ParagraphElement | SentenceElement | WordElement | MsttsSilenceElement | MsttsVisemeElement | MsttsAudioDurationElement | CustomElement;
111
115
  interface SsmlDocument {
112
116
  type?: "speak";
113
117
  version: string;
@@ -118,7 +122,7 @@ interface SsmlDocument {
118
122
  attributes?: SsmlAttributes;
119
123
  }
120
124
 
121
- type SsmlEditorInsertionButton = "break" | "emphasis" | "rate" | "pitch" | "volume" | "emotion" | "say-as" | "phoneme" | "audio" | "sub" | "lang" | "mark" | "bookmark" | "mstts:silence" | "mstts:viseme" | (string & {});
125
+ type SsmlEditorInsertionButton = "break" | "emphasis" | "rate" | "pitch" | "volume" | "emotion" | "say-as" | "phoneme" | "audio" | "sub" | "lang" | "mark" | "bookmark" | "mstts:silence" | "mstts:audioduration" | "mstts:viseme" | (string & {});
122
126
  type SsmlEditorButton = "help" | SsmlEditorInsertionButton | "undo" | "redo" | "clearAll" | "format" | "decorations" | (string & {});
123
127
  type SsmlEditorButtonVisibility = Readonly<Partial<Record<string, boolean>>>;
124
128
 
@@ -389,8 +393,8 @@ declare function updateTagAttribute(text: string, tagRange: SsmlTagRange, attrib
389
393
 
390
394
  type SsmlCodeLensAction = {
391
395
  type: "attribute";
392
- insertionId: "rate" | "pitch" | "break";
393
- attributeName: "rate" | "pitch" | "time";
396
+ insertionId: "rate" | "pitch" | "break" | "mstts:audioduration";
397
+ attributeName: "rate" | "pitch" | "time" | "value";
394
398
  tagRange: SsmlTagRange;
395
399
  } | {
396
400
  type: "unwrap" | "delete";
package/dist/react.d.ts CHANGED
@@ -103,11 +103,15 @@ interface MsttsVisemeElement extends SsmlElementBase {
103
103
  typeValue?: string;
104
104
  visemeType?: string;
105
105
  }
106
+ interface MsttsAudioDurationElement extends SsmlElementBase {
107
+ type: "mstts:audioduration";
108
+ value?: SsmlAttributeValue;
109
+ }
106
110
  interface CustomElement extends SsmlElementBase {
107
111
  type: "custom" | "element";
108
112
  name: string;
109
113
  }
110
- type SsmlElement = VoiceElement | ProsodyElement | BreakElement | ExpressAsElement | SayAsElement | PhonemeElement | EmphasisElement | AudioElement | SubElement | LangElement | MarkElement | BookmarkElement | LexiconElement | ParagraphElement | SentenceElement | WordElement | MsttsSilenceElement | MsttsVisemeElement | CustomElement;
114
+ type SsmlElement = VoiceElement | ProsodyElement | BreakElement | ExpressAsElement | SayAsElement | PhonemeElement | EmphasisElement | AudioElement | SubElement | LangElement | MarkElement | BookmarkElement | LexiconElement | ParagraphElement | SentenceElement | WordElement | MsttsSilenceElement | MsttsVisemeElement | MsttsAudioDurationElement | CustomElement;
111
115
  interface SsmlDocument {
112
116
  type?: "speak";
113
117
  version: string;
@@ -118,7 +122,7 @@ interface SsmlDocument {
118
122
  attributes?: SsmlAttributes;
119
123
  }
120
124
 
121
- type SsmlEditorInsertionButton = "break" | "emphasis" | "rate" | "pitch" | "volume" | "emotion" | "say-as" | "phoneme" | "audio" | "sub" | "lang" | "mark" | "bookmark" | "mstts:silence" | "mstts:viseme" | (string & {});
125
+ type SsmlEditorInsertionButton = "break" | "emphasis" | "rate" | "pitch" | "volume" | "emotion" | "say-as" | "phoneme" | "audio" | "sub" | "lang" | "mark" | "bookmark" | "mstts:silence" | "mstts:audioduration" | "mstts:viseme" | (string & {});
122
126
  type SsmlEditorButton = "help" | SsmlEditorInsertionButton | "undo" | "redo" | "clearAll" | "format" | "decorations" | (string & {});
123
127
  type SsmlEditorButtonVisibility = Readonly<Partial<Record<string, boolean>>>;
124
128
 
@@ -389,8 +393,8 @@ declare function updateTagAttribute(text: string, tagRange: SsmlTagRange, attrib
389
393
 
390
394
  type SsmlCodeLensAction = {
391
395
  type: "attribute";
392
- insertionId: "rate" | "pitch" | "break";
393
- attributeName: "rate" | "pitch" | "time";
396
+ insertionId: "rate" | "pitch" | "break" | "mstts:audioduration";
397
+ attributeName: "rate" | "pitch" | "time" | "value";
394
398
  tagRange: SsmlTagRange;
395
399
  } | {
396
400
  type: "unwrap" | "delete";
package/dist/react.js CHANGED
@@ -54,6 +54,8 @@ function isSsmlEditorButtonVisible(buttonVisibility, button) {
54
54
  // packages/ssml-editor-react/src/constants/ssmlPresets.ts
55
55
  var ssmlPresets_exports = {};
56
56
  __export(ssmlPresets_exports, {
57
+ AUDIO_DURATION_DESCRIPTIONS: () => AUDIO_DURATION_DESCRIPTIONS,
58
+ AUDIO_DURATION_PRESETS: () => AUDIO_DURATION_PRESETS,
57
59
  BREAK_STRENGTH_PRESETS: () => BREAK_STRENGTH_PRESETS,
58
60
  BREAK_TIME_DESCRIPTIONS: () => BREAK_TIME_DESCRIPTIONS,
59
61
  BREAK_TIME_PRESETS: () => BREAK_TIME_PRESETS,
@@ -86,6 +88,103 @@ __export(ssmlPresets_exports, {
86
88
  getExpressAsStyleCategory: () => getExpressAsStyleCategory,
87
89
  resolveExpressAsStyles: () => resolveExpressAsStyles
88
90
  });
91
+
92
+ // packages/ssml-editor-react/src/constants/azureVoiceStyleMap.generated.ts
93
+ var AZURE_VOICE_STYLE_MAP = {
94
+ "de-DE-ConradNeural": ["cheerful", "sad"],
95
+ "de-DE-KatjaNeural": ["cheerful", "sad"],
96
+ "en-US-AndrewNeural": ["empathetic", "relieved"],
97
+ "en-US-GuyNeural": [
98
+ "angry",
99
+ "cheerful",
100
+ "excited",
101
+ "friendly",
102
+ "hopeful",
103
+ "newscast",
104
+ "sad",
105
+ "shouting",
106
+ "terrified",
107
+ "unfriendly",
108
+ "whispering"
109
+ ],
110
+ "en-US-JennyMultilingualNeural": [
111
+ "cheerful",
112
+ "empathetic",
113
+ "excited",
114
+ "friendly",
115
+ "hopeful",
116
+ "sad",
117
+ "shouting",
118
+ "terrified",
119
+ "unfriendly",
120
+ "whispering"
121
+ ],
122
+ "en-US-JennyNeural": [
123
+ "assistant",
124
+ "chat",
125
+ "customerservice",
126
+ "newscast",
127
+ "cheerful",
128
+ "empathetic",
129
+ "excited",
130
+ "friendly",
131
+ "hopeful",
132
+ "sad",
133
+ "shouting",
134
+ "terrified",
135
+ "unfriendly",
136
+ "whispering"
137
+ ],
138
+ "es-ES-ElviraNeural": [],
139
+ "fil-PH-AngeloNeural": [],
140
+ "fr-FR-DeniseNeural": ["cheerful", "sad"],
141
+ "fr-FR-HenriNeural": ["cheerful", "sad"],
142
+ "id-ID-GadisNeural": [],
143
+ "it-IT-ElsaNeural": ["cheerful", "sad"],
144
+ "ja-JP-KeitaNeural": ["chat"],
145
+ "ja-JP-MayuNeural": ["calm", "cheerful", "sad"],
146
+ "ja-JP-NanamiNeural": ["chat", "customerservice", "cheerful", "whispering", "sad"],
147
+ "ko-KR-SunHiNeural": ["cheerful", "sad"],
148
+ "ms-MY-YasminNeural": [],
149
+ "pt-BR-FranciscaNeural": ["calm"],
150
+ "ru-RU-SvetlanaNeural": ["cheerful", "sad", "angry", "disgruntled", "embarrassed", "fearful"],
151
+ "th-TH-PremwadeeNeural": [],
152
+ "vi-VN-HoaiMyNeural": [],
153
+ "zh-CN-XiaoxiaoNeural": [
154
+ "assistant",
155
+ "chat",
156
+ "customerservice",
157
+ "newscast",
158
+ "cheerful",
159
+ "empathetic",
160
+ "excited",
161
+ "friendly",
162
+ "hopeful",
163
+ "sad",
164
+ "terrified",
165
+ "whispering",
166
+ "poetry-reading",
167
+ "sports_commentary",
168
+ "sports_commentary_excited",
169
+ "story"
170
+ ],
171
+ "zh-CN-YunxiNeural": [
172
+ "narration-relaxed",
173
+ "embarrassed",
174
+ "fearful",
175
+ "sad",
176
+ "disgruntled",
177
+ "serious",
178
+ "angry",
179
+ "depressed",
180
+ "chat",
181
+ "cheerful",
182
+ "assistant"
183
+ ],
184
+ "zh-TW-HsiaoChenNeural": []
185
+ };
186
+
187
+ // packages/ssml-editor-react/src/constants/ssmlPresets.ts
89
188
  var SSML_PRESETS = [
90
189
  {
91
190
  id: "basic",
@@ -185,7 +284,7 @@ function getExpressAsStyleCategory(style) {
185
284
  }
186
285
  return "other";
187
286
  }
188
- var VOICE_STYLE_MAP = {
287
+ var LEGACY_VOICE_STYLE_MAP = {
189
288
  "ja-JP-MayuNeural": ["calm", "cheerful", "sad"],
190
289
  "ja-JP-KeitaNeural": ["chat"],
191
290
  "ja-JP-NanamiNeural": ["chat", "customerservice", "cheerful", "whispering", "sad"],
@@ -271,6 +370,7 @@ var VOICE_STYLE_MAP = {
271
370
  "de-DE-ConradNeural": ["cheerful", "sad"],
272
371
  "ru-RU-SvetlanaNeural": ["cheerful", "sad", "angry", "disgruntled", "embarrassed", "fearful"]
273
372
  };
373
+ var VOICE_STYLE_MAP = Object.keys(AZURE_VOICE_STYLE_MAP).length > 0 ? AZURE_VOICE_STYLE_MAP : LEGACY_VOICE_STYLE_MAP;
274
374
  var VOICE_STYLE_MAP_BY_NORMALIZED_NAME = new Map(
275
375
  Object.entries(VOICE_STYLE_MAP).map(([voiceName, styles]) => [voiceName.toLowerCase(), styles])
276
376
  );
@@ -313,6 +413,7 @@ var SAY_AS_PRESETS = [
313
413
  ];
314
414
  var LANGUAGE_PRESETS = ["ja-JP", "en-US", "de-DE", "fr-FR"];
315
415
  var SILENCE_VALUE_PRESETS = ["300ms", "500ms", "1s"];
416
+ var AUDIO_DURATION_PRESETS = ["5s", "10s", "30s"];
316
417
  var SILENCE_TYPE_PRESETS = [
317
418
  "Leading",
318
419
  "Tailing",
@@ -321,6 +422,11 @@ var SILENCE_TYPE_PRESETS = [
321
422
  "Semicolon",
322
423
  "Enumerationcomma"
323
424
  ];
425
+ var AUDIO_DURATION_DESCRIPTIONS = {
426
+ "5s": { ja: "5\u79D2", en: "5 seconds" },
427
+ "10s": { ja: "10\u79D2", en: "10 seconds" },
428
+ "30s": { ja: "30\u79D2", en: "30 seconds" }
429
+ };
324
430
  var PHONEME_ALPHABET_PRESETS = ["ipa", "sapi", "ups", "x-sampa"];
325
431
  var VISEME_TYPE_PRESETS = ["redlips_front", "FacialExpression"];
326
432
  var SSML_ATTRIBUTE_PRESETS = {
@@ -364,6 +470,9 @@ var SSML_ATTRIBUTE_PRESETS = {
364
470
  type: SILENCE_TYPE_PRESETS,
365
471
  value: SILENCE_VALUE_PRESETS
366
472
  },
473
+ "mstts:audioduration": {
474
+ value: AUDIO_DURATION_PRESETS
475
+ },
367
476
  silence: {
368
477
  type: SILENCE_TYPE_PRESETS,
369
478
  value: SILENCE_VALUE_PRESETS
@@ -910,6 +1019,13 @@ var SSML_HOVER_COPY = {
910
1019
  parameters: {
911
1020
  type: { title: "type", description: "\u30D3\u30BC\u30FC\u30E0\u30A4\u30D9\u30F3\u30C8\u306E\u5F62\u5F0F\u3002" }
912
1021
  }
1022
+ },
1023
+ "mstts:audioduration": {
1024
+ title: "\u97F3\u58F0\u9577",
1025
+ description: "\u5408\u6210\u97F3\u58F0\u306E\u76EE\u6A19\u6642\u9593\u3092\u6307\u5B9A\u3057\u307E\u3059\u3002",
1026
+ parameters: {
1027
+ value: { title: "value", description: "\u76EE\u6A19\u6642\u9593\u3002\u4F8B: `10s`\u3001`5000ms`\u3001`00:00:10`\u3002" }
1028
+ }
913
1029
  }
914
1030
  }
915
1031
  },
@@ -1067,6 +1183,13 @@ var SSML_HOVER_COPY = {
1067
1183
  parameters: {
1068
1184
  type: { title: "type", description: "The viseme event format." }
1069
1185
  }
1186
+ },
1187
+ "mstts:audioduration": {
1188
+ title: "Audio duration",
1189
+ description: "Sets the target duration of synthesized audio.",
1190
+ parameters: {
1191
+ value: { title: "value", description: "The target duration, such as `10s`, `5000ms`, or `00:00:10`." }
1192
+ }
1070
1193
  }
1071
1194
  }
1072
1195
  }
@@ -1570,7 +1693,8 @@ var SSML_TAGS = {
1570
1693
  MSTTS_SILENCE: "mstts:silence",
1571
1694
  SILENCE: "silence",
1572
1695
  MSTTS_VISEME: "mstts:viseme",
1573
- VISEME: "viseme"
1696
+ VISEME: "viseme",
1697
+ MSTTS_AUDIO_DURATION: "mstts:audioduration"
1574
1698
  };
1575
1699
  var SSML_ATTRS = {
1576
1700
  VERSION: "version",
@@ -1697,6 +1821,9 @@ function getAttributes(element) {
1697
1821
  case SSML_TAGS.VISEME:
1698
1822
  addAttribute(attributes, SSML_ATTRS.TYPE, element.typeValue ?? element.visemeType);
1699
1823
  break;
1824
+ case SSML_TAGS.MSTTS_AUDIO_DURATION:
1825
+ addAttribute(attributes, SSML_ATTRS.VALUE, element.value);
1826
+ break;
1700
1827
  case SSML_TAGS.PARAGRAPH:
1701
1828
  case SSML_TAGS.SENTENCE:
1702
1829
  case SSML_TAGS.WORD:
@@ -1721,6 +1848,8 @@ function getTagName(element) {
1721
1848
  case SSML_TAGS.VISEME:
1722
1849
  case SSML_TAGS.MSTTS_VISEME:
1723
1850
  return SSML_TAGS.MSTTS_VISEME;
1851
+ case SSML_TAGS.MSTTS_AUDIO_DURATION:
1852
+ return SSML_TAGS.MSTTS_AUDIO_DURATION;
1724
1853
  case "element":
1725
1854
  case "custom":
1726
1855
  return element.name;
@@ -2253,6 +2382,12 @@ function convertElement(node) {
2253
2382
  if (typeValue !== void 0) element.typeValue = typeValue;
2254
2383
  return finishElement(element, node, attributes);
2255
2384
  }
2385
+ case SSML_TAGS.MSTTS_AUDIO_DURATION: {
2386
+ const element = { type: SSML_TAGS.MSTTS_AUDIO_DURATION };
2387
+ const value = readAttribute(attributes, SSML_ATTRS.VALUE);
2388
+ if (value !== void 0) element.value = value;
2389
+ return finishElement(element, node, attributes);
2390
+ }
2256
2391
  default: {
2257
2392
  const element = {
2258
2393
  name: node.name,
@@ -2433,6 +2568,7 @@ var INTRINSICALLY_EMPTY_ELEMENTS = /* @__PURE__ */ new Set([
2433
2568
  "lexicon",
2434
2569
  "mark",
2435
2570
  "mstts:silence",
2571
+ "mstts:audioduration",
2436
2572
  "mstts:viseme",
2437
2573
  "silence",
2438
2574
  "viseme"
@@ -3278,7 +3414,7 @@ function findSsmlVoiceContext(source, offset) {
3278
3414
  }
3279
3415
 
3280
3416
  // packages/ssml-editor-react/src/hooks/useSsmlEditorState.ts
3281
- var TIMING_INSERTION_TAGS = /* @__PURE__ */ new Set(["break", "mstts:silence"]);
3417
+ var TIMING_INSERTION_TAGS = /* @__PURE__ */ new Set(["break", "mstts:silence", "mstts:audioduration"]);
3282
3418
  var PROSODY_INSERTION_TAGS = /* @__PURE__ */ new Set(["prosody", "mstts:express-as", "voice", "emphasis"]);
3283
3419
  var TEXT_INSERTION_TAGS = /* @__PURE__ */ new Set(["sub", "say-as", "phoneme", "w", "lang"]);
3284
3420
  var EMPTY_SELECTION_OVERLAY = {
@@ -3999,6 +4135,10 @@ var SSML_COMPLETION_SNIPPETS = [
3999
4135
  label: "mstts:express-as",
4000
4136
  insertText: `<mstts:express-as style="cheerful">\${1:text}</mstts:express-as>`
4001
4137
  },
4138
+ {
4139
+ label: "mstts:audioduration",
4140
+ insertText: '<mstts:audioduration value="10s" />'
4141
+ },
4002
4142
  {
4003
4143
  label: "sub",
4004
4144
  insertText: `<sub alias="\${1:\u8AAD\u307F}">\${2:\u6F22\u5B57}</sub>`
@@ -4274,7 +4414,7 @@ function registerSsmlCodeLens(monaco, editor, onOpenPopover) {
4274
4414
  break;
4275
4415
  }
4276
4416
  const tag = source.slice(tagStart, tagEnd + 1);
4277
- const tagName = tag.match(/^<\s*(prosody|break)\b/i)?.[1]?.toLowerCase();
4417
+ const tagName = tag.match(/^<\s*(prosody|break|mstts:audioduration)\b/i)?.[1]?.toLowerCase();
4278
4418
  index = tagEnd + 1;
4279
4419
  if (!tagName) {
4280
4420
  continue;
@@ -4304,7 +4444,22 @@ function registerSsmlCodeLens(monaco, editor, onOpenPopover) {
4304
4444
  elementRange
4305
4445
  })
4306
4446
  );
4307
- } else if (/\/\s*>$/.test(tag)) {
4447
+ } else if (tagName === "mstts:audioduration" && /\/\s*>$/.test(tag)) {
4448
+ lenses.push(
4449
+ createLens(
4450
+ model,
4451
+ tagStart,
4452
+ tagEnd + 1,
4453
+ `\u26A1 Duration: ${getAttributeValue(tag, "value") ?? "default"} (Click to edit)`,
4454
+ { type: "attribute", insertionId: "mstts:audioduration", attributeName: "value", tagRange }
4455
+ ),
4456
+ createLens(model, tagStart, tagEnd + 1, "Delete", {
4457
+ type: "delete",
4458
+ tagRange,
4459
+ elementRange
4460
+ })
4461
+ );
4462
+ } else if (tagName === "break" && /\/\s*>$/.test(tag)) {
4308
4463
  lenses.push(
4309
4464
  createLens(
4310
4465
  model,
@@ -4640,6 +4795,17 @@ var SSML_TAG_DEFINITIONS = [
4640
4795
  values: VISEME_TYPE_PRESETS2
4641
4796
  }
4642
4797
  ]
4798
+ },
4799
+ {
4800
+ name: "mstts:audioduration",
4801
+ description: "Sets the target duration of synthesized audio.",
4802
+ parameters: [
4803
+ {
4804
+ name: "value",
4805
+ description: "The target duration, such as `10s`, `5000ms`, or `00:00:10`.",
4806
+ example: "10s"
4807
+ }
4808
+ ]
4643
4809
  }
4644
4810
  ];
4645
4811
  var definitionsByName = /* @__PURE__ */ new Map();
@@ -5246,7 +5412,7 @@ function useSsmlMonaco({
5246
5412
 
5247
5413
  // packages/ssml-editor-react/src/SsmlEditor.tsx
5248
5414
  var UNGROUPED_TOOLBAR_GROUP = "__ssml-editor-ungrouped__";
5249
- var TIMING_POPOVER_TAGS = /* @__PURE__ */ new Set(["break", "mstts:silence"]);
5415
+ var TIMING_POPOVER_TAGS = /* @__PURE__ */ new Set(["break", "mstts:silence", "mstts:audioduration"]);
5250
5416
  var PROSODY_POPOVER_TAGS = /* @__PURE__ */ new Set(["prosody", "mstts:express-as", "voice", "emphasis"]);
5251
5417
  var TEXT_POPOVER_TAGS = /* @__PURE__ */ new Set(["sub", "say-as", "phoneme", "w", "lang"]);
5252
5418
  function localizedText(value) {
@@ -5474,13 +5640,34 @@ var SSML_INSERTIONS = [
5474
5640
  suffix: "",
5475
5641
  mode: "insert"
5476
5642
  })
5643
+ },
5644
+ {
5645
+ id: "mstts:audioduration",
5646
+ icon: "\u25F7",
5647
+ tagName: "mstts:audioduration",
5648
+ selfClosing: true,
5649
+ labels: { ja: "\u97F3\u58F0\u9577", en: "Audio duration" },
5650
+ descriptions: {
5651
+ ja: "\u5408\u6210\u97F3\u58F0\u306E\u76EE\u6A19\u6642\u9593\u3092\u6307\u5B9A\u3057\u307E\u3059\u3002",
5652
+ en: "Sets the target duration of synthesized audio."
5653
+ },
5654
+ parameterDescription: {
5655
+ ja: "\u76EE\u6A19\u6642\u9593\u3092\u9078\u629E\u3057\u307E\u3059\u3002",
5656
+ en: "Selects the target duration."
5657
+ },
5658
+ options: createInsertionOptions(AUDIO_DURATION_PRESETS, AUDIO_DURATION_DESCRIPTIONS),
5659
+ createTemplate: (value) => ({
5660
+ prefix: `<mstts:audioduration value="${value}"/>`,
5661
+ suffix: "",
5662
+ mode: "insert"
5663
+ })
5477
5664
  }
5478
5665
  ];
5479
5666
  var DEFAULT_INSERTION_GROUPS = [
5480
5667
  {
5481
5668
  id: "pauses",
5482
5669
  labels: { ja: "\u9593\u30FB\u7121\u97F3", en: "Pauses" },
5483
- insertionIds: ["break", "mstts:silence"]
5670
+ insertionIds: ["break", "mstts:silence", "mstts:audioduration"]
5484
5671
  },
5485
5672
  {
5486
5673
  id: "prosody",