GithubHelp home page GithubHelp logo

ritwik12 / virtual-assistant Goto Github PK

View Code? Open in Web Editor NEW
123.0 16.0 97.0 16.87 MB

A linux based Virtual assistant on Artificial Intelligence in C

License: GNU General Public License v3.0

C 97.50% Makefile 2.50%
c linux artificial-intelligence natural-language-processing systems

virtual-assistant's Introduction

Virtual-Assistant

All Contributors

A virtual assistant is a software agent that can perform tasks or services for an individual. The term ”chatbot” is also used to refer to virtual assistants. Remember the time, when you were watching Iron Man and wondered to yourself, how cool it would be if you had your own J.A.R.V.I.S? Well, It's time to make that dream into a reality.

Artificial intelligence is the next gen. Imagine how cool it would be if you had your friends over at your house, and all of a sudden you go, "Hey JARVIS, show me some memes.", and JARVIS goes "Sure, sir. Here are the latest Italian memes.", whilst showing you the funniest Italian memes. Cool right?

Well, this is not exactly a chatbot nor JARVIS but to understand it better it is good to know about both.

Virtual assistants use Artificial Intelligence to match user text input to executable commands. It can provide a wide variety of services, These includes:

  • Weather forecast of any place
  • Play multimedia files such as audio songs and video songs
  • Open Applications such as Web browsers, Media players(like vlc), text editors, etc
  • Open directories in linux, Date and time
  • Search anything on Google
  • Open websites of user’s choice
  • Search anything on Youtube
  • Open Calendar of any year
  • Find Restaurants in an area
  • Send emails using your Gmail account
  • Arithmetic Calculations

screenshot from 2017-11-04 23 13 18

How it all works?

The user's sentence is read and passed through our Natural Language Processing (NLP) code for processing. After the sentence is processed, it's redirected to the action to be performed based on the meaning of the sentence. Our NLP code uses a simplified version of the Multinomial Naive Bayes Algorithm.

The following actions can be performed:

  • Play audio and media files
  • Display weather forecasts based on specified location
  • Display the calendar of a specified year
  • Perform YouTube video searches
  • Perform Google searches
  • Display restaurant recommendations
  • Send emails

If the virtual assistant does not understand the user’s sentence, a Google search performed.

Artificial Intelligence

Simplified Multinomial Naive Bayes Algorithm

Each classification contains a set of sentences that inputs are matched to. Scores are assigned based on the occurrence of words of an input sentence for each of the classifications. Scores measure the commonality of an input sentence to a classification. The commonality between words and the classifications are important. For example, matching the word “it” is considerably less meaningful than a match for the word “cheese”. The input sentence is assigned the classification of the highest score. This is a simplification as words need to be reduced to their stems.

A sample training set:

ai sample

Let’s classify a few sample input sentences:

screenshot from 2017-11-04 23 08 21

Notice that the classification for “What’s it like outside” found a term in another class but the term similarities to the desired class produced a higher score. By using an equation we are looking for word matches given some sample sentences for each class, and we avoid having to identify every pattern.

Setup

For Ubuntu (Debian-based Linux)

This program uses GNUstep speech engine for the purpose of text to speech. To use this feature few commands are needed:

say converts text to audible speech using the GNUstep speech engine.

$ sudo apt-get install gnustep-gui-runtime
$ say "hello"

Firefox is needed to perform browser tasks such as opening google and youtube.

$ sudo apt-get install firefox

In addition to this, following commands are needed to install the necessary packages.

$ sudo apt-get install libcurl4-openssl-dev
$ sudo apt-get install libjson-c-dev
$ sudo apt-get install libssl0.9.8

For Fedora (RHEL-based Linux)

This program uses Espeak for the purpose of text to speech.

espeak converts text to audible speech.

$ espeak "hello"

Firefox is needed to perform browser tasks such as opening google and youtube.

$ sudo yum install firefox

