barreloflube commited on
Commit
7de38d8
β€’
1 Parent(s): 11e2df6

Refactor code to remove unused function and commented out code

Browse files
Files changed (1) hide show
  1. tabs/audios/events.py +36 -35
tabs/audios/events.py CHANGED
@@ -22,46 +22,47 @@ def create_temp_file():
22
 
23
 
24
  def assign_language_tags(text):
25
- # Process the text
26
- # based on the language assign <|zh|><|en|><|jp|><|yue|><|ko|> for Chinese/English/Japanese/Cantonese/Korean
27
- # at the start of the text for that language
28
- # e.g. input: δ½ ε₯½ Hello こんにけは δ½ ε₯½ μ•ˆλ…•ν•˜μ„Έμš”
29
- # output: <|zh|>δ½ ε₯½<|en|>Hello<|jp|>こんにけは<|yue|>δ½ ε₯½<|ko|>μ•ˆλ…•ν•˜μ„Έμš”
30
- # Define language patterns
31
- patterns = {
32
- 'zh': r'[\u4e00-\u9fff]+', # Chinese characters
33
- 'en': r'[a-zA-Z]+', # English letters
34
- 'jp': r'[\u3040-\u30ff\u31f0-\u31ff]+', # Japanese characters
35
- 'ko': r'[\uac00-\ud7a3]+', # Korean characters
36
- }
 
37
 
38
- # Find all matches
39
- matches = []
40
- for lang, pattern in patterns.items():
41
- for match in re.finditer(pattern, text):
42
- matches.append((match.start(), match.end(), lang, match.group()))
43
 
44
- # Sort matches by start position
45
- matches.sort(key=lambda x: x[0])
46
 
47
- # Build the result string
48
- result = []
49
- last_end = 0
50
- zh_count = 0
51
- for start, end, lang, content in matches:
52
- if start > last_end:
53
- result.append(text[last_end:start])
54
- if lang == 'zh':
55
- zh_count += 1
56
- if zh_count > 1:
57
- lang = 'yue'
58
- result.append(f'<|{lang}|>{content}')
59
- last_end = end
60
 
61
- if last_end < len(text):
62
- result.append(text[last_end:])
63
 
64
- return ''.join(result)
65
 
66
 
67
  def update_mode(mode, sft_speaker, speaker_audio, voice_instructions):
 
22
 
23
 
24
  def assign_language_tags(text):
25
+ return text
26
+ # # Process the text
27
+ # # based on the language assign <|zh|><|en|><|jp|><|yue|><|ko|> for Chinese/English/Japanese/Cantonese/Korean
28
+ # # at the start of the text for that language
29
+ # # e.g. input: δ½ ε₯½ Hello こんにけは δ½ ε₯½ μ•ˆλ…•ν•˜μ„Έμš”
30
+ # # output: <|zh|>δ½ ε₯½<|en|>Hello<|jp|>こんにけは<|yue|>δ½ ε₯½<|ko|>μ•ˆλ…•ν•˜μ„Έμš”
31
+ # # Define language patterns
32
+ # patterns = {
33
+ # 'zh': r'[\u4e00-\u9fff]+', # Chinese characters
34
+ # 'en': r'[a-zA-Z]+', # English letters
35
+ # 'jp': r'[\u3040-\u30ff\u31f0-\u31ff]+', # Japanese characters
36
+ # 'ko': r'[\uac00-\ud7a3]+', # Korean characters
37
+ # }
38
 
39
+ # # Find all matches
40
+ # matches = []
41
+ # for lang, pattern in patterns.items():
42
+ # for match in re.finditer(pattern, text):
43
+ # matches.append((match.start(), match.end(), lang, match.group()))
44
 
45
+ # # Sort matches by start position
46
+ # matches.sort(key=lambda x: x[0])
47
 
48
+ # # Build the result string
49
+ # result = []
50
+ # last_end = 0
51
+ # zh_count = 0
52
+ # for start, end, lang, content in matches:
53
+ # if start > last_end:
54
+ # result.append(text[last_end:start])
55
+ # if lang == 'zh':
56
+ # zh_count += 1
57
+ # if zh_count > 1:
58
+ # lang = 'yue'
59
+ # result.append(f'<|{lang}|>{content}')
60
+ # last_end = end
61
 
62
+ # if last_end < len(text):
63
+ # result.append(text[last_end:])
64
 
65
+ # return ''.join(result)
66
 
67
 
68
  def update_mode(mode, sft_speaker, speaker_audio, voice_instructions):