/Kingmaker-MoreVoiceLines

Modification for Pathfinder: Kingmaker cRPG game to add more voice lines, for now only Jaethal from AI voice cloning.

Primary LanguageC#

More Voice Lines for Pathfinder: Kingmaker

This is modification for Pathfinder: Kingmaker. Uses Unity Mod Manager and 0Harmony. Audio files along with some configuration are required. For now, only Jaethal voice lines are done (at least by me), but you are free to contact me via GitHub Issues or e-mail if you want to contribute more. The repository also includes notes on voice clonning & scripts I used for generating Jaethal.

You can download the mod from Nexus Mods.

Notes

  • Voice over requests from game are detected by LocalizedString.PlayVoiceOver patch. We map those strings UUIDs to audio files, with special "recipe" that describes which actual files are to be used, in what order. Some suffixes are expected for sex or kingdom status dependent dialogues.

  • Audio files should be placed in audio directory inside mod directory. I used AI generated samples with 44100 Hz sample rate single channel (mono), but the mod can also play any other sample rate and stereo (might require tweaking the AudioPlaybackEngine instance on audio player side for better performance).

  • Next to the audio folder there should be audio_metadata.csv, | separated file with columns: LocalizedStringUUID, Companion (unused actually), Recipe and RawText (also unused).

  • Modification uses external executable (outside the game) for playing the sound, sources are of course included in the repository, as I failed to found another way.

    • I couldn't get Unity AudioClip to work

      Neither UnityWebRequestMultimedia.GetAudioClip nor WWW.GetAudioClip worked for me, maybe because wierd WAV format. They did load the bytes, but did not produce usable AudioClip (length was 0). I tried manually AudioClip.Create and AudioClip.SetData, with custom WAV parsing. Sadly I always got AudioClip.GetData failed; AudioClip contains no data (on SetData), because for some fucking reason Create, despite having channels parameter, always creates 0 channles.

    • I tried using C# MediaPlayer and SoundPlayer, but had issues with dependencies (WPF disagrees with Unity). Maybe one day someone (or me) will try using SoundPlayer tho.

    • For now, ended up using separated process with NAudio library to playback the audio files, communicates with game process using named pipes IPC, one receiving requests from game, other sending notifcations when audio/recipe finishes.

To-do

  • Add detecting missing dialogues to the mod; save to file and keep showing "notification" on the mod settings asking user to upload their logs/update the mod.
  • Replace dialogues referencing player character name by something more generic (for now it's fixed to use my character Elizabeth).
  • Add pitch setting
  • Add speed setting
  • Add re-focus option, as sometimes game window doesn't get focus, maybe because conosle window (even if hidden) blinks.
  • Allow skip part of the voice line using space, if possible using speed up