Skip to content

jamesburchill/eleven_labs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

eleven_labs (Basic Functions)

Important

You need an ELEVEN LABS API. (They're free!)

You can get one here: https://elevenlabs.io

You also need a .env file in the project. This file must contain the following line (which it the API key):

ELEVEN_LABS_API_KEY=XXXXXXXXXXXXXX

Installation

Just copy the file in your project and ensure you install the required packages

Requirements

    requests~=2.28.2
    python-dotenv~=1.0.0

Usage

Simply run the script and you can hear the main voices.

Check out the various functions to see just how easy it easy to use.

Example.py

    import eleven_labs as el

    el.get_eleven_labs_api_key()  # Required to get the API key from the .env file
     
    el.list_voices()  # entirely optional, lists all the voices available
    
    v = el.select_voice('Adam')  # set the voice to Adam
    
    el.speak(v, 'Hello World')  # have Adam say 'Hello World'
    

Notes

This app was designed to run on a Mac. It uses the afplay command to play the audio file. If this is not available on your system, you will need to change the play_audio function to use a different command.

Functions

get_voices() -- Lists all the available voices

speak(text, v_id) -- Speaks the text using the voice id

play_audio(c) -- Plays the audio file generated by speak()

demo_voices() -- Plays a demo of all the voices

input_voice() -- Allows you to select a voice from a list

list_voices() -- Lists all the voices

select_voice(x) -- Selects a voice from a list

get_eleven_labs_api_key() -- Gets the API key from the .env file

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages