Author Topic: Building a voice controlled champion selector for LoL  (Read 2257 times)

E.M.P

  • Newbie
  • *
  • Posts: 7
  • Languages: German, English
Building a voice controlled champion selector for LoL
« on: September 29, 2023, 12:00:44 PM »
I am currently trying to build a controller to select champions in League of Legends.
My goal is to do it without adding every champ manually to the query of my command.

To do this, I have created a simple plan:
  • Retrieve champion names from the official game website.
  • Get input from the user regarding the champion they want to select.
  • Hover the mouse cursor over the champion in the league client
  • Wait for user confirmation to log in/select champion

Step 1: With a little C# magic, I was able to retrieve all the champion names from the official website, so I don't have to add them manually.

Code: [Select]
WebClient client = new WebClient();
string result = client.DownloadString("https://www.leagueoflegends.com/de-de/champions/");

List<string> hyperlinks = result.Split('<').ToList().FindAll(x => x.Contains(":name\"));

StringBuilder sb = new StringBuilder();
foreach (string link in hyperlinks)
   sb.Append(link.Split('>')[1].Replace("&#x27;","\'").Replace("&amp","&") + ";");
           
sb.Remove(sb.Length - 1,1);
VA.SetText("champs", sb.ToString());

Step 2: I created a simple command that is activated when you say "hover champ" (attachment 1). It executes the C# code from step 1, stores all champion names in the variable "champs" and executes a "Wait for spoken response" method in which the "champs" are the only acceptable responses.

Now here is the point where I bumped into a little problem. Champions like "Akali", "Zed" und "Zoe" get recognized pretty easily.
Champions like "Aatrox", "Jarvan IV" and "Nunu & Willump" on the other hand don't.

So my question is, does anyone know a simple way to convert the names into a transcript, which VA understand?
I think if the names were converted it should be easier for VA to under stand them (Example: Aatrox = Ey-trahks, Ahri = Ah-ree).

Keep in mind to accomplish this transcription I would like to avoid any third-party apps or plugins. I just want to use the resources that VA provides.
Ofc C#, VB or other inline functions are okay.

SemlerPDX

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 291
  • Upstanding Lunatic
    • My AVCS Homepage
Re: Building a voice controlled champion selector for LoL
« Reply #1 on: September 29, 2023, 12:36:16 PM »
For those words which are not easily recognized, you could add them to the Dictionary and record a custom pronunciation for each of them.

Open the VoiceAttack options (the wrench/spanner icon on the main window) and select the Recognition tab along the top - next, select the Utilities menu near the top right and choose "Add/Remove Dictionary Words"


Be sure to check the box to record a custom pronunciation before you save that word:

SemlerPDX

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 291
  • Upstanding Lunatic
    • My AVCS Homepage
Re: Building a voice controlled champion selector for LoL
« Reply #2 on: September 29, 2023, 12:38:40 PM »
As a follow up note, in case you are not aware, certain keypress macros should be avoided when actually playing LoL - check out this webpage for more info - last thing we'd want is for someone to get their player account banned because they assumed they could use VoiceAttack for "whatever".  Selecting champions like this is unlikely to cause any issues, but you'd know best as an active player with regards to what is stated in this link:

https://leaguetips.gg/macros-ban-league-of-legends

E.M.P

  • Newbie
  • *
  • Posts: 7
  • Languages: German, English
Re: Building a voice controlled champion selector for LoL
« Reply #3 on: September 29, 2023, 12:57:23 PM »
For those words which are not easily recognized, you could add them to the Dictionary and record a custom pronunciation for each of them.

Hey, thanks for the quick response.

The idea with the dictionary is neat but my plan is to automate the process of transcription.

Imagine a new champ is released. I want my command to automaticly recognice the new champ and transcript it.
I do not want to manually add the new champion to the command nor do I want to manually add the champion to the dictionary.

Therefore I retrieve all champion names from riots website (cause on release the new champion will be added to the website).
So it's more of a question of how to convert the champion name automatically via inline function.

I know this is pretty advanced and probably something which can not be implemented that easily.
I am just looking for some ideas to transcript the names with C# or VB.


Specific:
I am looking for some standard tools which C# provides.
Some sort of module which allows me to transcript the name to different languages.

As a follow up note, in case you are not aware, certain keypress macros should be avoided when actually playing LoL - check out this webpage for more info - last thing we'd want is for someone to get their player account banned because they assumed they could use VoiceAttack for "whatever".  Selecting champions like this is unlikely to cause any issues, but you'd know best as an active player with regards to what is stated in this link:

https://leaguetips.gg/macros-ban-league-of-legends

Thanks for the note. But the only thing i want to do is the following:

When I get into the queue and join a game I want to say the champ I want to play.
VA then types the name into the searchbar of the league client and hovers over the champ i want to play.
After I confirm my choice VA will click the "select" or "log in" button in league to confirm my choice.

That's all.

SemlerPDX

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 291
  • Upstanding Lunatic
    • My AVCS Homepage
Re: Building a voice controlled champion selector for LoL
« Reply #4 on: September 30, 2023, 11:21:50 AM »
For those words which are not easily recognized, you could add them to the Dictionary and record a custom pronunciation for each of them.

Hey, thanks for the quick response.

The idea with the dictionary is neat but my plan is to automate the process of transcription.

Imagine a new champ is released. I want my command to automaticly recognice the new champ and transcript it.
I do not want to manually add the new champion to the command nor do I want to manually add the champion to the dictionary.

Therefore I retrieve all champion names from riots website (cause on release the new champion will be added to the website).
So it's more of a question of how to convert the champion name automatically via inline function.

Well, the reason I suggested the Dictionary with custom pronunciations is because of the limitations of the Windows Speech Recognition Engine itself.  In particular, it works off a massive dictionary of words, and while this includes many proper nouns such as names, unique words or names which are not present (such as the names of LoL champions) will not be recognized properly when spoken.

Since the list of champions in that game is a finite one, the idea of adding each of them to the WSR Dictionary (albeit a slog) would help to ensure consistent and accurate recognition of these unknown (and sometimes oddly spelled) proper nouns from LoL.

Dictation in VoiceAttack will be insufficient for that reason, and so if not using the dictionary, some other means would be required to gather what was said and match it properly with a name on file/in code.

I had not suggested other means, as you had said this in your first post:
Keep in mind to accomplish this transcription I would like to avoid any third-party apps or plugins. I just want to use the resources that VA provides.
Ofc C#, VB or other inline functions are okay.

...but there are other means.

For example, using a plugin, writing your own, or getting very fancy with orchestrating multiple inlines or a very very long one.  My OpenAI plugin for VoiceAttack has access to the entire host of API calls available through OpenAI, not just ChatGPT, and this includes the Whisper API.  Whisper is a tool that can transcribe or translate any speech with near 100% accuracy in English, and it is as fast as it is cheap/affordable (fractions of a penny per call, for a command-sized phrase).

I wrote this plugin so that profile builders such as yourself could easily access these OpenAI features through VoiceAttack however they can imagine.  The code is GPLv3 Freeware and Open Source on my GitHub, and perfectly safe and secure for its purposes.

My AVCS CHAT profile (powered by this plugin) uses Whisper as the means to get user speech into accurately transcribed text to provide as the input for a ChatGPT call, and so just now I tested Whisper's ability to properly convert my words including names - it seems to have correctly spelled the three LoL champion names which I gathered from your first post.  Understand that while I am asking a question of ChatGPT and it is responding, this test was for the transcription (the difference between "Append Dictation Buffer" and "Asking Malcolm" is the key), and none of ChatGPT was used to identify and properly spell these names:



What does this mean?  It means that you could potentially use the Whisper API offered by OpenAI to send the speech of the name you said, and return it as properly spelled, which then could be compared properly in an inline function to execute the appropriate command in VoiceAttack pertaining to that champion.

Again, I had not offered this as an initial suggestion because you stated that you specifically did not want to use any plugins, but truly this is what I would use if I needed to ambiguously transcribe proper (unknown) nouns for further parsing and command identification based on expected (proper) spelling of these names.

Obviously, link(s) to my work is in my signature below.  If you are code savvy, you may be able to create your own trimmed down Whisper API call to OpenAI through an inline function, and come up with your own methods/code to combine audio files generated during VA Dictation and send to Whisper for transcription.