Skip to content

Library for real-time streaming LLM output to Eleven Labs' text-to-speech API.

Notifications You must be signed in to change notification settings

azer/eleven-labs-tts-stream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eleven-labs-tts-stream

Library for real-time streaming LLM output to Eleven Labs' text-to-speech API.

Work in progress:

  • Vanilla JavaScript library
  • React hook
  • Tests

Install

$ npm i azer/eleven-labs-tts-stream

Usage

import { textToSpeechStream } from 'eleven-labs-tts-stream'

const stream = textToSpeechStream({
    apiKey: '<eleven labs api key>',
    voiceId: '<voice id>',
    verbose: true // turns on verbose mode for logging
})

// Make sure socket is initialized & ready
await stream.start()

stream.push('hi!')
stream.push('this is')
stream.push('a test')
stream.push('message.')

// Indicate end of input
stream.end()

Alternatively, object-orient API can be used for more granular control;

import { TextStream, Playlist } from 'eleven-labs-tts-stream'

const stream = new TextStream({ apiKey: '..', voiceId: '...' })
stream.playlist = new Playlist()

await stream.start()
stream.push('hello')
stream.push('world')
stream.end()

Examples

To run examples locally;

$ npm run serve-examples
# go to http://127.0.0.1:8001/simple.html?api_key=<eleven labs key here>

About

Library for real-time streaming LLM output to Eleven Labs' text-to-speech API.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published