Hev832 commited on
Commit
4a6e3e2
1 Parent(s): 9311069

Update lib/tts_infer.py

Browse files
Files changed (1) hide show
  1. lib/tts_infer.py +15 -2
lib/tts_infer.py CHANGED
@@ -4,6 +4,7 @@ import gc
4
  import torch
5
  from multiprocessing import cpu_count
6
  from lib.modules import VC
 
7
  from lib.split_audio import split_silence_nonsilent, adjust_audio_lengths, combine_silence_nonsilent
8
  import edge_tts
9
  import tempfile
@@ -109,7 +110,8 @@ def get_model(voice_model):
109
 
110
  def infer_audio(
111
  model_name,
112
- audio_path,
 
113
  f0_change=0,
114
  f0_method="rmvpe",
115
  min_pitch="50",
@@ -140,6 +142,17 @@ def infer_audio(
140
  vc = VC(configs)
141
  pth_path, index_path = get_model(model_name)
142
  vc_data = vc.get_vc(pth_path, protect, 0.5)
 
 
 
 
 
 
 
 
 
 
 
143
 
144
  if split_infer:
145
  inferred_files = []
@@ -195,7 +208,7 @@ def infer_audio(
195
  else:
196
  inference_info, audio_data, output_path = vc.vc_single(
197
  0,
198
- audio_path,
199
  f0_change,
200
  f0_method,
201
  index_path,
 
4
  import torch
5
  from multiprocessing import cpu_count
6
  from lib.modules import VC
7
+ from lib.language_tts import language_dict
8
  from lib.split_audio import split_silence_nonsilent, adjust_audio_lengths, combine_silence_nonsilent
9
  import edge_tts
10
  import tempfile
 
110
 
111
  def infer_audio(
112
  model_name,
113
+ text,
114
+ language_code,
115
  f0_change=0,
116
  f0_method="rmvpe",
117
  min_pitch="50",
 
142
  vc = VC(configs)
143
  pth_path, index_path = get_model(model_name)
144
  vc_data = vc.get_vc(pth_path, protect, 0.5)
145
+
146
+
147
+ voice = language_dict.get(language_code, "default_voice")
148
+ communicate = edge_tts.Communicate(text, voice)
149
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
150
+ tmp_path = tmp_file.name
151
+ await communicate.save(tmp_path)
152
+
153
+
154
+
155
+
156
 
157
  if split_infer:
158
  inferred_files = []
 
208
  else:
209
  inference_info, audio_data, output_path = vc.vc_single(
210
  0,
211
+ audio_path=tmp_path,
212
  f0_change,
213
  f0_method,
214
  index_path,