tmarenko / GenshinImpact_PaimonShutUp

Automatically mutes Paimon when she speaks
Apache License 2.0
39 stars 3 forks source link

app not working #1

Closed dovochi closed 3 years ago

dovochi commented 3 years ago

I launched the start.bat file and the last line I got from the command prompt window was "Ready for Paimon!". When Paimon spoke, nothing happened in the command prompt window. I tried using the English and Japanese voices but neither of them worked. I'm using Windows 10 build 19041, DirectX 12. Genshin is on the second monitor at 1920x1080 full screen, max settings. I'm using controller.

tmarenko commented 3 years ago

Genshin is on the second monitor

Can you try to check whether is app working when game is on primary monitor? I believe currently the code is looking only for first monitor if game is not windowed.

dovochi commented 3 years ago

I'm out of quests at the moment. Is there any place I can go to in order to test this?

tmarenko commented 3 years ago

Is there any place I can go to in order to test this?

I don't know. One way is to logout from your main account and create new one to test it.

I've added support for multiple monitors (https://github.com/tmarenko/GenshinImpact_PaimonShutUp/commit/7b8676748ee5246d3a3fd307db9a3461bc53f566) and tested it with my second monitor, seems to work fine. You can download updated main.py: https://raw.githubusercontent.com/tmarenko/GenshinImpact_PaimonShutUp/main/main.py and replace old one with it.

dovochi commented 3 years ago

I just downloaded the new main.py file and ran the start.bat file again but I can still hear Paimon talking. The command prompt window still doesn't show anything beyond "Ready for Paimon!". I'm using my laptop screen only at the moment.

dovochi commented 3 years ago

I also tried using windowed and full screen modes on both the laptop monitor and the external one but it's still not working. Do I need to put the app folder in a specific place or launch it before the game?

tmarenko commented 3 years ago

Do I need to put the app folder in a specific place or launch it before the game?

No you don't. Your in-game language is English?

dovochi commented 3 years ago

The UI is English but voice over is Japanese. I'm downloading the English voice file to test.

tmarenko commented 3 years ago

I'm downloading the English voice file to test.

In-game voice doesn't matter, script is looking for "Paimon" name in dialogue. I think script can't see her name in dialogue but I'm not sure why.

dovochi commented 3 years ago

I just tried the English voice and yeah it didn't work either. I also tried adjusting the dialogue volume but that didn't trigger the command prompt at all

tmarenko commented 3 years ago

I've edit main.py to save screenshots of the script's proccess: https://raw.githubusercontent.com/tmarenko/GenshinImpact_PaimonShutUp/debug/main.py Try to download and replace it with old one.

With this edit, script will create screenshots: windowed.png or all_screen.png to check if capturing the game is working correctly: windowed frame.png to check if Paimon's name is on screen: frame and bw_frame.png is black&white Paimon's name to recognize it properly: bw_frame

Try to run the script and see if your .png files looks the same.

dovochi commented 3 years ago

all_screen.png looks like the first pic, showing the current screen as bordered window. but the frame.png and bw_frame.png are both all black without any text at all. The command prompt window is spamming the below line in repeat

Found text:

dovochi commented 3 years ago

windowed.png is switching between 0KB and 6KB size every second or so.

dovochi commented 3 years ago

I copied windowed.png while it was a 6KB file to see and the pic is all black at 1686 x 1079 px.

tmarenko commented 3 years ago

Another updated main.py: https://raw.githubusercontent.com/tmarenko/GenshinImpact_PaimonShutUp/debug/main.py

The output should be similar to:

Waiting for GenshinImpact.exe process
Ready for Paimon!
Fullscreen: True, borders: (0, 0, 1920, 1080)
Got game's image 1920x1080, cropping by (889.2474078073014, 850.1901497320653, 1030.3835688364857, 894.8910822396474)
Found text: Paimon
tmarenko commented 3 years ago

I copied windowed.png while it was a 6KB file to see and the pic is all black at 1686 x 1079 px.

You should look at windowed.png only if you run game in windowed mode. Otherwise the screen would be in all_screen.png

tmarenko commented 3 years ago

Also you could test this code in any dialogue basically: image frame bw_frame

dovochi commented 3 years ago

I'm seeing the following

