Fix .env not updating and fix langregex false positives
This commit is contained in:
parent
8828173f2f
commit
417df900d3
3 changed files with 106 additions and 46 deletions
|
|
@ -540,31 +540,30 @@ class ConfigTab(QWidget):
|
||||||
# Ensure .env file exists
|
# Ensure .env file exists
|
||||||
if not self.env_file_path.exists():
|
if not self.env_file_path.exists():
|
||||||
self.env_file_path.touch()
|
self.env_file_path.touch()
|
||||||
|
|
||||||
# Save API settings (trim whitespace to prevent accidental spaces in .env)
|
|
||||||
set_key(self.env_file_path, "api", self.api_url_edit.text().strip())
|
|
||||||
set_key(self.env_file_path, "key", self.api_key_edit.text().strip())
|
|
||||||
set_key(self.env_file_path, "organization", self.organization_edit.text().strip())
|
|
||||||
set_key(self.env_file_path, "model", self.model_combo.currentText())
|
|
||||||
|
|
||||||
# Save translation settings
|
# Build config dict for both file and os.environ updates
|
||||||
set_key(self.env_file_path, "language", self.language_combo.currentText())
|
config = {
|
||||||
set_key(self.env_file_path, "timeout", str(self.timeout_spin.value()))
|
"api": self.api_url_edit.text().strip(),
|
||||||
|
"key": self.api_key_edit.text().strip(),
|
||||||
|
"organization": self.organization_edit.text().strip(),
|
||||||
|
"model": self.model_combo.currentText(),
|
||||||
|
"language": self.language_combo.currentText(),
|
||||||
|
"timeout": str(self.timeout_spin.value()),
|
||||||
|
"fileThreads": str(self.file_threads_spin.value()),
|
||||||
|
"threads": str(self.threads_spin.value()),
|
||||||
|
"batchsize": str(self.batch_size_spin.value()),
|
||||||
|
"frequency_penalty": str(self.frequency_penalty_spin.value()),
|
||||||
|
"width": str(self.width_spin.value()),
|
||||||
|
"listWidth": str(self.list_width_spin.value()),
|
||||||
|
"noteWidth": str(self.note_width_spin.value()),
|
||||||
|
"input_cost": str(self.input_cost_spin.value()),
|
||||||
|
"output_cost": str(self.output_cost_spin.value()),
|
||||||
|
}
|
||||||
|
|
||||||
# Save performance settings
|
# Save to .env file and update os.environ so subprocesses inherit new values
|
||||||
set_key(self.env_file_path, "fileThreads", str(self.file_threads_spin.value()))
|
for key, value in config.items():
|
||||||
set_key(self.env_file_path, "threads", str(self.threads_spin.value()))
|
set_key(self.env_file_path, key, value)
|
||||||
set_key(self.env_file_path, "batchsize", str(self.batch_size_spin.value()))
|
os.environ[key] = value
|
||||||
set_key(self.env_file_path, "frequency_penalty", str(self.frequency_penalty_spin.value()))
|
|
||||||
|
|
||||||
# Save formatting settings
|
|
||||||
set_key(self.env_file_path, "width", str(self.width_spin.value()))
|
|
||||||
set_key(self.env_file_path, "listWidth", str(self.list_width_spin.value()))
|
|
||||||
set_key(self.env_file_path, "noteWidth", str(self.note_width_spin.value()))
|
|
||||||
|
|
||||||
# Save custom API settings
|
|
||||||
set_key(self.env_file_path, "input_cost", str(self.input_cost_spin.value()))
|
|
||||||
set_key(self.env_file_path, "output_cost", str(self.output_cost_spin.value()))
|
|
||||||
|
|
||||||
if show_message:
|
if show_message:
|
||||||
QMessageBox.information(self, "Success", "Configuration saved successfully!")
|
QMessageBox.information(self, "Success", "Configuration saved successfully!")
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ _speakerCacheLock = threading.Lock()
|
||||||
SPEAKER_COLLECTED = [] # Original speaker names collected during parse mode (untranslated)
|
SPEAKER_COLLECTED = [] # Original speaker names collected during parse mode (untranslated)
|
||||||
|
|
||||||
# Regex - Need to change this if you want to translate from/to other languages. Default is Japanese Regex
|
# Regex - Need to change this if you want to translate from/to other languages. Default is Japanese Regex
|
||||||
LANGREGEX = r"[\u3000-\u303F\u3040-\u309F\u30A0-\u30FF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\uFF00-\uFF5D\uFF5F-\uFFEF]+"
|
LANGREGEX = r"[\u3000-\u303F\u3040-\u309F\u30A0-\u30FB\u30FD-\u30FF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\uFF02-\uFF5D\uFF5F-\uFFEF]+"
|
||||||
|
|
||||||
# Get pricing configuration based on the model
|
# Get pricing configuration based on the model
|
||||||
PRICING_CONFIG = getPricingConfig(MODEL)
|
PRICING_CONFIG = getPricingConfig(MODEL)
|
||||||
|
|
@ -2360,6 +2360,83 @@ def searchCodes(page, pbar, jobList, filename):
|
||||||
if "code" in codeList[i] and codeList[i]["code"] == 101 and CODE101 is True:
|
if "code" in codeList[i] and codeList[i]["code"] == 101 and CODE101 is True:
|
||||||
isVar = False
|
isVar = False
|
||||||
|
|
||||||
|
# Check for Ta_ face name mappings first (before other processing)
|
||||||
|
if FACENAME101 and len(codeList[i]["parameters"]) > 0:
|
||||||
|
faceName = codeList[i]["parameters"][0]
|
||||||
|
if isinstance(faceName, str):
|
||||||
|
if "Ta_Leona" in faceName:
|
||||||
|
speaker = "Leona"
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
if "Ta_Rury" in faceName:
|
||||||
|
speaker = "Rury"
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
if "Ta_Eve" in faceName:
|
||||||
|
speaker = "Eve"
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
if "Ta_Rebekka" in faceName:
|
||||||
|
speaker = "Rebecca"
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
if "Ta_Lapis" in faceName:
|
||||||
|
speaker = "Lapis"
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
if "Ta_Bighand" in faceName:
|
||||||
|
speaker = "Bighand"
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
if "Ta_Frank" in faceName:
|
||||||
|
speaker = "Frank"
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
if "Ta_Gang" in faceName:
|
||||||
|
speaker = "Gang"
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
if "Ta_Gunjin1" in faceName:
|
||||||
|
speaker = "Soldier 1"
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
if "Ta_Gunjin2" in faceName:
|
||||||
|
speaker = "Soldier 2"
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
if "Ta_Jesse" in faceName:
|
||||||
|
speaker = "Jesse"
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
if "Ta_Kotaro" in faceName:
|
||||||
|
speaker = "Kotaro"
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
if "Ta_Marcus" in faceName:
|
||||||
|
speaker = "Marcus"
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
if "Ta_Maxwell" in faceName:
|
||||||
|
speaker = "Maxwell"
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
if "Ta_mitsubai" in faceName:
|
||||||
|
speaker = "Mitsubai"
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
if "Ta_Ronin" in faceName:
|
||||||
|
speaker = "Ronin"
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
if "Ta_Shonin" in faceName:
|
||||||
|
speaker = "Merchant"
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
if "Ta_Yen" in faceName:
|
||||||
|
speaker = "Yen"
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
|
||||||
# Grab String
|
# Grab String
|
||||||
jaString = ""
|
jaString = ""
|
||||||
if len(codeList[i]["parameters"]) > 4:
|
if len(codeList[i]["parameters"]) > 4:
|
||||||
|
|
@ -2451,28 +2528,7 @@ def searchCodes(page, pbar, jobList, filename):
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
speaker = ""
|
speaker = ""
|
||||||
elif FACENAME101:
|
|
||||||
faceName = codeList[i]["parameters"][0]
|
|
||||||
if "kaogura" in faceName:
|
|
||||||
speaker = "Rienie"
|
|
||||||
if faceName == "Actor2_1":
|
|
||||||
speaker = "Suzune"
|
|
||||||
if faceName == "Actor3_1":
|
|
||||||
speaker = "Kaji"
|
|
||||||
if faceName == "Actor4_1":
|
|
||||||
speaker = "Kirari"
|
|
||||||
if faceName == "Actor5_1":
|
|
||||||
speaker = "Onsen"
|
|
||||||
if faceName == "Actor6_1":
|
|
||||||
speaker = "Gufu"
|
|
||||||
if faceName == "Actor7_1":
|
|
||||||
speaker = "Kahimeru"
|
|
||||||
if faceName == "Actor10_1":
|
|
||||||
speaker = "Miuma"
|
|
||||||
if faceName == "Actor11_1":
|
|
||||||
speaker = "Nurari"
|
|
||||||
if faceName == "Actor12_1":
|
|
||||||
speaker = "Kokotsuzumi"
|
|
||||||
|
|
||||||
## Event Code: 355 or 655 Scripts [Optional]
|
## Event Code: 355 or 655 Scripts [Optional]
|
||||||
if "code" in codeList[i] and (codeList[i]["code"] == 355 or codeList[i]["code"] == 655) and CODE355655 is True:
|
if "code" in codeList[i] and (codeList[i]["code"] == 355 or codeList[i]["code"] == 655) and CODE355655 is True:
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,11 @@ import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import io
|
import io
|
||||||
import threading
|
import threading
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
# Load environment variables from .env with override=True to ensure
|
||||||
|
# we always use the latest saved config, not inherited/stale values
|
||||||
|
load_dotenv(override=True)
|
||||||
|
|
||||||
# Set UTF-8 encoding for stdout to handle Unicode characters
|
# Set UTF-8 encoding for stdout to handle Unicode characters
|
||||||
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
|
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue