Skip to content

Commit

Permalink
talk and talk-llama: get voices from api
Browse files Browse the repository at this point in the history
  • Loading branch information
tamo committed Feb 14, 2024
1 parent 7574276 commit 53ad35c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions examples/talk-llama/eleven-labs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

parser = argparse.ArgumentParser(description="Generate the TTS")
parser.add_argument("inputfile")
parser.add_argument("-v", "--voice", type=int, default=2,
choices=[0, 1, 2, 3, 4, 5, 6],
parser.add_argument("-v", "--voice", type=int, default=21,
help="Get a voice object by number")
group = parser.add_mutually_exclusive_group()
group.add_argument("-s", "--savefile", default="audio.mp3",
Expand All @@ -21,12 +20,14 @@
print("elevenlabs library is not installed, you can install it to your enviroment using 'pip install elevenlabs'")
sys.exit()

from elevenlabs import generate, play, save
from elevenlabs import voices, generate, play, save, DEFAULT_VOICE

with open(args.inputfile) as f:
voicelist = [DEFAULT_VOICE]
voicelist += voices()[:]
audio = generate(
text=str(f.read()),
voice=["Adam", "Antoni", "Arnold", "Bella", "Domi", "Elli", "Josh"][args.voice]
voice=voicelist[args.voice % len(voicelist)]
)
if args.play:
play(audio)
Expand Down
9 changes: 5 additions & 4 deletions examples/talk/eleven-labs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

parser = argparse.ArgumentParser(description="Generate the TTS")
parser.add_argument("inputfile")
parser.add_argument("-v", "--voice", type=int, default=2,
choices=[0, 1, 2, 3, 4, 5, 6],
parser.add_argument("-v", "--voice", type=int, default=21,
help="Get a voice object by number")
group = parser.add_mutually_exclusive_group()
group.add_argument("-s", "--savefile", default="audio.mp3",
Expand All @@ -21,12 +20,14 @@
print("elevenlabs library is not installed, you can install it to your enviroment using 'pip install elevenlabs'")
sys.exit()

from elevenlabs import generate, play, save
from elevenlabs import voices, generate, play, save, DEFAULT_VOICE

with open(args.inputfile) as f:
voicelist = [DEFAULT_VOICE]
voicelist += voices()[:]
audio = generate(
text=str(f.read()),
voice=["Adam", "Antoni", "Arnold", "Bella", "Domi", "Elli", "Josh"][args.voice]
voice=voicelist[args.voice % len(voicelist)]
)
if args.play:
play(audio)
Expand Down

0 comments on commit 53ad35c

Please sign in to comment.