File size: 1,346 Bytes
a9482ab
 
b87f08b
7f6563e
 
510f17f
aeceb48
7f6563e
8772ca9
7f6563e
d59ee2f
 
a9482ab
a7d0893
 
b9e36f1
a9482ab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d2e0f91
 
 
 
 
 
 
 
91eda71
 
 
 
 
 
 
 
a9482ab
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import IPython

import sys
import subprocess

subprocess.check_call([sys.executable, "-m", "pip", "install", "--upgrade", "--force-reinstall", "git+https://github.com/osanseviero/tortoise-tts.git"])

# entmax could not be installed at same time as torch
subprocess.check_call([sys.executable, "-m", "pip", "install", "entmax"])

from tortoise_tts.api import TextToSpeech
from tortoise_tts.utils.audio import load_audio, get_voices

# This will download all the models used by Tortoise from the HF hub
device = "cuda" if torch.cuda.is_available() else "cpu"
tts = TextToSpeech("cpu")

voices = [
  "angie",
  "daniel",
  "deniro",
  "emma",
  "freeman",
  "geralt",
  "halle",
  "jlaw",
  "lj",
  "snakes",
  "tom",
  "William",
]
voices = get_voices()

preset = "fastest"

def inference(text, voice):
    cond_paths = voices[voice]
    conds = []
    for cond_path in cond_paths:
        c = load_audio(cond_path, 22050)
        conds.append(c)
    gen = tts.tts_with_preset(text, conds, preset)
    return gen
 
text = "Joining two modalities results in a surprising increase in generalization! What would happen if we combined them all?"
iface = gr.Interface(
  generate_tone,
  inputs=[
      gr.inputs.Textbox(type="text", default=text, label="Text"),
      gr.inputs.Dropdown(voices, type="index"),
  ],
  outputs="audio",
)

iface.launch()