šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

@restackio/integrations-azurespeech

Package Overview
Dependencies
Maintainers
0
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@restackio/integrations-azurespeech

This package provides an integration for Azure Speech services with Restack, allowing easy text-to-speech conversion using Microsoft's Cognitive Services.

0.0.10
latest
npm
Version published
Maintainers
0
Created
Source

Azure Speech Integration for Restack

This package provides an integration for Azure Speech services with Restack, allowing easy text-to-speech conversion using Microsoft's Cognitive Services.

Installation

To install the package, use npm or yarn:

npm install @restackio/integrations-azurespeech

Configuration

Before using the Azure Speech integration, you need to set up your Azure credentials. You can do this by setting environment variables or passing them directly to the functions.

  • Set up environment variables:
AZURE_SPEECH_API_KEY=your_azure_speech_api_key
AZURE_SPEECH_REGION=your_azure_speech_region
  • Or pass them directly when calling the functions (see Usage section).

Usage

Starting the Azure Speech Service

To start the Azure Speech service, use the azureSpeechService function:

// services.ts
import Restack from "@restackio/ai";
import { azureSpeechService } from "@restackio/integrations-azurespeech";

export async function services() {
  const client = new Restack();
  azureSpeechService({ client }).catch((err) => {
    console.error("Error starting Azure Speech service:", err);
  });
}

services().catch((err) => {
  console.error("Error running services:", err);
});

Using the Azure Speech Function

The main function provided by this integration is azureSpeech. Here's how to use it inside a workflow as part of one of its steps:

/// workflows/createRelease.ts

import { log, step } from "@restackio/ai/workflow";
import * as azureFunctions from "@restackio/integrations-azurespeech/functions";
import { azureSpeechTaskQueue } from "@restackio/integrations-azurespeech/taskQueue";

export async function azureSpeechWorkflow() {
  const result = await step<typeof azureFunctions>({
    taskQueue: azureSpeechTaskQueue,
  }).azureSpeech({
    text: "Hello, world!",
    config: {
      voiceName: "en-US-DavisNeural",
      format: sdk.SpeechSynthesisOutputFormat.Audio16Khz32KBitRateMonoMp3,
    },
    apiKey: "your_azure_speech_api_key", // Optional if set in environment variables
    region: "your_azure_speech_region", // Optional if set in environment variables
  });
  log.info("result", { result: result.media.payload }); // Base64 encoded audio data
  return result;
}

FAQs

Package last updated on 09 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts