CREDIT
*Inspired by Kasada, Wolfdua, Snk4211, Nolester, Xiaokuii, great idea from a user.
INSTALLATION
Download the full narrator voice line mod and this mod of the same model you like
~~This mod only contains voice lines that come along with seccond-person words "you, yours,..." which can be converted into first-person, so you will need to have the full voice lines mod and this mod activated, place this mod higher priority in your mod loader
~~
Seem like it no longer work like that, you only need to have one Narrator mod in your mod list, otherwise it won't work together.
Drag in BG3ModManager.

DESCRIPTION
Change the "you, your, you are,..." to "me, my, I am,..." in narrator voice lines so it will become first-person conversation instead of seccond-person, make it more likly to hear your thoughts than hear the Narrator
Tools used to make this mod are uploaded in Miscellaneous files.
[youtube]5J-C2EBOzgk[/youtube]
This mod let TTS (Text-to-speech) AI read Narrator's dialogue, which extracted by STT (Speech-to-text) program
‧˚₊꒷꒦︶꒷꒦꒷︶꒦꒷₊˚‧
STT's script (Google Colaboratory):
from google.colab import drive
drive.mount('/content/drive')
!pip install git+https://github.com/openai/whisper.git
!sudo apt update && sudo apt install ffmpeg
from google.colab import drive
drive.mount('/content/drive')
import os
import shutil
import time
import re
# Define the directory containing .wav files
audio_dir = "/content/drive/MyDrive/audios"
# Define the output directory in Google Drive
output_dir = "/content/drive/MyDrive/Narrator_Out_Large"
# Define the completed directory in Google Drive
completed_dir = "/content/drive/MyDrive/Completed/audios"
# Counter for processed files
counter = 0
# Get the total number of .wav files
total_files = len([name for name in os.listdir(audio_dir) if name.endswith(".wav")])
# Function to replace any existing file or folder
def replace_existing(path):
if os.path.exists(path):
if os.path.isfile(path):
os.remove(path)
else:
shutil.rmtree(path)
# Create the output and completed directories if they don't exist
for dir in [output_dir, completed_dir]:
if not os.path.exists(dir):
os.makedirs(dir)
# Check if there are .txt files in the output directory that have similar names to any .wav files in the audio directory
for filename in os.listdir(output_dir):
if filename.endswith(".txt"):
wav_file = os.path.join(audio_dir, os.path.splitext(filename)[0] + ".wav")
if os.path.exists(wav_file):
shutil.move(wav_file, completed_dir)
# Check if there are .wav files in the completed directory that don't have similar names to any .txt files in the output directory
for filename in os.listdir(completed_dir):
if filename.endswith(".wav"):
txt_file = os.path.join(output_dir, os.path.splitext(filename)[0] + ".txt")
if not os.path.exists(txt_file):
shutil.move(os.path.join(completed_dir, filename), audio_dir)
# Iterate over all files in the directory
for filename in os.listdir(audio_dir):
if filename.endswith(".wav"):
# Full path to the .wav file
wav_file = os.path.join(audio_dir, filename)
# Attempt to transcribe the file up to 5 times
for attempt in range(5):
try:
# Transcribe the .wav file
!whisper "$wav_file" --model large
# If transcription is successful, move the .txt file to Google Drive and print a number
txt_file = "/content/" + os.path.splitext(filename)[0] + ".txt"
# Open the transcribed text file and read its content
with open(txt_file, 'r') as file:
data = file.read()
# Replace multiple "." with a single "."
data = re.sub('\.+', '.', data)
# Replace newline characters with a space to ensure the transcribed text does not contain more than one line
data = data.replace('\n', ' ')
# Write the modified content back to the file
with open(txt_file, 'w') as file:
file.write(data)
# Replace any existing file or folder
replace_existing(os.path.join(output_dir, os.path.basename(txt_file)))
shutil.move(txt_file, output_dir)
# Move the .wav file to the completed directory
shutil.move(wav_file, completed_dir)
# Print the counter for successful transcriptions along with the filename
print(f"Successfully transcribed file number {counter + 1} - {filename}")
print(f"Transcribed content: \n{data}")
# If successful, break the loop and move on to the next file
break
except Exception as e:
print(f"Failed attempt {attempt+1} for {filename}: {e}")
# Wait for a bit before trying again
time.sleep(5)
# Increment the counter for processed files
counter += 1
# Print the progress percentage
print(f"Progress: {round((counter / total_files) * 100, 2)}%")
print("[================ TRANSCRIPTION COMPLETED ================]")
Converting script (downloadable in Miscellaneous files):
import os
import glob
import re
import csv
import json
import shutil
import tkinter as tk
from tkinter import filedialog
CONFIG_FILE = "last_paths.json"
AUTO_FIX_FILE = "auto_fixes.json"
# Fault patterns used only for flagging after conversion (defensive net)
FAULT_PATTERNS = [
r"\bme['’]ll\b", r"\bme['’]re\b", r"\bme['’]ve\b", r"\bme['’]d\b",
r"\bI['’]re\b", r"\bI are\b",
r"\bI to\b", r"\bI of\b", r"\bI into\b", r"\bI for\b", r"\bI with\b",
r"\bme and\b", r"\band me\b",
r"\bfills I\b", r"\bforcing I\b", r"\brestricting I\b", r"\blocking I\b",
r"\bwanted I to\b", r"\bhits I\b", r"\bme will\b", r"\bme guide\b",
r"\bme may\b", r"\bstands I\b", r"\bknows I\b", r"\bme sense\b",
r"\bme and me\b", r"\bme perform\b", r"\bcall I\b", r"\ballows I\b",
r"\bme watch\b", r"\bme notice\b", r"\bme trust\b", r"\bknow me will\b"
]
PREPOSITIONS = [
"to", "for", "at", "with", "from", "into", "onto", "over", "under", "near", "by", "against",
"about", "around", "before", "after", "between", "among", "through", "across", "within",
"without", "inside", "outside", "upon", "past", "via", "toward", "towards", "above", "below",
"behind", "beside", "besides", "beyond", "during", "except", "like", "unlike", "per", "past",
"around", "along", "amid", "amidst", "beneath", "off", "out", "onto", "up", "down", "across",
"because"
]
prep_group = r"(?:%s)" % "|".join(map(re.escape, PREPOSITIONS))
def load_last_paths():
if os.path.exists(CONFIG_FILE):
try:
with open(CONFIG_FILE, "r", encoding="utf-8") as f:
return json.load(f)
except Exception:
return {}
return {}
def save_last_paths(source, dest, last_index=0):
with open(CONFIG_FILE, "w", encoding="utf-8") as f:
json.dump({"source": source, "dest": dest, "last_index": last_index}, f, ensure_ascii=False, indent=2)
def load_auto_fixes():
if os.path.exists(AUTO_FIX_FILE):
with open(AUTO_FIX_FILE, "r", encoding="utf-8") as f:
return json.load(f)
return {}
def save_auto_fixes(fixes):
with open(AUTO_FIX_FILE, "w", encoding="utf-8") as f:
json.dump(fixes, f, ensure_ascii=False, indent=2)
def build_rules():
rules = []
# Plural "you all" → "we"
plural_pairs = [
("you all are", "we are"), ("you all were", "we were"), ("you all have", "we have"),
("you all had", "we had"), ("you all will", "we will"), ("you all would", "we would"),
("you all should", "we should"), ("you all could", "we could"), ("you all might", "we might"),
("you all must", "we must"), ("you all can", "we can"), ("you all cannot", "we cannot"),
("you all do", "we do"), ("you all did", "we did"), ("you all go", "we go"),
("you all went", "we went"), ("you all need", "we need"), ("you all want", "we want"),
("you all like", "we like"), ("you all love", "we love"), ("you all think", "we think"),
("you all know", "we know"), ("you all say", "we say"), ("you all tell", "we tell"),
("you all see", "we see"), ("you all feel", "we feel"), ("you all understand", "we understand"),
("you all", "we")
]
for src, tgt in plural_pairs:
rules.append((re.compile(r"\b" + re.escape(src) + r"\b", re.IGNORECASE), tgt, src))
# Inversion/questions
question_pairs = [
("are you", "am I"), ("were you", "was I"), ("do you", "do I"), ("did you", "did I"),
("will you", "will I"), ("would you", "would I"), ("should you", "should I"),
("could you", "could I"), ("might you", "might I"), ("must you", "must I"),
("can you", "can I"), ("have you", "have I"), ("had you", "had I")
]
for src, tgt in question_pairs:
rules.append((re.compile(r"\b" + re.escape(src) + r"\b", re.IGNORECASE), tgt, src))
# Preposition rules
rules.append((re.compile(r"\b" + prep_group + r"(?:\s+\w+){0,5}\s+you\b", re.IGNORECASE), None, "<prep> you → <prep> me"))
rules.append((re.compile(r"\b" + prep_group + r"(?:\s+\w+){0,5}\s+you\s+and\s+(\w+)\b", re.IGNORECASE), None, "<prep> you and X → <prep> me and X"))
# Explicit subject-form replacements first
subject_pairs = [
(r"you['’]ll", "I'll"), (r"you['’]re", "I'm"), (r"you['’]ve", "I've"), (r"you['’]d", "I'd"),
("you are", "I am"), ("you were", "I was"), ("you have", "I have"), ("you had", "I had"),
("you will", "I will"), ("you would", "I would"), ("you should", "I should"),
("you could", "I could"), ("you might", "I might"), ("you must", "I must"),
("you can", "I can"), ("you cannot", "I cannot"), ("you do", "I do"), ("you did", "I did"),
("you go", "I go"), ("you went", "I went"), ("you need", "I need"), ("you want", "I want"),
("you like", "I like"), ("you love", "I love"), ("you think", "I think"), ("you know", "I know"),
("you say", "I say"), ("you tell", "I tell"), ("you see", "I see"), ("you feel", "I feel"),
("you understand", "I understand")
]
for src, tgt in subject_pairs:
rules.append((re.compile(r"\b" + re.escape(src) + r"\b", re.IGNORECASE), tgt, src))
# Generic subject rule — skip auxiliaries
rules.append((re.compile(r"(^|\.\s+|\?\s+|!\s+|\b(?:but|and|or|so|yet|nor|for)\b[\s,;:]+)you\s+(?!are|were|have|had|will|would|should|could|can|might|must|do|did|go|went|need|want|like|love|think|know|say|tell|see|feel|understand\b)([a-z]+)", re.IGNORECASE), None, "<generic subject> you → I"))
# Start-of-sentence modal subject rule
rules.append((re.compile(r"(^|\.\s+|\?\s+|!\s+)(?:\w+\s+)?you\s+(shall|will|would|should|can|could|may|might|must)\b", re.IGNORECASE), None, "<start subj modal> you → I"))
# Relative clause subject (you/me + verb) → I + verb
rules.append((re.compile(r"\b(?:you|me)\s+([a-z]+ed|[a-z]+en|took|made|gave|found|saw|said|left|kept|held|take|make|give|find|see|say|leave|keep|hold|sense|watch|notice|trust)\b", re.IGNORECASE), None, "<relclause subj> you/me → I"))
# Verb + you (object) → verb + me
aux = r"(?:is|was|were|am|are|will|would|should|could|can|may|might|must|has|have|had)"
verb_forms = r"(?:[a-z]+ed|[a-z]+ing|[a-z]+s?)"
rules.append((re.compile(r"(?<!^)(?<![\.!?]\s)(?<!,\s)(?:" + aux + r"\s+)?\w+(?:ed|ing|es|s)?\s+you\b(?!\s+" + verb_forms + r")", re.IGNORECASE), None, "<verb> you → <verb> me"))
# Object "I" after verb → "me" (expanded verbs)
rules.append((re.compile(r"\b(bid(?:s|ded|ding)?|fill(?:s|ed)?|force(?:s|d)?|urge(?:s|d)?|ascend(?:s|ed|ing)?|command(?:s|ed|ing)?|allow(?:s|ed|ing)?|want(?:s|ed)?|rob(?:s|bed|bing)?|reduce(?:s|d|ing)?|lock(?:s|ed|ing)?|restrict(?:s|ed|ing)?|hit(?:s|ting)?|know(?:s|n)?|stand(?:s|ing)?|call(?:s|ed|ing)?)\s+I\b", re.IGNORECASE), None, "<verb> I (object) → <verb> me"))
# Infinitive: "to verb I" → "to verb me"
rules.append((re.compile(r"\bto\s+(bid|command|ascend|fill|force|urge|allow|want|rob|reduce|lock|restrict|hit|know|stand|call)\s+I\b", re.IGNORECASE), None, "to + verb + I → to + verb + me"))
# Quick nets for common phrases
rules.append((re.compile(r"\bfills I\b", re.IGNORECASE), "fills me", "fills I → fills me"))
rules.append((re.compile(r"\bforcing I\b", re.IGNORECASE), "forcing me", "forcing I → forcing me"))
rules.append((re.compile(r"\brestricting I\b", re.IGNORECASE), "restricting me", "restricting I → restricting me"))
rules.append((re.compile(r"\blocking I\b", re.IGNORECASE), "blocking me", "blocking I → blocking me"))
rules.append((re.compile(r"\bwanted I to\b", re.IGNORECASE), "wanted me to", "wanted I to → wanted me to"))
rules.append((re.compile(r"\bhits I\b", re.IGNORECASE), "hits me", "hits I → hits me"))
rules.append((re.compile(r"\bknows I\b", re.IGNORECASE), "knows me", "knows I → knows me"))
rules.append((re.compile(r"\bstands I\b", re.IGNORECASE), "stands me", "stands I → stands me"))
rules.append((re.compile(r"\bcall I\b", re.IGNORECASE), "call me", "call I → call me"))
rules.append((re.compile(r"\ballows I\b", re.IGNORECASE), "allows me", "allows I → allows me"))
# Coordination
rules.append((re.compile(r"(^|\.\s+|\?\s+|!\s+)you\s+and\s+(\w+)", re.IGNORECASE), None, "You and X (subject) → I and X"))
rules.append((re.compile(r"\b([a-z]+(?:ed|ing|es|s)?)\s+you\s+and\s+(\w+)\b", re.IGNORECASE), None, "verb + you and X (object) → verb + me and X"))
# Punctuation + you
rules.append((re.compile(r"([,;:])\s+you\b", re.IGNORECASE), None, "punctuation + you → me/I"))
# Possessives/reflexives
poss_pairs = [("yourself", "myself"), ("yourselves", "ourselves"), ("yours", "mine"), ("your", "my")]
for src, tgt in poss_pairs:
rules.append((re.compile(r"\b" + re.escape(src) + r"\b", re.IGNORECASE), tgt, src))
# Fallback
rules.append((re.compile(r"\byou\b", re.IGNORECASE), "I", "you → I"))
return rules
def cap_aware_replace(matched_text, replacement):
if matched_text and matched_text[0].isupper():
return replacement[0].upper() + replacement[1:]
return replacement
def auto_fix_faults(text, writer, filename, custom_fixes):
# Preserve capitalization for simple phrase replacements
def sub_ci(pattern, repl):
before = text
text_local = re.sub(pattern, lambda m: cap_aware_replace(m.group(0), repl), before, flags=re.IGNORECASE)
if text_local != before:
writer.writerow([filename, f"Auto-fix: {pattern}", repl,
len(re.findall(pattern, before, flags=re.IGNORECASE))])
return text_local
# Apply custom fixes first to avoid conflicts
for bad, good in custom_fixes.items():
pat = r"\b" + re.escape(bad) + r"\b"
before = text
text_local = re.sub(pat, lambda m: cap_aware_replace(m.group(0), good), before, flags=re.IGNORECASE)
if text_local != before:
cnt = len(re.findall(pat, before, flags=re.IGNORECASE))
writer.writerow([filename, f"Auto-fix (custom): {bad}", good, cnt])
text = text_local
# 1) Contractions / copulas
fixes = [
(r"\bI['’]re\b", "I'm"),
(r"\bI are\b", "I am"),
(r"\bme['’]re\b", "I'm"),
(r"\bme['’]ve\b", "I've"),
(r"\bme['’]ll\b", "I'll"),
(r"\bme['’]d\b", "I'd"),
(r"\bI['’]re\s+being\b", "I'm being"),
(r"\bI['’]re\s+used\b", "I'm used"),
(r"\bI['’]re\s+reminded\b", "I'm reminded"),
(r"\bI['’]re\s+stopped\b", "I'm stopped"),
(r"\bI['’]re\s+headed\b", "I'm headed"),
(r"\bI['’]re\s+free\b", "I'm free"),
(r"\bI['’]re\s+about\b", "I'm about"),
(r"\bI['’]re\s+still\b", "I'm still"),
(r"\bI['’]re\s+relieved\b", "I'm relieved"),
(r"\bI['’]re\s+under\b", "I'm under"),
(r"\bI['’]re\s+accused\b", "I'm accused"),
(r"\bI['’]re\s+allowed\b", "I'm allowed"),
(r"\bI['’]re\s+destined\b", "I'm destined"),
(r"\bI['’]re\s+surprised\b", "I'm surprised"),
(r"\bI['’]re\s+looking\b", "I'm looking"),
(r"\bI['’]re\s+but\b", "I'm but"),
(r"\bI['’]re\s+not\b", "I'm not"),
(r"\bI['’]re\s+clearly\b", "I'm clearly"),
(r"\bme will\b", "I will"),
(r"\bknow me will\b", "know I will"),
(r"\bme may\b", "I may"),
(r"\bme guide\b", "I guide"),
(r"\bme sense\b", "I sense"),
(r"\bme perform\b", "I perform"),
(r"\bme watch\b", "I watch"),
(r"\bme notice\b", "I notice"),
(r"\bme trust\b", "I trust")
]
# 2) Preposition + I → me
fixes += [
(r"\bI to\b", "me to"),
(r"\bI of\b", "me of"),
(r"\bI into\b", "me into"),
(r"\bI for\b", "me for"),
(r"\bI with\b", "me with"),
(r"\brestricting I\b", "restricting me"),
(r"\blocking I\b", "blocking me"),
(r"\blocking I\b", "locking me")
]
# 3) Specific multiword patterns and common phrases
fixes += [
(r"\bme realize\b", "I realize"),
(r"\bme realise\b", "I realise"),
(r"\bme['’]d expect\b", "I'd expect"),
(r"\bI can tell me['’]re\b", "I can tell I'm"),
(r"\bme['’]re sure\b", "I'm sure"),
(r"\bme thought\b", "I thought"),
(r"\bme['’]ve worked\b", "I've worked"),
(r"\bme['’]ve offered\b", "I've offered"),
(r"\bme['’]ve got\b", "I've got"),
(r"\bme['’]ve made\b", "I've made"),
(r"\bme['’]ve taken\b", "I've taken"),
(r"\bme['’]ve seen\b", "I've seen"),
(r"\bme['’]ve met\b", "I've met"),
(r"\bme['’]ve escaped\b", "I've escaped"),
(r"\bme['’]ve thwarted\b", "I've thwarted"),
(r"\bme['’]ve claimed\b", "I've claimed"),
(r"\bme['’]ve unburdened\b", "I've unburdened"),
(r"\bme['’]ve studied\b", "I've studied"),
(r"\bme['’]ve had dealings\b", "I've had dealings"),
(r"\bme['’]ve ever known\b", "I've ever known"),
(r"\bme['’]re going\b", "I'm going"),
(r"\bwanted I to\b", "wanted me to"),
(r"\bfills I\b", "fills me"),
(r"\bforcing I\b", "forcing me"),
(r"\brestricting I\b", "restricting me"),
(r"\blocking I\b", "blocking me"),
(r"\bIt will make I\b", "It will make me"),
(r"\bmake I\b", "make me"),
(r"\bforce I\b", "force me"),
(r"\bforces I\b", "forces me"),
(r"\brob(?:bing)? I\b", "robbing me"),
(r"\breduce(?:d|s|ing)? I\b", "reduce me"),
(r"\bleading I\b", "leading me"),
(r"\bbid I\b", "bid me"),
(r"\btells I\b", "tells me"),
(r"\bwants I\b", "wants me"),
(r"\bhits I\b", "hits me"),
(r"\bknows I\b", "knows me"),
(r"\bstands I\b", "stands me"),
(r"\bcall I\b", "call me"),
(r"\ballows I\b", "allows me"),
(r"\bme and me\b", "me")
]
# Apply simple phrase fixes
for pat, repl in fixes:
text = sub_ci(pat, repl)
# 4) Verb + I (object) → verb + me (expanded)
verb_object_patterns = [
r"\b(bid(?:s|ded|ding)?|fill(?:s|ed)?|force(?:s|d)?|urge(?:s|d)?|ascend(?:s|ed|ing)?|command(?:s|ed|ing)?|allow(?:s|ed|ing)?|want(?:s|ed)?|rob(?:s|bed|bing)?|reduce(?:s|d|ing)?|lock(?:s|ed|ing)?|restrict(?:s|ed|ing)?|hit(?:s|ting)?|know(?:s|n)?|stand(?:s|ing)?|call(?:s|ed|ing)?)\s+I\b"
]
for pat in verb_object_patterns:
before = text
text_local = re.sub(pat, lambda m: f"{m.group(1)} me", before, flags=re.IGNORECASE)
if text_local != before:
cnt = len(re.findall(pat, before, flags=re.IGNORECASE))
writer.writerow([filename, "Auto-fix: verb + I (object)", "verb + me", cnt])
text = text_local
# 5) Infinitive verb + I (object)
inf_object_patterns = [
r"\bto\s+(bid|command|ascend|fill|force|urge|allow|want|rob|reduce|lock|restrict|hit|know|stand|call)\s+I\b"
]
for pat in inf_object_patterns:
before = text
text_local = re.sub(pat, lambda m: f"to {m.group(1)} me", before, flags=re.IGNORECASE)
if text_local != before:
cnt = len(re.findall(pat, before, flags=re.IGNORECASE))
writer.writerow([filename, "Auto-fix: to + verb + I (object)", "to + verb + me", cnt])
text = text_local
# 6) Coordinations with me → I (subject), and object ordering
# "me and Name" → "Name and I" (subject)
before = text
text_local = re.sub(r"\bme and ([A-Z][\w'-]+)\b(?=\s+(?:am|are|is|was|were|will|would|should|could|can|might|must|do|did|go|went|need|want|like|love|think|know|say|tell|see|feel|understand|perform|sense|watch|notice|trust)\b)", lambda m: f"{m.group(1)} and I", text, flags=re.IGNORECASE)
if text_local != before:
cnt = len(re.findall(r"\bme and ([A-Z][\w'-]+)\b(?=\s+(?:am|are|is|was|were|will|would|should|could|can|might|must|do|did|go|went|need|want|like|love|think|know|say|tell|see|feel|understand|perform|sense|watch|notice|trust)\b)", before, flags=re.IGNORECASE))
writer.writerow([filename, "Auto-fix: me and Name (subject) → Name and I", "Name and I", cnt])
text = text_local
# "Name and me" → "Name and I" (subject)
before = text
text_local = re.sub(r"\b([A-Z][\w'-]+) and me\b(?=\s+(?:am|are|is|was|were|will|would|should|could|can|might|must|do|did|go|went|need|want|like|love|think|know|say|tell|see|feel|understand|perform|sense|watch|notice|trust)\b)", lambda m: f"{m.group(1)} and I", text, flags=re.IGNORECASE)
if text_local != before:
cnt = len(re.findall(r"\b([A-Z][\w'-]+) and me\b(?=\s+(?:am|are|is|was|were|will|would|should|could|can|might|must|do|did|go|went|need|want|like|love|think|know|say|tell|see|feel|understand|perform|sense|watch|notice|trust)\b)", before, flags=re.IGNORECASE))
writer.writerow([filename, "Auto-fix: Name and me (subject) → Name and I", "Name and I", cnt])
text = text_local
# "Name and me" → "Name and me" (object, preserve if correct)
before = text
text_local = re.sub(r"\b([A-Z][\w'-]+) and me\b(?!\s+(?:am|are|is|was|were|will|would|should|could|can|might|must|do|did|go|went|need|want|like|love|think|know|say|tell|see|feel|understand|perform|sense|watch|notice|trust)\b)", lambda m: f"{m.group(1)} and me", text, flags=re.IGNORECASE)
if text_local != before:
cnt = len(re.findall(r"\b([A-Z][\w'-]+) and me\b(?!\s+(?:am|are|is|was|were|will|would|should|could|can|might|must|do|did|go|went|need|want|like|love|think|know|say|tell|see|feel|understand|perform|sense|watch|notice|trust)\b)", before, flags=re.IGNORECASE))
writer.writerow([filename, "Auto-fix: Name and me (object) → Name and me", "Name and me", cnt])
text = text_local
# 7) Common narrative nets
text = sub_ci(r"\bwanted I to\b", "wanted me to")
text = sub_ci(r"\bleading I\b", "leading me")
text = sub_ci(r"\blocking I\b", "locking me")
text = sub_ci(r"\brestricting I\b", "restricting me")
text = sub_ci(r"\bhits I\b", "hits me")
text = sub_ci(r"\bknows I\b", "knows me")
text = sub_ci(r"\bstands I\b", "stands me")
text = sub_ci(r"\bcall I\b", "call me")
text = sub_ci(r"\ballows I\b", "allows me")
return text
def apply_rules(text, writer, filename, rules):
total_changes = 0
for pattern, replacement, label in rules:
if label.startswith("<prep>"):
def repl(m):
parts = m.group(0).split()
parts[-1] = "me"
rep = " ".join(parts)
return rep[0].upper() + rep[1:] if m.group(0)[0].isupper() else rep
matches = pattern.findall(text)
if matches:
total_changes += len(matches)
text = pattern.sub(repl, text)
writer.writerow([filename, label, "(contextual)", len(matches)])
elif label == "<start subj modal> you → I":
def repl(m):
prefix = m.group(1)
match_text = m.group(0).strip()
parts = match_text.split()
if len(parts) == 3:
preword = parts[0] + " "
modal = parts[2]
return f"{prefix}{preword}I {modal}"
else:
modal = parts[1]
return f"{prefix}I {modal}"
matches = pattern.findall(text)
if matches:
total_changes += len(matches)
text = pattern.sub(repl, text)
writer.writerow([filename, label, "(contextual)", len(matches)])
elif label == "<generic subject> you → I":
def repl(m):
prefix = m.group(1)
verb = m.group(2)
return f"{prefix}I {verb}"
matches = pattern.findall(text)
if matches:
total_changes += len(matches)
text = pattern.sub(repl, text)
writer.writerow([filename, label, "(contextual)", len(matches)])
elif label == "<relclause subj> you/me → I":
matches = pattern.findall(text)
if matches:
total_changes += len(matches)
text = pattern.sub(lambda m: "I " + m.group(1), text)
writer.writerow([filename, label, "(contextual)", len(matches)])
elif label == "<verb> you → <verb> me":
def repl(m):
return re.sub(r"\byou\b", "me", m.group(0), flags=re.IGNORECASE)
matches = pattern.findall(text)
if matches:
total_changes += len(matches)
text = pattern.sub(repl, text)
writer.writerow([filename, label, "(contextual)", len(matches)])
elif label == "<verb> I (object) → <verb> me":
matches = pattern.findall(text)
if matches:
total_changes += len(matches)
text = pattern.sub(lambda m: f"{m.group(1)} me", text)
writer.writerow([filename, label, "(contextual)", len(matches)])
elif label == "to + verb + I → to + verb + me":
matches = pattern.findall(text)
if matches:
total_changes += len(matches)
text = pattern.sub(lambda m: f"to {m.group(1)} me", text)
writer.writerow([filename, label, "(contextual)", len(matches)])
elif label == "than you → than me":
matches = pattern.findall(text)
if matches:
total_changes += len(matches)
text = pattern.sub("than me", text)
writer.writerow([filename, label, "(contextual)", len(matches)])
elif label == "You and X (subject) → I and X":
def repl(m):
prefix = m.group(1)
rest = re.sub(r"\byou\b", "I", m.group(0), flags=re.IGNORECASE)
return prefix + rest[len(prefix):]
matches = pattern.findall(text)
if matches:
total_changes += len(matches)
text = pattern.sub(repl, text)
writer.writerow([filename, label, "(contextual)", len(matches)])
elif label == "verb + you and X (object) → verb + me and X":
matches = pattern.findall(text)
if matches:
total_changes += len(matches)
text = pattern.sub(lambda m: f"{m.group(1)} me and {m.group(2)}", text)
writer.writerow([filename, label, "(contextual)", len(matches)])
elif label.startswith("punctuation + you"):
def repl(m):
after = text[m.end():].lstrip()
if re.match(r"[A-Za-z]+", after) and after.split()[0].lower() not in PREPOSITIONS:
return m.group(1) + " I"
else:
return m.group(1) + " me"
matches = pattern.findall(text)
if matches:
total_changes += len(matches)
text = pattern.sub(repl, text)
writer.writerow([filename, label, "(contextual)", len(matches)])
else:
matches = pattern.findall(text)
if matches and isinstance(replacement, str):
total_changes += len(matches)
text = pattern.sub(lambda m: cap_aware_replace(m.group(0), replacement), text)
writer.writerow([filename, label, replacement, len(matches)])
return text, total_changes
def has_faults(text, patterns):
return any(re.search(p, text) for p in patterns)
def main():
last_paths = load_last_paths()
custom_fixes = load_auto_fixes()
root = tk.Tk()
root.withdraw()
# Source folder
if last_paths.get("source") and os.path.exists(last_paths["source"]):
use_last = input(f"Last source folder: {last_paths['source']}\nUse this? (y/n): ").strip().lower()
if use_last == "y":
source_folder = last_paths["source"]
else:
source_folder = filedialog.askdirectory(title="Select folder with .txt files to convert")
else:
source_folder = filedialog.askdirectory(title="Select folder with .txt files to convert")
if not source_folder:
print("⚠ No source folder selected. Script will stop here.")
input("Press Enter to close...")
return
# Destination folder
if last_paths.get("dest") and os.path.exists(last_paths["dest"]):
use_last = input(f"Last destination folder: {last_paths['dest']}\nUse this? (y/n): ").strip().lower()
if use_last == "y":
dest_folder = last_paths["dest"]
else:
dest_folder = filedialog.askdirectory(title="Select folder to save converted files")
else:
dest_folder = filedialog.askdirectory(title="Select folder to save converted files")
if not dest_folder:
print("⚠ No destination folder selected. Script will stop here.")
input("Press Enter to close...")
return
# Create Skipped and Flagged folders
skipped_folder = os.path.join(dest_folder, "Skipped")
flagged_folder = os.path.join(dest_folder, "Flagged")
os.makedirs(skipped_folder, exist_ok=True)
os.makedirs(flagged_folder, exist_ok=True)
# CSV log
log_file = os.path.join(dest_folder, "replacement_log.csv")
rules = build_rules()
txt_files = glob.glob(os.path.join(source_folder, "*.txt"))
txt_files.sort()
if not txt_files:
print("ℹ No .txt files found in the source folder.")
input("Press Enter to close...")
return
# Resume logic with 3rd option: start all over
start_index = 0
if last_paths.get("last_index") and last_paths["source"] == source_folder and last_paths["dest"] == dest_folder:
last_idx = last_paths["last_index"]
if 0 <= last_idx < len(txt_files):
resume = input(
f"Last time you stopped after file {last_idx} of {len(txt_files)}.\n"
f"Resume from there (n), reprocess that last file too (y), or start all over (s)? (y/n/s): "
).strip().lower()
if resume == "y":
start_index = max(last_idx - 1, 0)
elif resume == "n":
start_index = last_idx
elif resume == "s":
start_index = 0
save_all = False
last_converted_path = None
with open(log_file, "w", newline="", encoding="utf-8") as csvfile:
writer = csv.writer(csvfile)
writer.writerow(["Filename", "Original Pattern", "Replacement", "Count"])
for i in range(start_index, len(txt_files)):
filepath = txt_files
with open(filepath, "r", encoding="utf-8") as f:
original_text = f.read()
converted_text, changes = apply_rules(original_text, writer, os.path.basename(filepath), rules)
converted_text = auto_fix_faults(converted_text, writer, os.path.basename(filepath), custom_fixes)
# If faults remain after conversion, save to Flagged
if has_faults(converted_text, FAULT_PATTERNS):
flagged_path = os.path.join(flagged_folder, os.path.basename(filepath))
with open(flagged_path, "w", encoding="utf-8") as out:
out.write(converted_text)
print(f"⚠ Flagged — saved to: {flagged_path}")
save_last_paths(source_folder, dest_folder, i+1)
continue
if changes or converted_text != original_text:
print("\n" + "="*70)
print(f"📄 File: {os.path.basename(filepath)} (changes: {changes})")
print("-"*70)
print("🔹 Original:")
print(original_text.strip()[:700] + ("..." if len(original_text) > 700 else ""))
print("\n🔹 Converted:")
print(converted_text.strip()[:700] + ("..." if len(original_text) > 700 else ""))
print("="*70)
if not save_all:
choice = input("Save this converted file? (y=save / n=skip / a=save all remaining): ").strip().lower()
if choice == "a":
save_all = True
elif choice != "y":
skipped_path = os.path.join(skipped_folder, os.path.basename(filepath))
shutil.copy2(filepath, skipped_path)
print(f"⏩ Skipped — copied to: {skipped_path}")
save_last_paths(source_folder, dest_folder, i+1)
continue
dest_path = os.path.join(dest_folder, os.path.basename(filepath))
with open(dest_path, "w", encoding="utf-8") as out:
out.write(converted_text)
last_converted_path = dest_path
print("✅ Saved.")
else:
print(f"ℹ No changes needed for {os.path.basename(filepath)} — copying to Skipped folder.")
skipped_path = os.path.join(skipped_folder, os.path.basename(filepath))
shutil.copy2(filepath, skipped_path)
print(f"📂 Copied original to: {skipped_path}")
save_last_paths(source_folder, dest_folder, i+1)
if last_converted_path and os.path.exists(last_converted_path):
with open(last_converted_path, "r", encoding="utf-8") as f:
content = f.read()
bad_patterns = ["me'll", "me're", "me've", "me'd", "I into", "I to", "I of", "I're", "I are", "me and ", " and me", "fills I", "forcing I", "restricting I", "locking I", "wanted I to", "hits I", "me will", "me guide", "me may", "stands I", "knows I", "me sense", "me and me", "me perform", "call I", "allows I", "me watch", "me notice", "me trust", "know me will"]
found = [p for p in bad_patterns if p in content]
if found:
print(f"⚠ Warning: Found possible bad replacements in last file: {', '.join(found)}")
else:
print("✅ Last converted file passed basic sanity check.")
# Self-learning: ask user for new fixes
while True:
bad = input("Enter a wrong phrase to auto-fix next time (or press Enter to finish): ").strip()
if not bad:
break
good = input(f"What should '{bad}' be replaced with? ").strip()
if good:
custom_fixes[bad] = good
print(f"✅ Learned: '{bad}' → '{good}'")
save_auto_fixes(custom_fixes)
print(f"\n✅ Processing complete. Converted files saved to: {dest_folder}")
print(f"📄 Log saved to: {log_file}")
input("\nPress Enter to close...")
[
](https://ko-fi.com/thma2908) 
来源与文件
- 原作者:ToxicDrake
- 原项目:YOU Narrator
- 文件:请在 N 网项目文件页选择适合的版本或变体。
- N 网项目版本(非单个文件版本):1
前往 N 网文件页选择并获取文件。安装与下载要求以原作者及平台说明为准。
<!-- aoe-mods-source:nexusmods:baldursgate3:18817 -->