| # Programm zur Behebung des UTF-8-Encoding-Problems | |
| def fix_encoding(file_path): | |
| # Öffnen der Datei zum Lesen | |
| with open(file_path, 'r', encoding='latin1') as file: | |
| lines = file.readlines() | |
| # Überprüfen, ob die Encoding-Zeile bereits vorhanden ist | |
| if not lines[0].startswith("# -*- coding: utf-8 -*-"): | |
| # UTF-8-Encoding-Zeile hinzufügen | |
| lines.insert(0, "# -*- coding: utf-8 -*-\n") | |
| # Schreiben der geänderten Datei | |
| with open(file_path, 'w', encoding='utf-8') as file: | |
| file.writelines(lines) | |
| # Beispiel für die Verwendung | |
| file_path = "segmentation_infer_html.py" #"annotate-context-caps.py" #"embed_contexts_e5_small.py" #"whisper_softprompt_e5_finetune.py"# '/mnt/raid/spirit/emonet-text/infer_compare_embed_only.py' #emo_acting_prompts.py' # Pfad zur Datei | |
| fix_encoding(file_path) | |