In addition to this, following commands are needed to install the necessary packages.

$ sudo yum install libcurl libcurl-devel
$ sudo yum install json-c json-c-devel
$ sudo dnf install openssl
$ sudo dnf install openssl-devel

For macOS

GNUstep can be cross-compiled from Linux to run on Apple's macOS, (See: http://wiki.gnustep.org/index.php/Cross_Compiling).

brew install curl
brew install json-c
brew install openssl

Compile

To compile with make:

sudo make install

then execute using virtual_assistant from any location

To remove all build files

make clean

To remove the changes

sudo make uninstall

To compile with gcc:

gcc main.c src/init_config.c $(pkg-config --libs --cflags libcurl) -lssl -lcrypto -ljson-c -std=gnu11

Restaurant

Virtual Assistant can find restaurants in an area.

restaurants

Weather

This feature requires curl. To use this feature you need to first install curl as follows-

$ sudo apt-get install curl

Or

$ sudo yum install curl

weather

Media

Virtual assistant can play any audio or video files of your choice. For playing media files vlc is needed. Get it here

$ sudo apt-get install vlc

Or

$ sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
$ sudo dnf install vlc

Or

sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
sudo yum install vlc
Please configure your working directory location before using this feature in config file (value of HOME_DIR)

media

Youtube Search

Virtual assistant can search anything on youtube.

search youtube for Artificial Intelligence

This will show all the videos on youtube related to Artificial Intelligence. Artificial Intelligence is an example here, you can use anything you want to search.

youtube

Google Search

Virtual assistant can search anything on Google.

gsearch

Calendar

Virtual assistant can show calendar of any year.

open calendar

calendar

Emails

In order to send emails using Virtual-Assistant, you need to allow access from less secure apps on your gmail account. Open your gmail account on any browser, click on profile pick and then Google account. In the tab Security you have to activate the parameter Allow access from less secure apps.

Access the gmail service using emails. You will be prompted for your email address and email password. Once you have input those, your email will be saved and you can choose what actions you would like to use. Currently you can only choose to write and send emails. Once you are done writing your message use finish and the email will save and send.

56217042-d4841c00-6062-11e9-9d98-71f7bda8a1d4

Reminder and Schedule

You can schedule your appointments and work using Virtual-Assistant. It will remind you of the appointments you have on a particular day. You can also access your schedule for any other day by just using the correct words.

In order to add a reminder simply say Add a reminder or Add an appointment or Make a schedule and other things like that. Once there, just enter the required details like date, time and event description.

Every time you run the Virtual-Assistant you will receive notifications of your schedule for that day. If you wish to access schedule for any other day you can say my schedule or what's my appointments.

notification

addreminder

schedule

Arithmetic Calculations

Virtual assistant can perform calculations for you, use math to calculate expressions in the command line using GNUs command line calculator. When you're done, just use quit.

Use man bc on terminal (outside Virtual Assistant) to learn about the command line calculator capabilities.

For long arithmetic expressions, the assistant can bring up the calculator for you by using calculator. math_demo

Help

Don't know how to use? Here use help command

help

help

Contributing Guide

  • This repository is strictly based on C language. No contributions other than C will be accepted.
  • When contributing to this repository, please first inform or discuss the change(s) you wish to make via an issue. This helps in letting others know what you're working on.
  • Before you push your changes to GitHub, make sure that your code compiles and runs without any errors or warnings.
  • New features are always welcome.

Want to ask something?

Please ask on FAQ or mail me at [email protected]

License

ritwik12/Virtual-Assistant is licensed under the GNU General Public License v3.0

Permissions of this strong copyleft license are conditioned on making available complete source code of licensed works and modifications, which include larger works using a licensed work, under the same license. Copyright and license notices must be preserved. Contributors provide an express grant of patent rights.

  1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated.
  2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  3. Rebranding or renaming this software misguides users about the origin of the original software and should not be done.

