#Hello. How do I do voice streaming using ElevenLabs and OpenAI in typescript?
1 messages · Page 1 of 1 (latest)
I'm sorry, but the information provided does not include a guide on how to do voice streaming using ElevenLabs and OpenAI in TypeScript. However, I can provide you with a guide on how to send an AI-generated message through a phone call using ElevenLabs and Twilio in Node.js.
First, you need to create accounts with Twilio and ngrok. You can do this by visiting their respective websites:
Next, you can get the entire code for this guide on GitHub.
To create the server with Express, you need to initialize your project, install dependencies, install dev dependencies, and create your files. Here's a sample code snippet to create your files:
// src/app.ts
import 'dotenv/config';
import express, { Response } from 'express';
import ExpressWs from 'express-ws';
import VoiceResponse from 'twilio/lib/twiml/VoiceResponse';
import { ElevenLabsClient } from 'elevenlabs';
import { type WebSocket } from 'ws';
import { type Readable } from 'stream';
const app = ExpressWs(express()).app;
const PORT: number = parseInt(process.env.PORT || '5000');
const elevenlabs = new ElevenLabsClient();
const voiceId = '21m00Tcm4TlvDq8ikWAM';
const outputFormat = 'ulaw_8000';
const text = 'This is a test. You can now hang up. Thank you.';
...
You also need to understand the code, handle the incoming call, create the text to speech, and send the message. After that, you need to point ngrok to your application, update your environment variables, start the application, and set up Twilio.
Finally, you can make a phone call to your number and you should hear a message using the ElevenLabs voice.
Please note that when running the application in production, make sure to set the SERVER_DOMAIN environment variable to that of your server. Be sure to also update the URL in Twilio to point to your production server.
How do I do voice streaming using ElevenLabs and OpenAI in node.js?