Mahiruoshi commited on
Commit
0e385a7
·
verified ·
1 Parent(s): 8e264ce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -33
app.py CHANGED
@@ -65,7 +65,7 @@ webBase = {
65
 
66
  languages = [ "Auto", "ZH", "JP"]
67
  modelPaths = []
68
- modes = ['pyopenjtalk-V2.3','fugashi-V2.3']
69
  sentence_modes = ['sentence','paragraph']
70
 
71
  net_g = None
@@ -408,35 +408,6 @@ def extract_and_convert(text):
408
  text = text.replace(eng, kana, 1) # 限制每次只替换一个实例
409
 
410
  return text
411
- # 推理工具
412
- def download_unidic():
413
- try:
414
- Tagger()
415
- print("Tagger launch successfully.")
416
- except Exception as e:
417
- print("UNIDIC dictionary not found, downloading...")
418
- subprocess.run([sys.executable, "-m", "unidic", "download"])
419
- print("Download completed.")
420
-
421
- def kanji_to_hiragana(text):
422
- global tagger
423
- output = ""
424
-
425
- # 更新正则表达式以更准确地区分文本和标点符号
426
- segments = re.findall(r'[一-龥ぁ-んァ-ン\w]+|[^\一-龥ぁ-んァ-ン\w\s]', text, re.UNICODE)
427
-
428
- for segment in segments:
429
- if re.match(r'[一-龥ぁ-んァ-ン\w]+', segment):
430
- # 如果是单词或汉字,转换为平假名
431
- for word in tagger(segment):
432
- kana = word.feature.kana or word.surface
433
- hiragana = jaconv.kata2hira(kana) # 将片假名转换为平假名
434
- output += hiragana
435
- else:
436
- # 如果是标点符号,保持不变
437
- output += segment
438
-
439
- return output
440
 
441
  def get_net_g(model_path: str, device: str, hps):
442
  net_g = SynthesizerTrn(
@@ -509,8 +480,6 @@ def infer(
509
  if style_text == None:
510
  style_text = ""
511
  style_weight=0,
512
- if mode == 'fugashi-V2.3':
513
- text = kanji_to_hiragana(text) if is_japanese(text) else text
514
  if language == "JP":
515
  text = translate(text,"jp")
516
  if language == "ZH":
@@ -699,7 +668,7 @@ def generate_audio(
699
  if inputFile:
700
  text = extract_text_from_file(inputFile.name)
701
  sentence_mode = 'paragraph'
702
- if mode == 'pyopenjtalk-V2.3' or mode == 'fugashi-V2.3':
703
  if sentence_mode == 'sentence':
704
  audio = infer(
705
  text,
 
65
 
66
  languages = [ "Auto", "ZH", "JP"]
67
  modelPaths = []
68
+ modes = ['pyopenjtalk-V2.3']
69
  sentence_modes = ['sentence','paragraph']
70
 
71
  net_g = None
 
408
  text = text.replace(eng, kana, 1) # 限制每次只替换一个实例
409
 
410
  return text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
411
 
412
  def get_net_g(model_path: str, device: str, hps):
413
  net_g = SynthesizerTrn(
 
480
  if style_text == None:
481
  style_text = ""
482
  style_weight=0,
 
 
483
  if language == "JP":
484
  text = translate(text,"jp")
485
  if language == "ZH":
 
668
  if inputFile:
669
  text = extract_text_from_file(inputFile.name)
670
  sentence_mode = 'paragraph'
671
+ if mode == 'pyopenjtalk-V2.3':
672
  if sentence_mode == 'sentence':
673
  audio = infer(
674
  text,