battle programmers alliance
Would you like to react to this message? Create an account in a few clicks or log in to continue.

battle programmers allianceLog in

the LivinGrimoire Artificial General Intelligence software design pattern forum

descriptionPycharm python windows OS 11labs hello world step by step walkthrough EmptyPycharm python windows OS 11labs hello world step by step walkthrough

more_horiz
Download
ffmpeg-git-full.7z:
https://www.gyan.dev/ffmpeg/builds/
Extract & Rename:
Extract the downloaded package.
Rename the extracted folder to “ffmpeg” (remove version details).
Move to Main Drive:
Drag and drop the “ffmpeg” folder onto your main system drive (e.g., C:\).
Place it in the root directory of the drive.
Add to PATH:
Search for “Edit the system environment variables” in the start menu.
Open the System Properties window.
Go to the “Advanced” tab and click “Environment Variables.”
Select the “Path” variable and click “Edit.”
Click “New” and add “C:\ffmpeg\bin” (adjust if you placed it elsewhere).
Now FFmpeg should be usable from any command prompt or application!

restart pycharm

pycharm terminal:
pip install elevenlabs

Code:

from elevenlabs.client import ElevenLabs
from elevenlabs import play, stream, save


def print_hi(name):
    # Use a breakpoint in the code line below to debug your script.
    print(f'Hi, {name}')  # Press Ctrl+F8 to toggle the breakpoint.


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    print_hi('PyCharm')
    client = ElevenLabs(api_key="my api key")

    # Generate TTS audio
    audio = client.generate(text="hello world")

    # Play audio using ffmpeg
    play(audio)

    # Save audio to a file
    save(audio, "my-file.mp3")


get the api key from:
https://elevenlabs.io/api

Last edited by Admin on Wed Jul 03, 2024 5:54 pm; edited 2 times in total

descriptionPycharm python windows OS 11labs hello world step by step walkthrough EmptyRe: Pycharm python windows OS 11labs hello world step by step walkthrough

more_horiz
to set different voices change the audio code line so it also has the voice param:

Code:

    # Generate TTS audio
    audio = client.generate(text="hello world", voice="z9fAnlkpzviPz146aGWa")


her is a list of voices:
Rachel; 21m00Tcm4TlvDq8ikWAM
Drew; 29vD33N1CtxCmqQRPOHJ
Clyde; 2EiwWnXFnvU5JabPnv8n
Paul; 5Q0t7uMcjvnagumLfvZi
Domi; AZnzlk1XvdvUeBnXmlld
Dave; CYw3kZ02Hs0563khs1Fj
Fin; D38z5RcWu1voky8WS1ja
Sarah; EXAVITQu4vr4xnSDxMaL
Antoni; ErXwobaYiN019PkySvjV
Thomas; GBv7mTt0atIp3Br8iCZE
Charlie; IKne3meq5aSn9XLyUdCD
George; JBFqnCBsd6RMkjVDRZzb
Emily; LcfcDJNUP1GQjkzn1xUU
Elli; MF3mGyEYCl7XYWbV9V6O
Callum; N2lVS1w4EtoT3dr4eOWO
Patrick; ODq5zmih8GrVes37Dizd
Harry; SOYHLrjzK2X1ezoPC6cr
Liam; TX3LPaxmHKxFdv7VOQHJ
Dorothy; ThT5KcBeYPX3keUQqHPh
Josh; TxGEqnHWrfWFTfGW9XjX
Arnold; VR6AewLTigWG4xSOukaG
Charlotte; XB0fDUnXU5powFXDhCwa
Alice; Xb7hH8MSUJpSbSDYk0k2
Matilda; XrExE9yKIg1WjnnlVkGX
James; ZQe5CZNOzWyzPSCn5a3c
Joseph; Zlb1dXrM653N07WRdFW3
Jeremy; bVMeCyTHy58xNoL34h3p
Michael; flq6f7yk4E4fJM5XTYuZ
Ethan; g5CIjZEefAph4nQFvHAz
Chris; iP95p4xoKVk53GoZ742B
Gigi; jBpfuIE2acCO8z3wKNLl
Freya; jsCqWAovK2LkecY7zXl4
Brian; nPczCjzI2devNBz1zQrb
Grace; oWAxZDx7w5VEj9dCyTzz
Daniel; onwK4e9ZLuTAKqWW03F9
Lily; pFZP5JQG7iQjIQuC4Bku
Serena; pMsXgVXv3BLzUgSXRplE
Adam; pNInz6obpgDQGcFmaJgB
Nicole; piTKgcLEGmPE4e6mEKli
Bill; pqHfZKP75CvOlQylNhV4
Jessie; t0jbNlBVZ17f02VDIeMI
Sam; yoZ06aMxZJJ28mfd3POQ
Glinda; z9fAnlkpzviPz146aGWa
Giovanni; zcAOhNBS3c14rBihAFp1
Mimi; zrHiDhphv9ZnVXBqCLjz

