karashiiro / TextToTalk

Chat TTS plugin for Dalamud. Has support for triggers/exclusions, several TTS providers, and more!
MIT License
47 stars 30 forks source link

Ungendered voice selected isn't used #49

Closed pixypolly closed 2 years ago

pixypolly commented 2 years ago

I'm having an issue where the ungendered voice I selected isn't properly registered and (I assuming) the default US-english speaker voice is used instead.

See this vid for example. For some reasons, the game recognizes the report on the table is male speaker but that's probably how they assigned gender in the game? Not that I have any issue with that. Anyway, you can see around 0:44 where an unknown speaker enters the scene and, eventhough I selected Takumi, a JP voice, for ungendered in config, an english voice was played.

Waitsnake commented 2 years ago

I have the same problem when using Amazon Poly as voice backend. I setup all the voices in UI to german voices, but during cutscenes as long as the gender is unknown it switches to an english default voice that pronounces German horribly wrong until complete unintelligibility.

I search in the code of the AmazonPolyBackend and saw some suspicious code that maybe could cause this.

https://github.com/karashiiro/TextToTalk/blob/f51fcf8df990e13391ee6617d323ace832a44817/src/TextToTalk/Backends/Polly/AmazonPollyBackend.cs#L74

Why uses the say() function in AmazonPolyBackend as default "this.config.PollyVoice" when the gender is unclear/neutral and not "this.config.PollyVoiceUngendered" ?

If you look into the say() function in the SystemBackend it uses the "UngenderedVoicePreset" as default. https://github.com/karashiiro/TextToTalk/blob/f51fcf8df990e13391ee6617d323ace832a44817/src/TextToTalk/Backends/System/SystemBackend.cs#L58

But back to the say() function in AmazonPolyBackend. When this suspicious "this.config.PollyVoice" (because the user can not set this in UI) is set to variable voiceIdStr. In next code line it tries to convert the variable voiceIdStr to variable voiceId and if it could not find the voice for "this.config.PollyVoice" (probably undefined) is falls even back to the hard coded "VoiceId.Matthew" that is presumably the english voice we here in case the gender is neutral.

https://github.com/karashiiro/TextToTalk/blob/f51fcf8df990e13391ee6617d323ace832a44817/src/TextToTalk/Backends/Polly/AmazonPollyBackend.cs#L79

Waitsnake commented 2 years ago

As I mentioned before I set up all voices in UI that I could set up for AmazonPolyBackend.

If I now open the TextToTalk config file here %appdata%\xivlauncher\pluginConfigs\TextToTalk.json then I see thees setting for the voices: "Lexicons": [], "PollyVoice": null, "PollyVoiceUngendered": "Vicki", "PollyVoiceMale": "Hans", "PollyVoiceFemale": "Marlene", "PollyEngine": "standard",

As we see while "PollyVoiceUngendered" is set to German voice "Vicki that should be also the default voice the value for "PollyVoice" is set to "null" and this will then lead to problem that "null" could not be found as voice and it uses then the hard coded default voice "VoiceId.Matthew".

Waitsnake commented 2 years ago

A workaround is to directly change the value null of "PollyVoice" in TextToTalk.json to different voice of the own language with a text editor. For example: "Lexicons": [], "PollyVoice": "Vicki", "PollyVoiceUngendered": "Vicki", "PollyVoiceMale": "Hans", "PollyVoiceFemale": "Marlene", "PollyEngine": "standard",

I tested this this workaround for a gaming session and it seems work. The english hard coded voice Matthew is not longer used and the UI seems not to override the value for "PollyVoice" with something else.

karashiiro commented 2 years ago

That is indeed a mistake, good catch. I'll change that to use PollyVoiceUngendered, I was confusing myself with the config option names. As for why it falls back to Matthew if that fails, it's in order to avoid a plugin crash if the config is manually edited to something invalid.

karashiiro commented 2 years ago

https://github.com/goatcorp/DalamudPlugins/pull/1995 should be fixed, now.

karashiiro commented 2 years ago

Updated code, for reference: https://github.com/karashiiro/TextToTalk/blob/96b3b3b31fd46a901226ee56c6b7fa35745a2293/src/TextToTalk/Backends/Polly/AmazonPollyBackend.cs#L70-L85

https://github.com/karashiiro/TextToTalk/blob/96b3b3b31fd46a901226ee56c6b7fa35745a2293/src/TextToTalk/Backends/System/SystemBackend.cs#L54-L63