Spaces:
Sleeping
Sleeping
ASG Models
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -88,7 +88,9 @@ def _inference_forward_stream(
|
|
88 |
spectrogram = latents * output_padding_mask
|
89 |
|
90 |
for i in range(0, spectrogram.size(-1), chunk_size):
|
91 |
-
|
|
|
|
|
92 |
|
93 |
|
94 |
|
@@ -126,7 +128,7 @@ def generate_audio(text,name_model,speaker_id=None):
|
|
126 |
#torch.cuda.empty_cache()
|
127 |
with torch.no_grad():
|
128 |
for chunk in _inference_forward_stream(model,input_ids=inputs.input_ids,attention_mask=inputs.attention_mask,speaker_embeddings= speaker_embeddings,chunk_size=64):
|
129 |
-
yield 16000,chunk
|
130 |
def generate_audio_ai(text,name_model):
|
131 |
text_answer = get_answer_ai(text)
|
132 |
text_answer = remove_extra_spaces(text_answer)
|
@@ -137,7 +139,7 @@ def generate_audio_ai(text,name_model):
|
|
137 |
#torch.cuda.empty_cache()
|
138 |
with torch.no_grad():
|
139 |
for chunk in _inference_forward_stream(model,input_ids=inputs.input_ids,attention_mask=inputs.attention_mask,speaker_embeddings= speaker_embeddings,chunk_size=64):
|
140 |
-
yield 16000,chunk
|
141 |
|
142 |
# yield generate_audio(text_answer,name_model)
|
143 |
def remove_extra_spaces(text):
|
|
|
88 |
spectrogram = latents * output_padding_mask
|
89 |
|
90 |
for i in range(0, spectrogram.size(-1), chunk_size):
|
91 |
+
with torch.no_grad():
|
92 |
+
wav=self.decoder(spectrogram[:,:,i : i + chunk_size] ,speaker_embeddings)
|
93 |
+
yield wav.squeeze().cpu().numpy()
|
94 |
|
95 |
|
96 |
|
|
|
128 |
#torch.cuda.empty_cache()
|
129 |
with torch.no_grad():
|
130 |
for chunk in _inference_forward_stream(model,input_ids=inputs.input_ids,attention_mask=inputs.attention_mask,speaker_embeddings= speaker_embeddings,chunk_size=64):
|
131 |
+
yield 16000,chunk#.squeeze().cpu().numpy()#.astype(np.int16).tobytes()
|
132 |
def generate_audio_ai(text,name_model):
|
133 |
text_answer = get_answer_ai(text)
|
134 |
text_answer = remove_extra_spaces(text_answer)
|
|
|
139 |
#torch.cuda.empty_cache()
|
140 |
with torch.no_grad():
|
141 |
for chunk in _inference_forward_stream(model,input_ids=inputs.input_ids,attention_mask=inputs.attention_mask,speaker_embeddings= speaker_embeddings,chunk_size=64):
|
142 |
+
yield 16000,chunk#.cpu().numpy().squeeze()#.astype(np.int16).tobytes()
|
143 |
|
144 |
# yield generate_audio(text_answer,name_model)
|
145 |
def remove_extra_spaces(text):
|