UNPKG

web-speech-profanity

Version:

Web Speech API adapter to use Cognitive Services Speech Services for both speech-to-text and text-to-speech service.

20 lines (16 loc) 494 B
const TOKEN_URL_TEMPLATE = 'https://{region}.api.cognitive.microsoft.com/sts/v1.0/issueToken'; export default async function ({ region, subscriptionKey }) { const res = await fetch( TOKEN_URL_TEMPLATE.replace(/\{region\}/u, region), { headers: { 'Ocp-Apim-Subscription-Key': subscriptionKey }, method: 'POST' } ); if (!res.ok) { throw new Error(`Failed to fetch authorization token, server returned ${res.status}`); } return res.text(); }