VokaturiAndroid


Source link: https://github.com/alshell7/VokaturiAndroid

Vokaturi - Android Library

Android port of the Vokaturi emotion recognition API.

Overview

Vokaturi is an emotion recognition software, that can understand the emotions in a speaker's voice. Currently Vokaturi is available for iOS, Windows, MacOS. This project adds up to support for Android platform as well. Vokaturi maintains three separate versions of its software library for recognizing emotions. The android library provided in this project is implemented using JNI framework and built up on the OpenVokaturi that is distributed under General Public License (GPL).

Currently the community version of the Vokaturi is able to detect five different types of emotions.

  • Neutrality
  • Happiness
  • Sadness
  • Anger
  • Fear

Demo

To have a check on the library, download the demo apk

Demo application shows the following emoji's based on the results detected from voice.

🔧 Installation

To add emotion recognition by speech functionality in your app, Add the library in your Project build.gradle :

allprojects {
  repositories {

...
maven {
 url 'https://jitpack.io' 
}
  
}
 
}

Add the dependency in the build.gradle (Module: app) :

dependencies {
  compile 'com.github.alshell7:VokaturiAndroid:{
version-number
}
' 
}

Check out the latest release or from the badge above for the version number.

💡 Usage

Permissions

  • To be able to record and analyze for emotions from a given audio file, your app must tell the user that it will access the device's audio input and read from external storage. You must include these permission tags in the app's manifest file :
<uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

Java

  • To instantiate the library and get access to its functions, retrieve the singleton instance of the Vokaturi class :
Vokaturi vokaturiApi;  try {

 vokaturiApi = Vokaturi.getInstance(getApplicationContext());
  
}
 catch (VokaturiException e) {

 e.printStackTrace();
 
}
  • Start recording the voice from the device :
vokaturiApi.startListeningForSpeech();
  • Stop recording and analyze for emotions :
EmotionProbabilities emotionProbabilities = vokaturiApi.stopListeningAndAnalyze();

Recording of voice from the audio input hardware of the device is automatically handled by the library, so you need not to worry about using AudioRecord and MediaRecord classes.

  • Access the metrics of emotions :
logD("Neutrality: " + emotionProbabilities.Neutrality);
 logD("Happiness: " + emotionProbabilities.Happiness);
 logD("Sadness: " + emotionProbabilities.Sadness);
 logD("Anger: " + emotionProbabilities.Anger);
 logD("Fear: " + emotionProbabilities.Fear);

Since the method stopListeningAndAnalyze() returns back highly accurate metrics of emotions analyzed from the speech data captured, you can trim the length of values in EmotionProbabilities by calling the method :

EmotionProbabilities.scaledValues(int scale);

For example, the value 0.0780483331548E-15, after calling scaledValues(5), value will change to 0.07805

  • Detect the exact dominating emotion from the metrics 🔎 :
Emotion capturedEmotion = Vokaturi.extractEmotion(EmotionProbabilities emotionProbabilities)

The returned value can be any of the below encapsulated values :

public enum Emotion {

 Neutral,
 Happy,
 Sad,
 Angry,
 Feared 
}

Analyze asynchronously

You can use async method to analyze for emotions on a background thread. But only if you wish to handle voice recording by yourself, or want to voluntarily process any audio file to extract emotions.

vokaturiApi.AnalyzeForEmotionsAsync(MainActivity.this, fileName, new VokaturiAsyncResult()

 {

  @Override

  public void onSuccess(EmotionProbabilities emotionProbabilities)

  {

//If there were no exceptions thrown by the native code

  
}

 @Override

  public void onError(VokaturiException e)

  {

  //If there was some problem that occurred while processing

  
}

 
}
);
  • Important Note : Vokaturi currently supports audio file of WAV format only. Trying to process audio file of any other format will result in receiving an exception 👻.

💬 Error codes

The exception class thrown by the library is common for both the exceptions triggered from the native and java implementation as well. The exception comes along with the error codes, so that you can take actions based on the type of the exception.

The error codes associated with the exception are as follows :

  • VOKATURI_ERROR - Generic error.

  • VOKATURI_NOT_ENOUGH_SONORANCY - If the speech sound that is produced is not continuous, and has turbulent audio.

  • VOKATURI_DENIED_PERMISSIONS - File Read Write/Recording audio permissions not granted for the application.

  • VOKATURI_INVALID_WAV_FILE - The given file is not of a valid WAV format.

💤 Few Tips

  • You can use in built recorder to record audio in WAV format, in case you wish to handle the voice recording by yourself.

  • Need some more info?, you can download the java documentation for the library.

  • Found some problems in the library?, feel easy to report it in the issues.

How to Contribute?

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request 🙉

Licenses

Copyright 2017 alshell7  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 
 Copyright (C) 2016,2017 Paul Boersma, Johnny Ip, Toni Gojani  version 2.0, 2017-01-02
 OpenVokaturi is free software; you can redistribute it and/or modify  it under the terms of the GNU General Public License as published by  the Free Software Foundation; either version 3 of the License, or (at  your option) any later version.
 OpenVokaturi is distributed in the hope that it will be useful, but  WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details. 

Resources

A simple & fluent Android ORM, how can it be easier? And it's compatible with RxJava2!

The Bluetooth Filter library allows for a more fine grained discovery. Developed with purpose-build Android application where they connect to one or two specific Bluetooth devices in mind. The Bluetooth Filter library allows those apps to only provide a minimum list of results to their users rather instead of the usual general list of all devices found.

Widget to calibrate sensors (Orientation). This Calibrator can be embedded in your own App.

Android library which can turn any View into a draggable dialog with swipe to dismiss feature.

Project to set up basics of a Java annotation processor.

Motivations

  • Provide a fluent and complete stack to write a custom annotation processor using Android Studio
  • Set up a robust testing strategy of the Processor implementation

An easy way to build RecyclerView.Adapter. This adapter also has multiple ItemViewType, if needed.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes