@ottervoice/provider-azure-speech
Documentation / @ottervoice/provider-azure-speech
@ottervoice/provider-azure-speech
Section titled “@ottervoice/provider-azure-speech”Azure Cognitive Services text-to-speech provider for OtterVoice, using REST and SSML.
Install
Section titled “Install”npm install @ottervoice/core @ottervoice/provider-azure-speechimport { createAzureTTS } from '@ottervoice/provider-azure-speech';
const tts = createAzureTTS({ region: 'eastus', voice: 'en-US-AvaMultilingualNeural', tokenBrokerUrl: '/api/voice-token',});Use tokenBrokerUrl in browser and mobile apps so Azure credentials remain on
your server. subscriptionKey is available for trusted server-side code.
License
Section titled “License”MIT
Interfaces
Section titled “Interfaces”AzureTTSOptions
Section titled “AzureTTSOptions”Defined in: provider-azure-speech/src/index.ts:30
Options for createAzureTTS. Region and neural voice are required;
authenticate with subscriptionKey (server) or tokenBrokerUrl (client-safe).
Shares broker/fetch fields from CredentialOptions (use subscriptionKey
instead of apiKey).
Extends
Section titled “Extends”Omit<CredentialOptions,"apiKey">
Properties
Section titled “Properties”| Property | Type | Description | Inherited from | Defined in |
|---|---|---|---|---|
defaultFormat? |
TTSFormat |
Default audio container when the request omits format. |
- | provider-azure-speech/src/index.ts:40 |
endpoint? |
string |
Override the synthesis endpoint (defaults to the region host). | - | provider-azure-speech/src/index.ts:42 |
fetch? |
FetchLike |
Custom fetch implementation (tests / React Native polyfills). |
Omit.fetch |
provider-utils/dist/credential.d.ts:39 |
language? |
string |
BCP-47 language tag for SSML. Defaults to en-US. |
- | provider-azure-speech/src/index.ts:38 |
now? |
() => number |
Clock override for deterministic expiry checks in tests. | Omit.now |
provider-utils/dist/credential.d.ts:41 |
region |
string |
Azure region, e.g. eastus. |
- | provider-azure-speech/src/index.ts:32 |
subscriptionKey? |
string |
Subscription key (server-side). Mutually exclusive with tokenBrokerUrl. |
- | provider-azure-speech/src/index.ts:34 |
tokenBrokerUrl? |
string |
Endpoint that mints short-lived tokens (client-safe). | Omit.tokenBrokerUrl |
provider-utils/dist/credential.d.ts:37 |
voice |
string |
Neural voice name, e.g. zh-CN-XiaoxiaoNeural. |
- | provider-azure-speech/src/index.ts:36 |
SSMLOptions
Section titled “SSMLOptions”Defined in: provider-azure-speech/src/ssml.ts:56
Default voice / language when TTSInput omits them.
Properties
Section titled “Properties”Functions
Section titled “Functions”azureOutputFormat()
Section titled “azureOutputFormat()”function azureOutputFormat(format): string;Defined in: provider-azure-speech/src/ssml.ts:26
Map a core TTSFormat to an Azure X-Microsoft-OutputFormat value.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
format |
TTSFormat |
OtterVoice TTS format. |
Returns
Section titled “Returns”string
Azure output-format header value.
buildSSML()
Section titled “buildSSML()”function buildSSML(input, defaults): string;Defined in: provider-azure-speech/src/ssml.ts:69
Build an SSML document for a synthesis request.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
input |
TTSInput |
Text plus optional voice / rate / pitch overrides. |
defaults |
SSMLOptions |
Adapter defaults when input omits voice or language. |
Returns
Section titled “Returns”string
createAzureTTS()
Section titled “createAzureTTS()”function createAzureTTS(options): TTSProvider;Defined in: provider-azure-speech/src/index.ts:59
Azure Cognitive Services Text-to-Speech provider (REST + SSML).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options |
AzureTTSOptions |
Region, voice, and credentials (subscriptionKey or broker). |
Returns
Section titled “Returns”escapeXml()
Section titled “escapeXml()”function escapeXml(text): string;Defined in: provider-azure-speech/src/ssml.ts:40
Escape the five XML predefined entities so user text is SSML-safe.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
text |
string |
Returns
Section titled “Returns”string
mimeTypeForFormat()
Section titled “mimeTypeForFormat()”function mimeTypeForFormat(format): string;Defined in: provider-azure-speech/src/ssml.ts:35
MIME type for a synthesized TTSFormat.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
format |
TTSFormat |
OtterVoice TTS format. |
Returns
Section titled “Returns”string
ratePercent()
Section titled “ratePercent()”function ratePercent(speed): string;Defined in: provider-azure-speech/src/ssml.ts:50
Convert a 0.5–2.0 multiplier into an Azure prosody rate percentage.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
speed |
number |
Returns
Section titled “Returns”string