Found text: ianinm
Fullscreen: True, borders: (117, 0, 1803, 1079)
Got game's image 1686x1079, cropping by (780.8703799807865, 849.4029366304615, 904.805571384539, 894.0624793857218)
Found text: ianinm
Fullscreen: True, borders: (117, 0, 1803, 1079)
Got game's image 1686x1079, cropping by (780.8703799807865, 849.4029366304615, 904.805571384539, 894.0624793857218)
Found text: Paimon
Paimon, shut up!
Fullscreen: True, borders: (117, 0, 1803, 1079)
Got game's image 1686x1079, cropping by (780.8703799807865, 849.4029366304615, 904.805571384539, 894.0624793857218)
Found text: ianinm
Unmuting the game.
Fullscreen: True, borders: (117, 0, 1803, 1079)
Got game's image 1686x1079, cropping by (780.8703799807865, 849.4029366304615, 904.805571384539, 894.0624793857218)
Found text: ianinm
Fullscreen: False, borders: (117, 0, 1803, 1079)
Got game's image 1686x1079, cropping by (780.8703799807865, 849.4029366304615, 904.805571384539, 894.0624793857218)

However, the current NPC is Keqing and the game's sound was muted during her dialogue, not Paimon when it detected Paimon. It seems to be delayed by several seconds.

dovochi commented 3 years ago

I'm running the game in windowed mode but strangely, windowed.png is switching between 0KB and 6KB (which is an all black pic with no text). all_screen.png is showing the current screen which is in windowed mode.

tmarenko commented 3 years ago

not Paimon when it detected Paimon

Yeap, I see. Too much overlook only for Paimon. As again, here updated main.py: https://raw.githubusercontent.com/tmarenko/GenshinImpact_PaimonShutUp/debug/main.py Should recognize other characters better.

It seems to be delayed by several seconds.

It is, I've added 2 sec delay just for testing purposes.

dovochi commented 3 years ago

Looks like the OCR engine is misreading certain characters

Found text: Pdimon Fullscreen: True, borders: (245, 0, 1931, 1079) Got game's image 1686x1079, cropping by (780.8703799807865, 849.4029366304615, 904.805571384539, 894.0624793857218) Found text: Koqing Fullscreen: True, borders: (245, 0, 1931, 1079) Got game's image 1686x1079, cropping by (780.8703799807865, 849.4029366304615, 904.805571384539, 894.0624793857218) Found text: Koqing Fullscreen: True, borders: (245, 0, 1931, 1079) Got game's image 1686x1079, cropping by (780.8703799807865, 849.4029366304615, 904.805571384539, 894.0624793857218)

dovochi commented 3 years ago

It read Keqing as Koqing and Paimon as Pdimon.

dovochi commented 3 years ago

I just switched to using my laptop monitor's only. Does this matter at all?

tmarenko commented 3 years ago

It read Keqing as Koqing and Paimon as Pdimon.

I forgor that could happen =) Another update: https://raw.githubusercontent.com/tmarenko/GenshinImpact_PaimonShutUp/debug/main.py Should work for misreading characters now.

I just switched to using my laptop monitor's only. Does this matter at all?

I believe it doesn't, as soon as frame.png contains name of character.

dovochi commented 3 years ago

It seems to be working now with some delays.

Found text: Koqing Fullscreen: True, borders: (245, 0, 1931, 1079) Got game's image 1686x1079, cropping by (780.8703799807865, 849.4029366304615, 904.805571384539, 894.0624793857218) Found text: Puimon Paimon, shut up! Fullscreen: True, borders: (245, 0, 1931, 1079) Got game's image 1686x1079, cropping by (780.8703799807865, 849.4029366304615, 904.805571384539, 894.0624793857218) Found text: Puimon Fullscreen: True, borders: (245, 0, 1931, 1079) Got game's image 1686x1079, cropping by (780.8703799807865, 849.4029366304615, 904.805571384539, 894.0624793857218) Found text: Puimon Fullscreen: True, borders: (245, 0, 1931, 1079) Got game's image 1686x1079, cropping by (780.8703799807865, 849.4029366304615, 904.805571384539, 894.0624793857218) Found text: Puimon Fullscreen: False, borders: (245, 0, 1931, 1079) Got game's image 1686x1079, cropping by (780.8703799807865, 849.4029366304615, 904.805571384539, 894.0624793857218) Found text: Unmuting the game.