Credits

This project intitiated with contributions by Riya and Ritwik. The project is much better and improving with the help of some awesome contributors.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Riya

💻 📖

Rushikesh Nagle

💻 📖 🚇

GaelleMarais

💻 📖

Vinayak Sankar

💻 📖

Matheus

💻

Omer Dagan

💻

Jacky Lui

📖

pavan-pan

💻

hardikpnsp

💻

Eldar Takach

💻 📖

Roy Mattar

💻

Jayadev V

📖

A. Nummikallio

💻

igo4Jesus

💻

speedy-software-ch

💻

Anindya

💻

LilyaMel

💻 📖

This project follows the all-contributors specification. Contributions of any kind welcome!

virtual-assistant's People

Contributors

allcontributors[bot] avatar andy5995 avatar anindyasen avatar aurochs-angels avatar eldart95 avatar ellisken avatar gaellemarais avatar grace-morales avatar hardikpnsp avatar igo4jesus avatar jackycodes avatar jayadevvasudevan avatar joshua-deans avatar lilyamel avatar mcavazotti avatar omerdagan-tg avatar omerdagan84 avatar oxr463 avatar pavan-pan avatar ritwik12 avatar riya-17 avatar roymattar avatar rushikesh22 avatar speedy-software-ch avatar vnksnkr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

virtual-assistant's Issues

Gmail

It will be a great feature if Virtual assistant could open Gmail or read Gmail notifications.

Code structure

Hello all,

Is there any special reason why the code is organised by including the .c files. According to my knowledge, implementation of a function in .c file and prototype in .h file creates loose coupling among modules. I guess there is a reason why the code in this project is structured this way. I just want to know your views.

Regards,
PP

Code readability issues

Your idea seems interesting but after quick look at the repository I noticed some alarming problems with style of your code and overall structure. To begin with, your project consists of just ONE file and, which is even worse, only ONE function that is somewhere around 400 lines long. There is a serious need to split sections of your main function into multiple functions to make maintenance and readability easier. I would also suggest adapting some folders' structure and splitting your code into multiple files.

I also couldn't help the feeling that some parts of your code are duplicated and moreover probably unnecessary as functions performing those task might be provided in standard library.

If you find my statements useful or need some explanations, feel free to email me.

Maps

Google map integration to find a place or even a restaurant and show the result.

Create Documentation

Every feature of Virtual Assistant have its unique implementation such as the implementation for Restaurant, Weather, Google search, Email and Media is different for each.

To understand better it will be good to have Docs related to the working of these.

blank spaces

When nothing is provided as an input, still firefox is invoked to google.

Fix minor typo in README

There is one minor typo in the README that I will fix.

If the virtual assistant have no idea about the user’s sentence, it will simply search that sentence on Google.

The sentence is awkward and could be adjusted

Restaurant

Just like we are getting the weather forecast, we can even get the list of restaurants near us.

Does the strlen function need to be recalculated every round of the for loop?

strlen(example) function is called in each iteration of the loop to determine the length of the string example. However, calculating the length of the string repeatedly in each iteration can be inefficient, especially if the length remains constant throughout the loop.

Virtual-Assistant/analysis.c

