SohomToom commited on
Commit
b1aa671
·
verified ·
1 Parent(s): 472f8db

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py CHANGED
@@ -36,6 +36,22 @@ def clone_and_speak(text, speaker_wav):
36
  if not speaker_wav:
37
  return "Please upload a reference .wav file."
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  base_name = f"output_{int(time.time())}_{uuid.uuid4().hex[:6]}"
40
  tmp_melo_path = f"{output_dir}/{base_name}_tmp.wav"
41
  final_output_path = f"{output_dir}/{base_name}_converted.wav"
 
36
  if not speaker_wav:
37
  return "Please upload a reference .wav file."
38
 
39
+ import melo.text.english as english
40
+ original_g2p = english.g2p
41
+
42
+ def patched_g2p(text):
43
+ phones, tones, word2ph = original_g2p(text)
44
+ # Fix: wrap ints in list to avoid TypeError
45
+ word2ph_fixed = []
46
+ for item in word2ph:
47
+ if isinstance(item, int):
48
+ word2ph_fixed.append([item])
49
+ else:
50
+ word2ph_fixed.append(item)
51
+ return phones, tones, word2ph_fixed
52
+
53
+ english.g2p = patched_g2p
54
+
55
  base_name = f"output_{int(time.time())}_{uuid.uuid4().hex[:6]}"
56
  tmp_melo_path = f"{output_dir}/{base_name}_tmp.wav"
57
  final_output_path = f"{output_dir}/{base_name}_converted.wav"