File size: 300 Bytes
a269add
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
from elevenlabslib import *
import os

def text2voice(prompt, path, key, voiceIndex):
    user = ElevenLabsUser(key)
    voice = user.get_available_voices()[voiceIndex]
    audioBytes = voice.generate_audio_bytes(prompt)
    with open(path, "wb") as binary_file:
        binary_file.write(audioBytes)