Skip to content

tarunravi/LGxVoiceControl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

LGxVoiceControl

Overview

Create a DialogFlow Agent which accepts end-user's queries. It extracts keywords (for example, the country name) from those queries and populates those keywords into a Firebase database. Next on Linux, it extracts those keywords from Firebase and displays it on Google Earth.

Installation

Set-Up Dialog Flow

  1. Go to the Dialog Flow Website. Click Sign in wih Google, and sign in.
  2. In the Left Panel, click on Create Agent.
  3. A new window would have appeared in the middle of the page, at the top click on Agent name, and give your agent a name.
  4. Click on CREATE.
  5. After it creates, click on Intents on the left side of the page.
  6. Then click on CREATE INTENT.
  7. Give your Intent a name by clicking on Intent Name, I named my intent AskLocation.
  8. Click on Contexts, followed by ADD CONTEXT. Now, type in an Input Context, I named mine ask_for_location.
  9. Click on Actions and parameters, followed by ADD PARAMETERS AND ACTION.
  10. Under PARAMETER NAME, give it a name, I named mine location.
  11. Under ENTITY, type in @sys.geo-country.
  12. Under VALUE, type in your Parameter Name, so I typed in location.
  13. Click SAVE.
  14. Under Training Phrases, followed by ADD TRAINING PHRASES, type in some Phrases your end users will say. For example I want to look at america (Make sure there is a country in each training phrase). Keep adding new training phrases, as your phrases get populated, DialogFlow will highlight the country names in yellow, if it doesnt double click that country name, next click on location.
  15. Scroll down to Fulfillment, followed by ADD FULFILLMENT, then check the Enable webhook call for this intent.
  16. Click on SAVE.
  17. Your Intent should look like this.
  18. Click back on Intents, then Default Welcome Intent.
  19. Under Contexts, leave the input context blank, for the output context type in the Input Context you set for your previous intent. For me it was ask_for_location. (If you forgot the name of your input context, then click back on Intents, then your other Intent. You should see your input context there)
  20. Still in the Default Welcome Intent, scroll down to Responses. Type in Hi! What do you want to see?
  21. Click on Save.
  22. Your Default Welcome Intent should look like this..

Set-Up Firebase Database

  1. Go to the Firebase Website. Click on Get Started and sign in to your Google Account.
  2. Under Your projects using Firebase, click on the project with the name of your Dialog Flow Agent.
  3. Under Discover Firebase, click on Get Started for the Database box.
  4. Click on Create Database.
  5. Click on Enable.
  6. On the top of the page, next to Database, make sure it says Realtime Databse, if it doesn't, click on the small downward facing triangle, and select Realtime Database.
  7. Make sure, you are under the data section, if not just click on data.
  8. You should see null, hover over that then click on the small plus icon.
  9. For Name, type in a broad name, like location. Don't type in specific names like Country/State etc. I named mine Location.
  10. Leave the value blank, then click on the plus icon next to the value box.
  11. For Name, type in Country. (Remember @sys.geo-country, that extracts countries)
  12. Set the Value to anything, I named mine Empty.
  13. Lastly, click on the Add button.
  14. Copy your database URL, it should end with .firebaseio.com/.
  15. Your Firebase Database should look like this.

DialogFlow and Firebase Fulfillment

  1. Head back over to Dialog Flow.
  2. On the left panel, click on Fulfillment
  3. Enable the Inline Editor, by clicking the Enabled button.
  4. Make sure you are under index.js.
  5. Delete all the code currently in the Inline Editor, and replace it with this.
  6. In the code, replace DATABASEURL with your database URL. When you copy your Database URL, remove the HTTPS://. It should look something like this: ws://NAME.firebaseio.com/.
  7. In the code, replace BROADNAME with the broad name from your database. Mine looks like this: return admin.database().ref('location').transaction((location) => {.
  8. In the code, replace NAMEOFINTENT to what your intent name is. Mine looks like this: intentMap.set('AskLocation', handleLocation);
  9. Click on DEPLOY.
  10. After it deployes, you can test it out. On the Try it now field, type in a greeting (like hi, hello etc). It will respond Hi! What do you want to see?, now type in a country name. It will finally respond Thank You... Viewing (name of your country) on Liquid Galaxy!

Linux Installation

Use the termial for the installation

Set-Up Firebase CLI

  1. Install all updates
    sudo apt-get update
    sudo apt-get upgrade
  2. Install curl:
    sudo apt-get install curl
  3. Install node.js:
    curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
    sudo apt-get install -y nodejs
  4. Install Firebase CLI:
    npm install -g firebase-tools
  5. Log in to Firebase:
    firebase login
    When you run this command, it will ask if Firebase can collect ULI usage and error, just type Y
    Then it will open a window, there you log into your Google Account
  6. Initialize your Firebase CLI:
    firebase init
    When you run this command, it will ask you which features to select, select all of them. To select click on space, and to go down click on the down key. Click enter when you finish selecting them all.

Next, it will ask you to set up a default Firebase project. Select the project which contains your database, from the Set Up Firebase Section.

After that, just keep clicking enter. Until it asks for what language to use.

Chose JavaScript when it askes for what language to use for Cloud Function.
Then, type y for when it askes if you want to use ESLint
Next, type Y when it askes to install dependencies.
After that, click enter when it askes to use your public directory.
Then, type y for when it askes to configure it as a single-page app.
Finally, click enter for when it asks about Storage Rules.

Download Google Earth

  1. On Linux, open the browser and go to the Google Earth download page.
  2. Download and install it, by using the default software install (or any other way to install it).

Editing Google Earth

  1. Navigate to Google Earth folder: cd /opt/google/earth/pro
  2. Edit drivers.ini file with Root privileges: sudo nano drivers.ini Between SETTINGS{ and CPUVertexBlendEfficiency = 1.2, type in the following: ;ViewSync settings
    ViewSync/queryFile = /tmp/query.txt
    ViewSync/send = true
    Click Ctrl-X
    Then Y to Save
  3. drivers.ini should look like this.

Controlling Google Earth

  1. Download Script: wget https://raw.githubusercontent.com/MyWorldRules/LGxVoiceControl/master/LGScript.sh
  2. Edit Script nano LGScript.sh
    Use the arrow keys to go down to firebase database:get /BROADNAME/country > messages.txt. Replace BROADNAME with the Broad Name from the Firebase database.
    Click Ctrl-X
    Then Y to Save
  3. Give execute permission to the script: chmod +x LGScript.sh
  4. Open Google Earth
  5. Run the script: ./LGScript.sh Note: The first time you run the file, you will get a error. From the second time onward there will be no error.
  6. To stop the script, simply click Ctrl-C

About

Control Liquid Galaxy with voice using DialogFlow and Firebase

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published