LoL TIMERS - Track cooldowns information using Speech to Text (PYTHON)
Project dedicated to League of Legends.
This tool will helps players to track summoners spells cooldown information easily using Voice.
Introduction
What is Summoner Spells?
Summoner spells are abilities that players can use for their champions.
They are chosen in Champion Select before the start of the game. Each player is allowed two summoner spells chosen from a below list.
Each summoners has a special effect and can heavily impact the game, that’s why a lot of Pro Player write in the game chat to give information about cooldown.
Example of message sent by a Pro Player in game-chat (0830 J means Jungler will get his flash at 8:30)
Example of summoners:
Flash: Blinks your champion a short distance toward the target location.
Exhaust: Exhausts enemy champion, slowing them and reducing their damage dealt
Teleport : Teleport your champion to the selected allied unit.
Ignite : Ignites an enemy champion , dealing damage.
How to make tracking summoners cooldown easier?
The main idea is to use voice instead of keyboard to write in game chat cooldowns information.
In order to capture voice and re-transcribe it to text we will use a technology called “Speech to Text”.
Voice Message Structure In order to create a good message we need 3 information:
- Who used a summoners ( Role)
- Which summoners
- When the summoner spell was used.
Syntax: {Summoners} {Role} {Time}
Example: Flash Top 22:02 (It means Player on top role used his flash at 22:02)
Note: I’m French, and my accent is not excellent that’s why I will use FR detection model in this post.
We will only track 4 summoners:
- Flash
- Teleport
- Exhaust will be replaced by “fatigue” ( French word)
- Ignite will be replaced by “feu” ( French word)
Development
Setup your project using Anaconda (Windows)
Download Anaconda or Miniconda , open an Anaconda prompt and type the following commands.
- conda create -n Blog1_speech_recognition python=3.7
- conda activate Blog1_speech_recognition
Install Dependencies using Pip.
- pip install SpeechRecognition
- pip install jupyter notebook
Download PyAudio (PyAudio-0.2.11-cp37-cp37m-win_amd64.whl which is for python 3.7 and 64 bits windows).
- pip install PyAudio-0.2.11-cp37-cp37m-win_amd64.whl
Speech to Text
Code
This code uses speech_recognition library to do following tasks:
- Listen to microphone (record audio)
- Ask google to performs Speech to text on recorded audio ( French model)
First results
Results are promising, most of the time, speech to text is able to detect and give me the correct output however speech to text is not always accurate and we can’t directly write text in game Chat.
We will need to improve it using:
- Similarity Algorithm to verify which role and Summoners is in the output text.
Similarity Algorithm
Requirements:
- pip install fuzzywuzzy
Code
We compute similarity and print the summoners with the highest ratio.
We compute similarity and print the role with the highest ratio.
Keyboard input
We now need to be able to write informations into game chat using Keyboard inputs.
We will use ctypes and Win DLL to performs this action.
Convert text into Win DLL format
We create some python dictionaries to store matching between role / summoners and corresponding input sentence.
All keyboard input codes all listed here.
We can build time sentence using below code. This code get input code for each numbers and add the cooldown time to final result.
Example of Matching Dictionary ( summoners / input sentence).
Assemble Sentence:
get input sentences for role and summoners using dictionaries.
concatenate with separating space
Write Information:
init WinDLL
iterate trough sentence and do keyboard input
Executable Application
We need to create an executable application which will be launched everytime we want to track a summoners. Steps to create an executable are below.
Download pyinstaller python package.
- pip install pyinstaller
Open a command prompt and type:
- pyinstaller –onefile src/main.py
An executable is now created and is located inside a folder called “dist”
Results
Download
You can get the code Here.