divakaivan commited on
Commit
3e188e1
1 Parent(s): 592f541

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -130,18 +130,20 @@ def predict(text, speaker):
130
  return (16000, np.zeros(0).astype(np.int16))
131
 
132
  inputs = processor(text=text, return_tensors="pt")
133
-
134
  # limit input length
135
- input_ids = inputs["input_ids"]
136
- input_ids = input_ids[..., :model.config.max_text_positions]
137
 
138
  ### ### ###
139
  example = dataset['test'][11]
140
  speaker_embedding = torch.tensor(example["speaker_embeddings"]).unsqueeze(0)
141
-
142
  speaker_embedding = torch.tensor(speaker_embedding).unsqueeze(0)
143
-
144
- speech = model.generate_speech(input_ids, speaker_embedding, vocoder=vocoder)
 
 
145
 
146
  speech = (speech.numpy() * 32767).astype(np.int16)
147
  return (16000, speech)
 
130
  return (16000, np.zeros(0).astype(np.int16))
131
 
132
  inputs = processor(text=text, return_tensors="pt")
133
+
134
  # limit input length
135
+ # input_ids = inputs["input_ids"]
136
+ # input_ids = input_ids[..., :model.config.max_text_positions]
137
 
138
  ### ### ###
139
  example = dataset['test'][11]
140
  speaker_embedding = torch.tensor(example["speaker_embeddings"]).unsqueeze(0)
141
+
142
  speaker_embedding = torch.tensor(speaker_embedding).unsqueeze(0)
143
+ spectrogram = model.generate_speech(inputs["input_ids"], speaker_embedding)
144
+ with torch.no_grad():
145
+ speech = vocoder(spectrogram)
146
+ # speech = model.generate_speech(input_ids, speaker_embedding, vocoder=vocoder)
147
 
148
  speech = (speech.numpy() * 32767).astype(np.int16)
149
  return (16000, speech)