Fix bug: Truncate to max text positions
Browse files
app.py
CHANGED
@@ -30,7 +30,16 @@ def translate(audio):
|
|
30 |
|
31 |
|
32 |
def synthesise(text):
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
speech = model.generate_speech(inputs["input_ids"].to(device), speaker_embeddings.to(device), vocoder=vocoder)
|
35 |
return speech.cpu()
|
36 |
|
|
|
30 |
|
31 |
|
32 |
def synthesise(text):
|
33 |
+
# Need to specific truncate to max text positions.
|
34 |
+
# Otherwise model.generate_speech will throw errors.
|
35 |
+
inputs = processor(
|
36 |
+
text=text,
|
37 |
+
max_length=model.config.max_text_positions,
|
38 |
+
truncation=True,
|
39 |
+
padding=True,
|
40 |
+
return_tensors="pt"
|
41 |
+
)
|
42 |
+
# inputs = processor(text=text, return_tensors="pt")
|
43 |
speech = model.generate_speech(inputs["input_ids"].to(device), speaker_embeddings.to(device), vocoder=vocoder)
|
44 |
return speech.cpu()
|
45 |
|