Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -1243,10 +1243,18 @@ def generate_audio_mars5(text):
|
|
1243 |
chat = ChatTTS.Chat()
|
1244 |
chat.load_models()
|
1245 |
|
1246 |
-
# Ensure the sample rate
|
1247 |
if not hasattr(chat, 'sr'):
|
1248 |
chat.sr = 22050 # Or the appropriate sample rate for your use case
|
1249 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1250 |
# Continue with the rest of your script
|
1251 |
def generate_audio_chattts(text, temperature=0.3, top_p=0.7, top_k=20):
|
1252 |
rand_spk = torch.randn(768)
|
@@ -1263,7 +1271,7 @@ def generate_audio_chattts(text, temperature=0.3, top_p=0.7, top_k=20):
|
|
1263 |
|
1264 |
for chunk in chunks:
|
1265 |
wav = torch.zeros(1, chat.sr) # Use a placeholder silent audio for the reference
|
1266 |
-
cfg = chat.config_class(**{k: params_infer_code[k] for k in params_infer_code if k in chat.config_class.
|
1267 |
ar_codes, wav_out = chat.tts(chunk, wav, "", cfg=cfg)
|
1268 |
|
1269 |
temp_audio_path = os.path.join(tempfile.gettempdir(), f"chattts_audio_{len(audio_segments)}.wav")
|
|
|
1243 |
chat = ChatTTS.Chat()
|
1244 |
chat.load_models()
|
1245 |
|
1246 |
+
# Ensure the sample rate and config_class attributes are set
|
1247 |
if not hasattr(chat, 'sr'):
|
1248 |
chat.sr = 22050 # Or the appropriate sample rate for your use case
|
1249 |
|
1250 |
+
if not hasattr(chat, 'config_class'):
|
1251 |
+
class Config:
|
1252 |
+
def __init__(self, temperature, top_p, top_k):
|
1253 |
+
self.temperature = temperature
|
1254 |
+
self.top_p = top_p
|
1255 |
+
self.top_k = top_k
|
1256 |
+
chat.config_class = Config
|
1257 |
+
|
1258 |
# Continue with the rest of your script
|
1259 |
def generate_audio_chattts(text, temperature=0.3, top_p=0.7, top_k=20):
|
1260 |
rand_spk = torch.randn(768)
|
|
|
1271 |
|
1272 |
for chunk in chunks:
|
1273 |
wav = torch.zeros(1, chat.sr) # Use a placeholder silent audio for the reference
|
1274 |
+
cfg = chat.config_class(**{k: params_infer_code[k] for k in params_infer_code if k in chat.config_class.__init__.__code__.co_varnames})
|
1275 |
ar_codes, wav_out = chat.tts(chunk, wav, "", cfg=cfg)
|
1276 |
|
1277 |
temp_audio_path = os.path.join(tempfile.gettempdir(), f"chattts_audio_{len(audio_segments)}.wav")
|