ASG Models commited on
Commit
2abe848
·
verified ·
1 Parent(s): fc5b39b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
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
- yield generate_audio(text_answer,name_model)
 
 
 
 
 
 
 
 
 
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.