descriptionPycharm python windows OS 11labs hello world step by step walkthrough EmptyRe: Pycharm python windows OS 11labs hello world step by step walkthrough

more_horiz
in case you wonder how I got the voices list, here is the Python code:

Code:

import requests
import json

# Your ElevenLabs API key
XI_API_KEY = "your_api_key_here"

# API endpoint URL for listing voices
url = "https://api.elevenlabs.io/v1/voices"

# Set up headers for the HTTP request
headers = {
    "Accept": "application/json",
    "xi-api-key": XI_API_KEY,
    "Content-Type": "application/json"
}

# Send a GET request to the API
response = requests.get(url, headers=headers)

# Parse the JSON response
data = response.json()

# Print voice names and their corresponding voice IDs
for voice in data['voices']:
    print(f"{voice['name']}; {voice['voice_id']}")

descriptionPycharm python windows OS 11labs hello world step by step walkthrough EmptyRe: Pycharm python windows OS 11labs hello world step by step walkthrough

more_horiz
voice cloning:

Code:

from elevenlabs.client import ElevenLabs
from elevenlabs import play

client = ElevenLabs(
  api_key="YOUR_API_KEY", # Defaults to ELEVEN_API_KEY
)

voice = client.clone(
    name="Alex",
    description="An old American male voice with a slight hoarseness in his throat. Perfect for news", # Optional
    files=["./sample_0.mp3", "./sample_1.mp3", "./sample_2.mp3"],
)

audio = client.generate(text="Hi! I'm a cloned voice!", voice=voice)

play(audio)

descriptionPycharm python windows OS 11labs hello world step by step walkthrough EmptyRe: Pycharm python windows OS 11labs hello world step by step walkthrough

more_horiz
Introducing the 11Labs Saver Python Class

Are you tired of spending precious 11Labs tokens every time you generate an MP3 file? Look no further! Our Python class simplifies your experience with 11Labs while saving you money.

Key Features:

Easy Integration:
Our class provides a straightforward interface for utilizing 11Labs’ powerful text-to-speech capabilities.
No complex setup—just import the class and start generating audio effortlessly.
Smart Savings:
We understand the value of your 11Labs tokens. Our class automatically saves generated MP3 files locally.
When you need the same content again, it fetches the saved file instead of consuming additional tokens.
Step-by-Step Instructions:
We’ve got you covered! Our video tutorial guides you through the entire process.
Learn how to use the class effectively and maximize your savings.
Clean Codebase:
Quality matters. Our Python class is well-organized, readable, and follows best practices.
You’ll appreciate the simplicity and maintainability of our code.

https://ko-fi.com/s/369beb03d3

there is also a latency method to change the voice's speed!
privacy_tip Permissions in this forum:
You cannot reply to topics in this forum
power_settings_newLogin to reply