Spaces:
Sleeping
Sleeping
ASG Models
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -130,7 +130,16 @@ def generate_audio(text,name_model,speaker_id=None):
|
|
130 |
def generate_audio_ai(text,name_model):
|
131 |
text_answer = get_answer_ai(text)
|
132 |
text_answer = remove_extra_spaces(text_answer)
|
133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
def remove_extra_spaces(text):
|
135 |
"""
|
136 |
Removes extra spaces between words in a string.
|
|
|
130 |
def generate_audio_ai(text,name_model):
|
131 |
text_answer = get_answer_ai(text)
|
132 |
text_answer = remove_extra_spaces(text_answer)
|
133 |
+
inputs = tokenizer(text_answer, return_tensors="pt")#.input_ids
|
134 |
+
|
135 |
+
speaker_embeddings = None
|
136 |
+
model=get_model(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.squeeze().cpu().numpy()#.astype(np.int16).tobytes()
|
141 |
+
|
142 |
+
# yield generate_audio(text_answer,name_model)
|
143 |
def remove_extra_spaces(text):
|
144 |
"""
|
145 |
Removes extra spaces between words in a string.
|