art-from-the-machine / Mantella

Mantella is a Skyrim and Fallout 4 mod which allows you to naturally speak to NPCs using Whisper (speech-to-text), LLMs (text generation), and xVASynth / XTTS (text-to-speech).
https://art-from-the-machine.github.io/Mantella/
GNU Affero General Public License v3.0
169 stars 42 forks source link

v12 config.ini locations. #337

Closed wiseman-timelord closed 1 month ago

wiseman-timelord commented 1 month ago

Mantella v11 saves the config.ini in a safe location of the mantella dir, however, with regards to v12...

Leidtier commented 1 month ago

Thanks for reporting, I'll take a look at it.

wiseman-timelord commented 1 month ago

According to GPT4...

import ctypes
from ctypes import wintypes
import os

def get_documents_folder():
    # Define constants for the SHGetFolderPath function
    CSIDL_PERSONAL = 5  # CSIDL for "My Documents" folder
    SHGFP_TYPE_CURRENT = 0

    # Buffer to store the folder path
    buf = ctypes.create_unicode_buffer(wintypes.MAX_PATH)

    # Load shell32.dll and call SHGetFolderPathW
    shell32 = ctypes.windll.shell32
    result = shell32.SHGetFolderPathW(None, CSIDL_PERSONAL, None, SHGFP_TYPE_CURRENT, buf)

    if result == 0:  # S_OK
        return buf.value
    else:
        raise Exception("Failed to get 'My Documents' folder path")

documents_path = get_documents_folder()
print("My Documents folder is located at:", documents_path)

def get_documents_folder_using_expanduser():

Use os.path.expanduser to get the path relative to the user's home directory

home_directory = os.path.expanduser("~")
documents_folder = os.path.join(home_directory, "Documents")

return documents_folder

Fetch and print the path

documents_path = get_documents_folder_using_expanduser() print("My Documents folder (via expanduser) is located at:", documents_path)

Leidtier commented 1 month ago

I have commited a PR #343 to fix this. @wiseman-timelord I used your second solution because I also stumbled over it when researching the issue. Could you please check if this simple change is enough to fix the issue for you?