I was playing with using the third voice as a narrator that will read quest titles, NPC names, objectives, and anything in < > brackets.
I have cobbled up some changes to the code, including settings, both in Retail and Classic. I've played with it in Retail for a day or so and tried one quest in Classic. It seems to work but may need some more testing.
The new code is run only when Settings.useNarrator is true; otherwise, your original code is run without any changes.
I changed module.getText(source) so that it decorates text with [narratorTag][/narratorTag] whenever it encounters one of the above-mentioned situations. (Only if Settings.useNarrator is true)
The new function module.processAndSplitNarrator(text) splits the text into segments {text: string, voiceID: int} according to inserted narrator tags.
The module.ttsPlay(text) function calls module.processAndSplitNarrator(text) and iterates through segments and puts them into the speechQueue table eliminating any empty text. (Only if Settings.useNarrator is true)
After that, it calls the function module.processNextSpeechSegment(), which will read the first segment (first in, first out). (Only if Settings.useNarrator is true)
The module.processNextSpeechSegment() function checks if there is anything left to play or if anything is playing. If so, it will just return. Otherwise, it will read segment.text using segment.voiceID.
I included calling module.processNextSpeechSegment() in the UseEvent section of the "VOICE_CHAT_TTS_PLAYBACK_FINISHED" and "VOICE_CHAT_TTS_PLAYBACK_FAILED" events, so it will try to read the next segment when the previous one has finished.
Additionally, in module.ttsStop(), I cleared the speechQueue.
And one more thing—I don’t know if it was intentional, but in immersion.lua, the OnHide hook was calling Main.ttsStop(). I changed it to Main.ttsAutoStop() to be in line with the "vanilla" experience.
As a non-native English speaker, I love your addon. Thank you very much!
Whether you choose to use this Pull Request or not is up to you!
Hello there,
I was playing with using the third voice as a narrator that will read quest titles, NPC names, objectives, and anything in
< >
brackets.I have cobbled up some changes to the code, including settings, both in Retail and Classic. I've played with it in Retail for a day or so and tried one quest in Classic. It seems to work but may need some more testing.
The new code is run only when
Settings.useNarrator
is true; otherwise, your original code is run without any changes.module.getText(source)
so that it decorates text with[narratorTag][/narratorTag]
whenever it encounters one of the above-mentioned situations. (Only ifSettings.useNarrator
is true)module.processAndSplitNarrator(text)
splits the text intosegments {text: string, voiceID: int}
according to inserted narrator tags.module.ttsPlay(text)
function callsmodule.processAndSplitNarrator(text)
and iterates through segments and puts them into thespeechQueue
table eliminating any empty text. (Only ifSettings.useNarrator
is true)module.processNextSpeechSegment()
, which will read the first segment (first in, first out). (Only ifSettings.useNarrator
is true)module.processNextSpeechSegment()
function checks if there is anything left to play or if anything is playing. If so, it will just return. Otherwise, it will readsegment.text
usingsegment.voiceID
.module.processNextSpeechSegment()
in theUseEvent
section of the "VOICE_CHAT_TTS_PLAYBACK_FINISHED" and "VOICE_CHAT_TTS_PLAYBACK_FAILED" events, so it will try to read the next segment when the previous one has finished.module.ttsStop()
, I cleared thespeechQueue
.And one more thing—I don’t know if it was intentional, but in
immersion.lua
, theOnHide
hook was callingMain.ttsStop()
. I changed it toMain.ttsAutoStop()
to be in line with the "vanilla" experience.As a non-native English speaker, I love your addon. Thank you very much!
Whether you choose to use this Pull Request or not is up to you!