Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -31,13 +31,20 @@ def predict(text, speaker):
|
|
31 |
|
32 |
# text = getNews ()
|
33 |
# inputs = processor(text=text, return_tensors="pt")
|
34 |
-
inputs = processor(text=getNews(text),
|
35 |
-
return_tensors="pt")
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
# limit input length
|
38 |
input_ids = inputs["input_ids"]
|
39 |
input_ids = input_ids[..., :model.config.max_text_positions]
|
40 |
|
|
|
41 |
if speaker == "Surprise Me!":
|
42 |
# load one of the provided speaker embeddings at random
|
43 |
idx = np.random.randint(len(speaker_embeddings))
|
@@ -93,14 +100,15 @@ examples = [
|
|
93 |
gr.Interface(
|
94 |
fn=predict,
|
95 |
inputs=[
|
96 |
-
gr.Text(label="
|
97 |
-
gr.Radio(label="
|
98 |
-
"
|
99 |
-
"
|
100 |
-
"
|
|
|
101 |
"Surprise Me!"
|
102 |
],
|
103 |
-
value="
|
104 |
],
|
105 |
outputs=[
|
106 |
gr.Audio(label="Generated Speech", type="numpy"),
|
|
|
31 |
|
32 |
# text = getNews ()
|
33 |
# inputs = processor(text=text, return_tensors="pt")
|
|
|
|
|
34 |
|
35 |
+
if Interest == "":
|
36 |
+
inputs = processor(text=getNews(Interest),
|
37 |
+
return_tensors="pt")
|
38 |
+
else
|
39 |
+
inputs = processor(text=getNews(text),
|
40 |
+
return_tensors="pt")
|
41 |
+
|
42 |
+
|
43 |
# limit input length
|
44 |
input_ids = inputs["input_ids"]
|
45 |
input_ids = input_ids[..., :model.config.max_text_positions]
|
46 |
|
47 |
+
|
48 |
if speaker == "Surprise Me!":
|
49 |
# load one of the provided speaker embeddings at random
|
50 |
idx = np.random.randint(len(speaker_embeddings))
|
|
|
100 |
gr.Interface(
|
101 |
fn=predict,
|
102 |
inputs=[
|
103 |
+
gr.Text(label="keyword"),
|
104 |
+
gr.Radio(label="Interest", choices=[
|
105 |
+
"Minecraft",
|
106 |
+
"Technology",
|
107 |
+
"Politics",
|
108 |
+
"KPop",
|
109 |
"Surprise Me!"
|
110 |
],
|
111 |
+
value="KPop"),
|
112 |
],
|
113 |
outputs=[
|
114 |
gr.Audio(label="Generated Speech", type="numpy"),
|