Commit
Β·
7de38d8
1
Parent(s):
11e2df6
Refactor code to remove unused function and commented out code
Browse files- 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 |
-
|
| 26 |
-
#
|
| 27 |
-
#
|
| 28 |
-
#
|
| 29 |
-
#
|
| 30 |
-
#
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
| 37 |
|
| 38 |
-
# Find all matches
|
| 39 |
-
matches = []
|
| 40 |
-
for lang, pattern in patterns.items():
|
| 41 |
-
|
| 42 |
-
|
| 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 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
|
| 61 |
-
if last_end < len(text):
|
| 62 |
-
|
| 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):
|