ICP 3 - Gnkhakimova/CS5551 GitHub Wiki

ICP 3

Objectives

Used two controllers for the following ICP.

Task 1

The purpose of this task is to create a web application which will get meal name which will be entered by user and output how many calories are there and serving weight by making API call to Nutritionix.

Task 2

In following task we need to perform text to speech using Watson API which converts text to Audio. User can enter text which needs to be spoke out entered text or read output from task 1.

Steps

I have a web page with two animations: one for each task.

  • First animation has input field and search button. User input food name and clicks to search button, application will perform API call to get calories and serving weight, which will be outputted as a text and also will be read by Watson speech to text API.
  • Second animation also has input field and speak out button, user can input text which he wants to hear and application will read it using Watson text to speech API.

Source Code

HTML
Used simple bootsrap theme from colorlib.com and modified UI to fit application requirements. Animation change every second and also can be controller by slider which is provided on right hand side - two dots. First animation read input text from the user and on button click calls getCalories() function using ng-click.
Second animation also has input field and a button which get input text and performs text to speech by calling Watson API. On button click speakOut() function is called using ng-click.
JS
Using AngularJS create one app called food and two controllers: foodctrl and watsonctrl. Watson controller is a parent of food controller which will help us to call a function speakOut from parent controller to perform text to speech on returned result from NutritionIX API.
Parent, child controllers

First controller
Following controller called NutritionIX API to get calories and serving weight of food. Performing GET request using AngularJS and passing food name. Then parsing response and outputting required result: calories and serving weight of meal. Also calling speckOut function from second controller to read result.

Second Controller
This controller calls Watson API to perform text to speech which gets input text and speaks it out. Passing out: username, password and text which needs to be read.

Video

Presented ICP in class.