for (int iter_char = 0; iter_char < strlen(example); iter_char++) {

int len = strlen(example);

for (int iter_char = 0; iter_char < len; iter_char++) {
    example[iter_char] = tolower(example[iter_char]);
    if (example[iter_char] == ' ') {
        if (example[iter_char + 1] != ' ') {
            split[word][character] = '\0';
            character = 0;
            word++;
        }
        continue;
    } else {
        split[word][character++] = example[iter_char];
    }
}

By calculating the length of the string outside the loop and storing it in the variable len, you avoid the overhead of recomputing the length in each iteration. This can lead to a significant improvement in performance, especially for long strings.

Answering any question

Here in this feature, the virtual assistant should be able to answer almost all the questions which are available on the internet. The basic approach is to fetch the answer(knowledge) from the internet (such as Google or Wikipedia) and passing it back to the answer.
The approach which I know is to get the data from Wikipedia using Wikipedia APIs and getting the data in JSON format and converting it to string for printing on the terminal.
For further knowledge please see these links-
https://stackoverflow.com/questions/8555320/is-there-a-clean-wikipedia-api-just-for-retrieve-content-summary

The JSON data will look like these links -
https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro=&explaintext=&titles=google
https://en.wikipedia.org/w/api.php?action=opensearch&search=facebook

The data can be fetched using above link and for converting it from JSON to string please refer our Restaurant feature.

Categories like weather etc in enum

An enum can be created of all categories and based on that rewriting of arrays and other functionality code can be handled. In future, if more categories are added, functionality should be handled automatically.

Text to speech

Right now we are using GNUstep speech engine for text to speech.
But it is not that good and we can use something better like eSpeak or festival.
Suggestions are welcomed.

FAQ

Doubt or question? Please feel free to ask here. Me and Riya are here to answer.

Some code safety insights

Thanks for your contribution to opensource! There's some code safety improvements possible, for example:

  1. scanf return value not taken into account. Possibly here(for example) and in other places.
  2. Unfreed memory and unitialized memory access. Possibly here(for example) and in other places. Please check valgrind tool to mitigate this kind of safety flaws.
  3. Excessive use of system calls without user input validation. Possibly here(for example) and in other places. Please see how it may be abused here.

Increase array size

In requests.c the class arrays are initialized with maximum word length 10, but for restaurant_class the word length is 11 for "restaurants" and 12 if '\0' is included (code below)

char *restaurant_class[10][10] = { {"Please", "find", "some", "restaurants"}, {"Find", " ", "some", "restaurants"}, {"Show", " ", " ", "restaurants"}, {"Find", "places", "to", "eat"} };

How can I set another output soundcard for "say" command?

On my laptop "say" command works as intended even though i have two sound outputs (Normal and HDMI audio). Due to me recording and producing music too, on my desktop PC i have the normal Soundcard installed in the Tower (which i don't use), and an external one connected over USB. I can switch to which device i wanna use in ubuntu over pulseaudio selection, or even alsa, but it doesn't change which soundcard "say" command is using for output. Is there a way to define that somewhere? if yes maybe we could even add that as a feature to Virtual-Assistant. Help anyone?

ALSA lib pcm_dmix.c:1108 error

I keep getting this error when I try to run the command say "hello"

ALSA lib pcm_dmix.c:1108 : ( snd_pcm_open ) unable to open slave audio_open_alsa: failed to open audio device default. Device or resource busy.

I have no other application using an audio device, Ubuntu-19.04.

libjson0 deprecated or dependency issue with Ubuntu 17.10 (Artful Aardvark)

Attempting to install the transitional packages libjson0/libjson0-dev $ sudo apt-get install libjson0 libjson0-dev during setup on Ubuntu 17.10 results in the following issue:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libjson0
E: Unable to locate package libjson0-dev

Replacing libjson0-dev with libjson-c-dev (see https://packages.debian.org/source/jessie/json-c) in the following manner seems to have solved this problem for me while installing Virtual-Assistant:
sudo apt-get install libjson-c-dev

Please note that this also requires updating the compile statement to:
`gcc main.c $(pkg-config --libs --cflags libcurl) -l json-c -std=gnu11'

And in main.c, #include <json/json.h> must be replaced with:
#include <json-c/json_object.h>
#include <json-c/json_tokener.h>

I would be happy to commit the patch if the developers consider it useful.

Adding details about how to run the program in Readme file

I find it a bit hard to know how to compile and run this program as there are some things to be added to the command while compiling like -std=c99 -lcurl -ljson. I am using the following way to compile " gcc main.c -o a -std=c99 -lcurl -ljson ". Is this the correct way or is there any other easy way I am missing.

Reminder

Reminder which can help us schedule our work or remember special days and to be up to time.

user text recognition

Right now this virtual assistant is comparing strings entered by user directly, But it is not a good way as there are thousands of options and we can't compare all.
So for that purpose we need to make our Virtual assistant intelligent so that it can understand what a user wants it to do.

NLP is one solution to that.

Update Knowledge base (corpus)

To make NLP (Natural Language Processing) better, we need to update the corpus time to time with new additions of data.

Reorgainize preprocessor macros to outside of main function calls

I suggest moving the #include directives outside of function calls, given that they are text replacement by the preprocessor and not handled at runtime. In the process init_config.c can be reorganized with appropriate sanity checks and functions, as generally using an include directive in place of functions is unusual code style.

A.I class for Calendar

Right now we are only having direct comparisons for calendar feature like "open calendar","calendar".

Speech to Text

Virtual assistant is only text to speech at this moment as it is hard to implement Speech to text in C language.
But if we can have Speech to text too, then we'll be able to use it with voice commands also and that'll be an huge improvement.

Things defined in main.c also defined in init_config.c

After I invoke make, this is printed out:

gcc -c -o build/init_config.o src/init_config.c -std=gnu11 -Isrc -Iutils pkg-config --cflags libcurlgcc -o build/virtual_assistant build/main.o build/init_config.o -std=gnu11 -Isrc -Iutilspkg-config --cflags libcurl-lssl -lcrypto -ljson-cpkg-config --libs libcurl/usr/bin/ld: build/init_config.o:(.bss+0x0): multiple definition ofstr'; build/main.o:(.bss+0x11bc0): first defined here
/usr/bin/ld: build/init_config.o:(.bss+0x3e8): multiple definition of start'; build/main.o:(.bss+0x11fa8): first defined here /usr/bin/ld: build/init_config.o:(.bss+0x3f0): multiple definition of pv'; build/main.o:(.bss+0x11fb0): first defined here
/usr/bin/ld: build/init_config.o:(.bss+0x400): multiple definition of location'; build/main.o:(.bss+0x11fc0): first defined here /usr/bin/ld: build/init_config.o:(.bss+0x800): multiple definition of youtube'; build/main.o:(.bss+0x123c0): first defined here
/usr/bin/ld: build/init_config.o:(.bss+0xc00): multiple definition of songs'; build/main.o:(.bss+0x127c0): first defined here /usr/bin/ld: build/init_config.o:(.bss+0x1000): multiple definition of cal'; build/main.o:(.bss+0x12bc0): first defined here
/usr/bin/ld: build/init_config.o:(.bss+0x1080): multiple definition of search'; build/main.o:(.bss+0x12c40): first defined here /usr/bin/ld: build/init_config.o:(.bss+0x1100): multiple definition of HOMEDIR'; build/main.o:(.bss+0x12cc0): first defined here
/usr/bin/ld: build/init_config.o:(.bss+0x1500): multiple definition of WebBrowser'; build/main.o:(.bss+0x130c0): first defined here /usr/bin/ld: build/init_config.o:(.bss+0x1900): multiple definition of MediaPlayer'; build/main.o:(.bss+0x134c0): first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:18: build/virtual_assistant] Error`

[ideas pls] what to contribute

Hello , I am Santhosh and am new to open-source and all .This Virtual assistant seems interesting for me , it would be highly appreciated if u can give me some ideas for me to start and work with and so that I may be able to comtribute :) Thanks

Ineligible Repository For Hacktoberfest

I got started with open source through this project in spirit of taking part in Hacktoberfest. Seems like my PR didnt get counted as it shows this repo as ineligible :\ . Any idea why that happened ?
Thanks!

Add basic math capabilities

i would like to contribute basic math capabilities to the assistant (and update the readme of course), what do you think about that ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.