This commit is contained in:
Dazed 2023-12-29 11:09:11 -06:00
parent ae138ee0b5
commit a550bbc693
2 changed files with 45 additions and 57 deletions

View file

@ -48,7 +48,7 @@ if 'gpt-3.5' in MODEL:
elif 'gpt-4' in MODEL:
INPUTAPICOST = .01
OUTPUTAPICOST = .03
BATCHSIZE = 5
BATCHSIZE = 40
def handleKansen(filename, estimate):
global ESTIMATE
@ -354,18 +354,18 @@ def translateTyrano(data, pbar, totalLines):
# Save some money and enter the character before translation
def getSpeaker(speaker):
match speaker:
case '':
return ['Wataru', [0,0]]
case '悠帆':
return ['Yuuho', [0,0]]
case '穂村':
return ['Homura', [0,0]]
case 'マリー':
return ['Marie', [0,0]]
case 'マル子':
return ['Maruko', [0,0]]
case '瑞樹':
return ['Mizuki', [0,0]]
case '大介':
return ['Daisuke', [0,0]]
case '眞琴':
return ['Makoto', [0,0]]
case '':
return ['Shou', [0,0]]
case '冴子':
return ['Saeko', [0,0]]
case '':
return ['Aya', [0,0]]
case '':
return ['Kozue', [0,0]]
case '':
return ['Jin', [0,0]]
case '緒織':
@ -512,18 +512,12 @@ def batchList(input_list, batch_size):
def createContext(fullPromptFlag, subbedT):
characters = 'Game Characters:\n\
林つかさ (Tsukasa Hayashi) - Female\n\
山田美兎 (Miyato Yamada) - Female\n\
鈴木赤音 (Akane Suzuki) - Female\n\
佐藤莉伊南 (Riina Satou) - Female\n\
佐々木万梨美 (Marimi Sasaki) - Female\n\
渡辺登樹子 (Tokiko Watanabe) - Female\n\
桃乃夢 (Yume Momono) - Female\n\
吉浦美雪 (Miyuki Yoshiura) - Female\n\
三ツ門まあな (Maana Mitsukado) - Female\n\
モリーボイド (Molly Boyd) - Female\n\
オルガブヤチッチ (Olga Buyachich) - Female\n\
アッチャラー ギッティ (Atchara Gitti) - Female\n\
仙道 大介 (Sendou Daisuke) - Male\n\
眞琴 (Abumi Makoto) - Female\n\
石郷岡 (Ishigooka Shou) - Male\n\
桐越 冴子 (Kirikoshi Saeko) - Female\n\
真坂 (Masaka Aya) - Female\n\
能登屋 (Notoya Kozue) - Female\n\
'
system = PROMPT if fullPromptFlag else \

View file

