跳转到内容

@ottervoice/provider-azure-speech

Documentation


Documentation / @ottervoice/provider-azure-speech

Azure Cognitive Services text-to-speech provider for OtterVoice, using REST and SSML.

Terminal window
npm install @ottervoice/core @ottervoice/provider-azure-speech
import { 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.

Documentation · GitHub

MIT

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).

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

Defined in: provider-azure-speech/src/ssml.ts:56

Default voice / language when TTSInput omits them.

Property Type Description Defined in
language string BCP-47 language for the <voice xml:lang> attribute. provider-azure-speech/src/ssml.ts:60
voice string Azure neural voice name (e.g. zh-CN-XiaoxiaoNeural). provider-azure-speech/src/ssml.ts:58
function azureOutputFormat(format): string;

Defined in: provider-azure-speech/src/ssml.ts:26

Map a core TTSFormat to an Azure X-Microsoft-OutputFormat value.

Parameter Type Description
format TTSFormat OtterVoice TTS format.

string

Azure output-format header value.


function buildSSML(input, defaults): string;

Defined in: provider-azure-speech/src/ssml.ts:69

Build an SSML document for a synthesis request.

Parameter Type Description
input TTSInput Text plus optional voice / rate / pitch overrides.
defaults SSMLOptions Adapter defaults when input omits voice or language.

string


function createAzureTTS(options): TTSProvider;

Defined in: provider-azure-speech/src/index.ts:59

Azure Cognitive Services Text-to-Speech provider (REST + SSML).

Parameter Type Description
options AzureTTSOptions Region, voice, and credentials (subscriptionKey or broker).

TTSProvider


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.

Parameter Type
text string

string


function mimeTypeForFormat(format): string;

Defined in: provider-azure-speech/src/ssml.ts:35

MIME type for a synthesized TTSFormat.

Parameter Type Description
format TTSFormat OtterVoice TTS format.

string


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.

Parameter Type
speed number

string