osanseviero commited on
Commit
a9482ab
1 Parent(s): f7e3ddf

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -0
app.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import torchaudio
3
+ import torch.nn as nn
4
+ import torch.nn.functional as F
5
+
6
+ import IPython
7
+
8
+ from api import TextToSpeech
9
+ from utils.audio import load_audio, get_voices
10
+
11
+ # This will download all the models used by Tortoise from the HF hub.
12
+ tts = TextToSpeech()
13
+
14
+ voices = [
15
+ "angie",
16
+ "daniel",
17
+ "deniro",
18
+ "emma",
19
+ "freeman",
20
+ "geralt",
21
+ "halle",
22
+ "jlaw",
23
+ "lj",
24
+ "snakes",
25
+ "tom",
26
+ "William",
27
+ ]
28
+ voices = get_voices()
29
+
30
+ preset = "fastest"
31
+
32
+ def inference(text, voice):
33
+ cond_paths = voices[voice]
34
+ conds = []
35
+ for cond_path in cond_paths:
36
+ c = load_audio(cond_path, 22050)
37
+ conds.append(c)
38
+ gen = tts.tts_with_preset(text, conds, preset)
39
+ return gen
40
+
41
+ text = "Joining two modalities results in a surprising increase in generalization! What would happen if we combined them all?"
42
+ iface = gr.Interface(
43
+ generate_tone,
44
+ inputs=[
45
+ gr.inputs.Textbox(type="text", default=text, label="Text"),
46
+ gr.inputs.Dropdown(voices, type="index"),
47
+ ],
48
+ outputs="audio",
49
+ )
50
+
51
+ iface.launch()