@ -46,7 +46,7 @@ if 'gpt-3.5' in MODEL:
elif 'gpt-4' in MODEL:
INPUTAPICOST = .01
OUTPUTAPICOST = .03
BATCHSIZE = 50
BATCHSIZE = 50
FREQUENCY_PENALTY = 0.1
#tqdm Globals
@ -55,14 +55,14 @@ POSITION = 0
LEAVE = False
# Dialogue / Scroll
CODE401 = True
CODE401 = False
CODE405 = False
# Choices
CODE102 = True
CODE102 = False
# Variables
CODE122 = False
CODE122 = True
# Names
CODE101 = False
@ -839,21 +839,17 @@ def searchCodes(page, pbar, fillList, filename):
## Event Code: 122 [Set Variables]
if codeList[i]['code'] == 122 and CODE122 is True:
# This is going to be the var being set. (IMPORTANT)
# if varNum not in [1178]:
# continue
if codeList[i]['parameters'][0] not in [327]:
continue
jaString = codeList[i]['parameters'][4]
if isinstance(jaString, str):
if not isinstance(jaString, str):
continue
# Definitely don't want to mess with files
if '' in jaString or '_' in jaString:
continue
# Definitely don't want to mess with files
if '\'' not in jaString:
continue
# Need to remove outside code and put it back later
matchList = re.findall(r"[\'\"\`](.*)[\'\"\`]", jaString)
@ -1583,10 +1579,10 @@ def searchSS(state, pbar):
totalTokens = [0, 0]
# Name
nameResponse = translateGPT(state['name'], 'Reply with only the '+ LANGUAGE +' translation of the RPG Skill name.', True) if 'name' in state else ''
nameResponse = translateGPT(state['name'], 'Reply with only the '+ LANGUAGE +' translation of the RPG Skill name.', False) if 'name' in state else ''
# Description
descriptionResponse = translateGPT(state['description'], 'Reply with only the '+ LANGUAGE +' translation of the description.', True) if 'description' in state else ''
descriptionResponse = translateGPT(state['description'], 'Reply with only the '+ LANGUAGE +' translation of the description.', False) if 'description' in state else ''
# Messages
message1Response = ''
@ -1749,8 +1745,14 @@ def searchSystem(data, pbar):
# Save some money and enter the character before translation
def getSpeaker(speaker):
match speaker:
case '雪音':
return ['Yukine', [0,0]]
case 'リオ':
return ['Rio', [0,0]]
case 'ラビ':
return ['Rabi', [0,0]]
case 'フィルス':
return ['Phils', [0,0]]
case 'レイン':
return ['Meryl', [0,0]]
case _:
return translateGPT(speaker, 'Reply with only the '+ LANGUAGE +' translation of the NPC name.', False)
@ -1875,22 +1877,16 @@ def batchList(input_list, batch_size):
def createContext(fullPromptFlag, subbedT):
characters = 'Game Characters:\n\
林つかさ (Tsukasa Hayashi) - Female\n\
山田美兎 (Miyato Yamada) - Female\n\
鈴木赤音 (Akane Suzuki) - Female\n\
佐藤莉伊南 (Riina Satou) - Female\n\
佐々木万梨美 (Marimi Sasaki) - Female\n\
渡辺登樹子 (Tokiko Watanabe) - Female\n\
桃乃夢 (Yume Momono) - Female\n\
吉浦美雪 (Miyuki Yoshiura) - Female\n\
三ツ門まあな (Maana Mitsukado) - Female\n\
モリーボイド (Molly Boyd) - Female\n\
オルガブヤチッチ (Olga Buyachich) - Female\n\
アッチャラー ギッティ (Atchara Gitti) - Female\n\
リオ (Rio) - Female\n\
ラビ (Rabi) - Female\n\
'
system = PROMPT if fullPromptFlag else \
f'Output ONLY the {LANGUAGE} translation in the following format: `Translation: <{LANGUAGE.upper()}_TRANSLATION>`'
f'\
You are an expert Eroge Game translator who translates Japanese text to English.\n\
You are going to be translating text from a videogame.\n\
I will give you lines of text, and you must translate each line to the best of your ability.\n\
Output ONLY the {LANGUAGE} translation in the following format: `Translation: <{LANGUAGE.upper()}_TRANSLATION>`'
user = f'{subbedT}'
return characters, system, user
@ -1912,6 +1908,7 @@ def translateText(characters, system, user, history):
response = openai.chat.completions.create(
temperature=0.1,
frequency_penalty=0.1,
presence_penalty=0.1,
model=MODEL,
messages=msg,
)
@ -1933,10 +1930,7 @@ def cleanTranslatedText(translatedText, varResponse):
translatedText = translatedText.replace(target, replacement)
translatedText = resubVars(translatedText, varResponse[1])
if '\n' in translatedText:
return [line for line in translatedText.split('\n') if line]
else:
return [line for line in translatedText.split('\\n') if line]
return [line for line in translatedText.split('\n') if line]
def extractTranslation(translatedTextList, is_list):
pattern = r'<Line(\d+)>[\\]*`?(.*?)[\\]*?`?</Line\d+>'