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 General Public License v3.0
164 stars 41 forks source link

"NPC not added. Please try again after your next response" after using End Conversation hotkey with Text Input #241

Closed jordanbtucker closed 4 months ago

jordanbtucker commented 4 months ago

When using Text Input and pressing the End Conversation hotkey during a conversation, Mantella hangs and Mantella Spell displays the debug message "NPC not added. Please try again after your next response." when attempting to start a new conversation.

This occurs because Transcriber.get_player_response calls game_state_manager.load_data_when_available, which continues to poll _mantella_text_input.txt until its contents have changed. But when the user has pressed the End Conversation hotkey, there is no way for that file to get updated, so load_data_when_available hangs in an endless loop.

I've thought of a couple ways to fix this.

  1. When the End Conversation hotkey is pressed, Mantella Spell should update _mantella_text_input.txt with the end_conversation_keyword to break load_data_when_available out of its loop. I have limited experience writing PSC files, and I'm not sure if Mantella Spells has access to the value of end_conversation_keyword, so I'll leave it up to you if you want to implement a fix there.
  2. Alternatively, Transcriber.get_player_response should not only poll _mantella_text_input.txt, but it should also poll _mantella_end_conversation.txt to see if the player has pressed the End Conversation hotkey. I've written a fix for this, and it works in testing, so I'll open a PR for you to review.