Logo

Azure

Orate supports Azure's speech and transcription services.

Azure Cognitive Services by Microsoft are a collection of artificial intelligence (AI) APIs that help developers create applications with advanced AI capabilities. These services are available on Microsoft Azure, a cloud computing platform.

Setup

The Azure provider is available by default in Orate. To import it, you can use the following code:

import { Azure } from 'orate/azure';

Configuration

You can use Azure by creating a new instance of the Azure class:

const azure = new Azure();

This will use the AZURE_API_KEY and AZURE_REGION environment variables. If you don't have these variables set, you can pass your keys as an argument to the constructor.

const azure = new Azure({
  apiKey: 'your_api_key',
  region: 'your_region',
});

Usage

The Azure provider provides a single interface for all of Azure's speech and transcription services.

Text to Speech

The Azure provider provides a tts function that allows you to create a text-to-speech synthesis function using Azure Speech Service.

import { speak } from 'orate';
import { Azure } from 'orate/azure';
 
const speech = await speak({
  model: new Azure().tts(),
  prompt: 'Hello, world!',
});

You can specify the voice to use by passing it as an argument to the tts function.

const speech = await speak({
  model: new Azure().tts('en-US-AriaNeural'),
  prompt: 'Hello, world!',
});

You can also stream the speech.

const speech = await speak({
  model: new Azure().tts(),
  prompt: 'Hello, world!',
  stream: true,
});

Speech to Text

The Azure provider provides a stt function that allows you to create a speech-to-text transcription function using Azure Speech Service.

import { transcribe } from 'orate';
import { Azure } from 'orate/azure';
 
const text = await transcribe({
  model: new Azure().stt(),
  audio: new File(...),
});

You can also stream the transcription.

const text = await transcribe({
  model: new Azure().stt(),
  audio: new File(...),
  stream: true,
});

On this page