tmarenko commented 3 years ago

Good. Here is version without debug saving and delays: https://raw.githubusercontent.com/tmarenko/GenshinImpact_PaimonShutUp/a1a22ef5e58e3d33804d5552b7be39de0f1bfeaf/main.py You can use it for now. I'll update main branch and release tomorrow.

dovochi commented 3 years ago

I just tested the latest version and it had a fraction of a second of delay. Paimon managed to get a word out before getting muted. As soon as the dialogue changed, the game was unmuted. Is it possible to completely get rid of the voice? It's okay if not though. This is way, way better than having to listen to whole sentences. You just saved my ears from so much pain. Thank you so much!

dovochi commented 3 years ago

Wait. I just switched back to full screen mode on my second screen and it doesn't work anymore. Any ideas why?

dovochi commented 3 years ago

Actually, it seems to only work in windowed mode.

dovochi commented 3 years ago

The script didn't mute Paimon if something overlaid on top of the dialogue before she started talking. image

It also didn't mute her when she talked while off-screen, such as when moving around and not in a cutscene.

tmarenko commented 3 years ago

it seems to only work in windowed mode

I think I've fixed in https://github.com/tmarenko/GenshinImpact_PaimonShutUp/commit/b0d8a5e4f4a80947f56428c6a8af6fffdbfbeb42

didn't mute her when she talked while off-screen

Now it should

didn't mute Paimon if something overlaid on top of the dialogue

That's okay, may be? I'm not sure how to overlook for dialogue overlays so I think to leave it as it is.

I just tested the latest version and it had a fraction of a second of delay. Paimon managed to get a word out before getting muted. As soon as the dialogue changed, the game was unmuted. Is it possible to completely get rid of the voice?

Yeah delays are inevitable. Mostly it's image grabbing that require too much time to complete. One way is to switch from Python to C++, that would reduce delays and size of external libs but this requires some work and time. Maybe one day sometimes

dovochi commented 3 years ago

The latest version kept muting and unmuting rapidly when Paimon was still talking off-screen. Maybe that's due to the changing frames while you're moving? I don't mind it all that much, really, since this happens way less than the cutscene dialogues. It's working correctly in full screen mode now, though. As for the delay, that's totally okay! It's actually kinda funny and makes me laugh, like you're actually shutting her up. Thanks for your awesome work!

tmarenko commented 3 years ago

I've tried to switch from Python to C++: https://github.com/tmarenko/GenshinImpact_PaimonShutUp/releases/tag/0.4.0 Much lesser archive size and screen capturing should be quicker also.

dovochi commented 3 years ago

Strangely, neither the old and new version worked anymore, either in windowed and full screen mode. This happened after I rebooted.

dovochi commented 3 years ago

Hold that thought. I just tried running the C++ version as admin and it's working in windowed mode on single display mode (laptop screen only). I'll test on full screen and also on second screen as well.

dovochi commented 3 years ago

It works great in full screen mode on both internal and external monitors. CPU usage is a bit high at 10% (a quarter of what Genshin is using) but that's okay. It seems to work much faster at muting Paimon than the Python version. It also works correctly when she talks off screen as well as when you're moving. Awesome work! Thanks so much for this. I'll be testing it for the next few days to see if any other issue shows up.

dovochi commented 3 years ago

Okay so the C++ version needs to be run as admin but it seems to only work for about 10 min before crashing.

dovochi commented 3 years ago

script just crashed again, so I'd say around 20-30 min?

tmarenko commented 3 years ago

script just crashed again, so I'd say around 20-30 min?

I'm debugging it right now but no crashes for me so far. Have you done something before crash? Alt+tab, changing monitor/resolution, etc.?

tmarenko commented 3 years ago

Ok, I've got it. Script crashes trying to strip \n\n string for example.

tmarenko commented 3 years ago

Should be fixed in https://github.com/tmarenko/GenshinImpact_PaimonShutUp/releases/tag/0.4.1

dovochi commented 3 years ago

The latest version seems to be working correctly so far. I'll keep testing it for the next few days and will keep you updated. Thanks!