quran_android
quran_android copied to clipboard
Adding Voice Commands Feature
These changes are adding voice commands button to the app. Current commands are found under voice_commands.xml. This can be expanded to add commands to audio control or change settings as well. A microphone button can be found on top of the main screen.
Thank you for your comments. I just want to clarify, this is just a basic code just to show that it works. The core code is there, all is needed is to add "features" to it by adding to the case function in VoiceCommandsUtil.java. I might eluded in my previous posts and probably can be seen in my slow progress, I don't have that much time to work on this to make it a full fledged feature. I am hoping that with this code someone can work on it to add more features to it to make it useful for people. If not, I'll keep working on it as time permits until it is completed.
Also, I will make the code cleaner with more descriptive comments. But you have raised a very good issue, its hard for someone new like myself to read the master code and understand the different functions since there is almost no comments or explanations. Even the order of imports being alphabetical is not clear. So, I suggest an effort to be made to add comments to help new collaborators hit the ground running.
Please let me know if there are any additional comments or feel free to work on the code yourself. Just a few items to clarify:
- I understand the comment about not hard coding strings. However, I had to do it for 2 special cases for an English sura search. This is the best way I could think of to make it easy to search without complicated sentences since the translated sura names are longer than one word. I couldn't use the Arabic version of the English names because google recognition software had difficulty capturing many of the name.
- Two of the English translated sura names (Qaf and Jinn) couldn't be found by the voice recognition software. The rest can be identified according to my own testing. I am open to suggestions on how to handle those 2 suras.
- The list of voice commands both in Arabic and English can be found in strings voice_commands.xml (the default one) as well as the strings used for searching. The reason I didn't separate them is because of the system language locale issue. The localized xml files can be only accessed if the system language is changed. This limits the functionality of the software if someone wants to use the Arabic voice recognition while the system language is English (such as in my case). The other option was to play around with the configuration locale by changing it back and forth but I read that it is not recommended to do that.
- The command to go to specific page is "page 7" for example.
- The command to go to specific sura is "go to the opener" for example. No need to say sura/surat. In fact to avoid bad recognition of words, the code will only care about the last word (except for the two special cases mentioned in the code)
- The command to change the language to Arabic is "language arabic" then you can immediately start giving commands in Arabic the next time you click the microphone.
- There are also commands "settings", "help" and "about"
- The possibilities are endless. Additional features can be added such as changing settings directly without opening the settings page (similar to changing the language of the recognition software) or opening translation or tafseers, or searching for specific words, or start audio recitations, etc. This will require a lot more time from me because I still haven't figured out the rest of the code. It is difficult to understand without any comments.
@ahmedre what is the update on this PR? Can someone else take over? If yes, can you please describe the voice command feature in more detail. thanks