File size: 1,170 Bytes
a9482ab
 
 
 
 
 
 
6ef16fa
 
 
 
 
a9482ab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d2e0f91
 
 
 
 
 
 
 
 
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
57
58
import torch
import torchaudio
import torch.nn as nn
import torch.nn.functional as F

import IPython

import os
import sys
os.system("git clone https://github.com/neonbjb/tortoise-tts.git")
sys.path.append("tortoise-tts")

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

# This will download all the models used by Tortoise from the HF hub.
tts = TextToSpeech()

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()