This project is basically made by me in order to step in the world of AI (Artificial Intelligence) with Java. I have used two main components, or you can say Libraries for it. The first one is FreeTTS, this is for converting text-to-speech and the second one is Sphinx4, used for converting speech-to-text.
Using FreeTTS is somewhat easy, you just need to set the voice (this library comes with some inbuilt voices, you can use one of them or use another famous library specifically for choosing voices of your own choice, i.e. MBROLA) and that's it. Now give some command for it to speak and there you go... π. Need help? Just once check the sample TTS.java file for this.
But when it comes to speech-to-text, you need to prepare some stuffs beforehand (as discussed in the installation section). For sample once have a look at STT.java file.
- Firstly clone this project and open it in any of your favourite IDE (mine is IntellIJ π).
- Add all the jar files (basically the dependencies of this project) present in the library folder into your project folder from the IDE itself.
- Now create a command.txt file and add all the commands which you want Jarvis to listen and respond accordingly.
Remember: In this file, whatever commands you enter, only those words will be recognized, regardless of what you speak.
- Now go to this site. And upload the command.txt file on the space given in it and then click
Compile Knowledge Base
button. - You will get redirected to next page from where you need to download two files, one is of .dic extension (called dictionary file) and other is .lm (called language model file) and save it in your project folder.
Note: You can use mine too. As I already did all the steps required for some commonly used commands.
- In order to confirm that your whole setup is working fine or not, run that two sample files TTS.java and STT.java. If they both runs smoothly then you are ready to move on to the next step π₯³π else re-config your setup and try again π€π«£.
Make sure to enable the mic permissions for your IDE (I did not do this and have changed almost half of my code π . So make sure you don't do this mistake).
- And that's it. Now you can run the VoiceAssistant.java file and there you have it, your own personal voice assistant named JARVIS ποΈ for your own convenience, and now you are ready to jump into action.
If you would like to contribute to this repo Voice_Assistant_Using_Java
, please fork the repository and submit a pull request with your changes. Contributions are welcome and encouraged!
This project is still ongoing. I am working on converting this whole thing in a GUI for better user experience along with few more commandsβοΈπ. So till then do whatever you like and wait for it as it will be soon get uploaded hereπ.
If you are feeling generous, buy me a coffee...!!! β