├── app
├── .gitignore
├── libs
│ ├── galaxy-v2.0.jar
│ ├── com.baidu.tts.jar
│ ├── arm64-v8a
│ │ ├── libbdtts.so
│ │ ├── libbd_etts.so
│ │ ├── libgnustl_shared.so
│ │ ├── libBDSpeechDecoder_V1.so
│ │ ├── libbdEASRAndroid.v1.9.11.so
│ │ ├── libBDVoiceRecognitionClient_MFE_V1_s2.so
│ │ └── libbd_easr_s1_merge_normal_20151216.dat.so
│ ├── armeabi
│ │ ├── libbd_etts.so
│ │ ├── libbdtts.so
│ │ ├── libgnustl_shared.so
│ │ ├── libBDSpeechDecoder_V1.so
│ │ ├── libbdEASRAndroid.v1.9.11.so
│ │ ├── libBDVoiceRecognitionClient_MFE_V1_s2.so
│ │ └── libbd_easr_s1_merge_normal_20151216.dat.so
│ └── VoiceRecognition-2.1.20.jar
├── src
│ ├── main
│ │ ├── assets
│ │ │ ├── WakeUp.bin
│ │ │ ├── bd_etts_text.dat
│ │ │ └── bd_etts_speech_female.dat
│ │ ├── res
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── mic_btn.png
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── input_btn.png
│ │ │ │ ├── mic_btn_pressed.png
│ │ │ │ ├── input_btn_disabled.png
│ │ │ │ └── input_btn_pressed.png
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── input_btn.png
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── input_btn_disabled.png
│ │ │ │ └── input_btn_pressed.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values
│ │ │ │ ├── colors.xml
│ │ │ │ ├── styles.xml
│ │ │ │ └── strings.xml
│ │ │ ├── drawable
│ │ │ │ └── redius_rec.xml
│ │ │ ├── layout
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── fragment_voice_input.xml
│ │ │ │ └── fragment_main.xml
│ │ │ └── values-zh
│ │ │ │ └── strings.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── ooolab
│ │ │ │ └── whatiswhat
│ │ │ │ ├── QueryParser.java
│ │ │ │ ├── HurlStackWrapper.java
│ │ │ │ ├── StringRequestWrapper.java
│ │ │ │ ├── Utils.java
│ │ │ │ ├── WebViewClientWrapper.java
│ │ │ │ ├── BaiduBaikeHandler.java
│ │ │ │ ├── MainFragment.java
│ │ │ │ ├── MicrophoneView.java
│ │ │ │ ├── VoiceInputFragment.java
│ │ │ │ └── MainActivity.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── ooolab
│ │ │ └── whatiswhat
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── ooolab
│ │ └── whatiswhat
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── README.md
├── gradlew.bat
├── gradlew
└── LICENSE
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/app/libs/galaxy-v2.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/libs/galaxy-v2.0.jar
--------------------------------------------------------------------------------
/app/libs/com.baidu.tts.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/libs/com.baidu.tts.jar
--------------------------------------------------------------------------------
/app/libs/arm64-v8a/libbdtts.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/libs/arm64-v8a/libbdtts.so
--------------------------------------------------------------------------------
/app/libs/armeabi/libbd_etts.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/libs/armeabi/libbd_etts.so
--------------------------------------------------------------------------------
/app/libs/armeabi/libbdtts.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/libs/armeabi/libbdtts.so
--------------------------------------------------------------------------------
/app/src/main/assets/WakeUp.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/src/main/assets/WakeUp.bin
--------------------------------------------------------------------------------
/app/libs/arm64-v8a/libbd_etts.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/libs/arm64-v8a/libbd_etts.so
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/libs/VoiceRecognition-2.1.20.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/libs/VoiceRecognition-2.1.20.jar
--------------------------------------------------------------------------------
/app/libs/armeabi/libgnustl_shared.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/libs/armeabi/libgnustl_shared.so
--------------------------------------------------------------------------------
/app/src/main/assets/bd_etts_text.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/src/main/assets/bd_etts_text.dat
--------------------------------------------------------------------------------
/app/libs/arm64-v8a/libgnustl_shared.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/libs/arm64-v8a/libgnustl_shared.so
--------------------------------------------------------------------------------
/app/libs/armeabi/libBDSpeechDecoder_V1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/libs/armeabi/libBDSpeechDecoder_V1.so
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/mic_btn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/src/main/res/mipmap-xhdpi/mic_btn.png
--------------------------------------------------------------------------------
/app/libs/arm64-v8a/libBDSpeechDecoder_V1.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/libs/arm64-v8a/libBDSpeechDecoder_V1.so
--------------------------------------------------------------------------------
/app/libs/armeabi/libbdEASRAndroid.v1.9.11.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/libs/armeabi/libbdEASRAndroid.v1.9.11.so
--------------------------------------------------------------------------------
/app/src/main/assets/bd_etts_speech_female.dat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/src/main/assets/bd_etts_speech_female.dat
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/input_btn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/src/main/res/mipmap-xhdpi/input_btn.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/input_btn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/src/main/res/mipmap-xxxhdpi/input_btn.png
--------------------------------------------------------------------------------
/app/libs/arm64-v8a/libbdEASRAndroid.v1.9.11.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/libs/arm64-v8a/libbdEASRAndroid.v1.9.11.so
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/mic_btn_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/src/main/res/mipmap-xhdpi/mic_btn_pressed.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/input_btn_disabled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/src/main/res/mipmap-xhdpi/input_btn_disabled.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/input_btn_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/src/main/res/mipmap-xhdpi/input_btn_pressed.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/input_btn_disabled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/src/main/res/mipmap-xxxhdpi/input_btn_disabled.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/input_btn_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/src/main/res/mipmap-xxxhdpi/input_btn_pressed.png
--------------------------------------------------------------------------------
/app/libs/armeabi/libBDVoiceRecognitionClient_MFE_V1_s2.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/libs/armeabi/libBDVoiceRecognitionClient_MFE_V1_s2.so
--------------------------------------------------------------------------------
/app/libs/arm64-v8a/libBDVoiceRecognitionClient_MFE_V1_s2.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/libs/arm64-v8a/libBDVoiceRecognitionClient_MFE_V1_s2.so
--------------------------------------------------------------------------------
/app/libs/armeabi/libbd_easr_s1_merge_normal_20151216.dat.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/libs/armeabi/libbd_easr_s1_merge_normal_20151216.dat.so
--------------------------------------------------------------------------------
/app/libs/arm64-v8a/libbd_easr_s1_merge_normal_20151216.dat.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solrex/WhatIsWhat/HEAD/app/libs/arm64-v8a/libbd_easr_s1_merge_normal_20151216.dat.so
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 | app/src/main/res/values/apikey.xml
11 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 | * Notes:
21 | *
22 | *
28 | *
101 | * See the Android Training lesson Communicating with Other Fragments for more information. 104 | */ 105 | public interface OnInputBtnClickListner { 106 | // TODO: Update argument type and name 107 | void onInputBtnClick(View v); 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /app/src/main/java/com/ooolab/whatiswhat/MicrophoneView.java: -------------------------------------------------------------------------------- 1 | package com.ooolab.whatiswhat; 2 | 3 | import android.animation.AnimatorSet; 4 | import android.animation.ObjectAnimator; 5 | import android.content.Context; 6 | import android.graphics.Bitmap; 7 | import android.graphics.BitmapFactory; 8 | import android.graphics.Canvas; 9 | import android.graphics.Color; 10 | import android.graphics.Paint; 11 | import android.speech.SpeechRecognizer; 12 | import android.util.AttributeSet; 13 | import android.util.Log; 14 | import android.util.TypedValue; 15 | import android.view.MotionEvent; 16 | import android.view.View; 17 | 18 | 19 | /** 20 | * TODO: document your custom view class. 21 | */ 22 | public class MicrophoneView extends View { 23 | 24 | private static final int STATE_RECORDING = 0; 25 | private static final int STATE_PRESSED = 1; 26 | private int mState = STATE_RECORDING; 27 | 28 | private Bitmap mRecordingBitmap; 29 | private Bitmap mPressedBitmap; 30 | 31 | private Paint mPaint; 32 | private AnimatorSet mAnimatorSet = new AnimatorSet(); 33 | 34 | private float mMinRadius; 35 | private float mMaxRadius; 36 | private float mCurrentRadius; 37 | 38 | public MicrophoneView(Context context) { 39 | super(context); 40 | init(null, 0); 41 | } 42 | 43 | public MicrophoneView(Context context, AttributeSet attrs) { 44 | super(context, attrs); 45 | init(attrs, 0); 46 | } 47 | 48 | public MicrophoneView(Context context, AttributeSet attrs, int defStyle) { 49 | super(context, attrs, defStyle); 50 | init(attrs, defStyle); 51 | } 52 | 53 | private void init(AttributeSet attrs, int defStyle) { 54 | mRecordingBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.mic_btn); 55 | mPressedBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.mic_btn_pressed); 56 | 57 | mPaint = new Paint(); 58 | mPaint.setAntiAlias(true); 59 | mPaint.setColor(Color.argb(255, 0x9e, 0x9e, 0x9e)); 60 | 61 | mMinRadius = dp2px(getContext(), 96) / 2; 62 | mCurrentRadius = mMinRadius; 63 | 64 | setClickable(true); 65 | } 66 | 67 | public static int dp2px(Context context, int dp){ 68 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, context.getResources().getDisplayMetrics()); 69 | } 70 | 71 | @Override 72 | protected void onSizeChanged(int w, int h, int oldw, int oldh) { 73 | super.onSizeChanged(w, h, oldw, oldh); 74 | mMaxRadius = Math.min(w, h) / 2; 75 | Log.d("", "MaxRadius: " + mMaxRadius); 76 | } 77 | 78 | @Override 79 | protected void onDraw(Canvas canvas) { 80 | super.onDraw(canvas); 81 | 82 | int width = canvas.getWidth(); 83 | int height = canvas.getHeight(); 84 | 85 | if(mCurrentRadius > mMinRadius){ 86 | canvas.drawCircle(width / 2, height / 2, mCurrentRadius, mPaint); 87 | } 88 | 89 | switch (mState){ 90 | case STATE_RECORDING: 91 | canvas.drawBitmap(mRecordingBitmap, width / 2 - mMinRadius, height / 2 - mMinRadius, mPaint); 92 | break; 93 | case STATE_PRESSED: 94 | canvas.drawBitmap(mPressedBitmap, width / 2 - mMinRadius, height / 2 - mMinRadius, mPaint); 95 | break; 96 | } 97 | } 98 | 99 | public void animateRadius(float radius){ 100 | if(radius <= mCurrentRadius){ 101 | return; 102 | } 103 | if(radius > mMaxRadius){ 104 | radius = mMaxRadius; 105 | }else if(radius < mMinRadius){ 106 | radius = mMinRadius; 107 | } 108 | if(radius == mCurrentRadius){ 109 | return; 110 | } 111 | if(mAnimatorSet.isRunning()){ 112 | mAnimatorSet.cancel(); 113 | } 114 | mAnimatorSet.playSequentially( 115 | ObjectAnimator.ofFloat(this, "CurrentRadius", getCurrentRadius(), radius).setDuration(50), 116 | ObjectAnimator.ofFloat(this, "CurrentRadius", radius, mMinRadius).setDuration(600) 117 | ); 118 | mAnimatorSet.start(); 119 | } 120 | 121 | public float getCurrentRadius() { 122 | return mCurrentRadius; 123 | } 124 | 125 | public void setCurrentRadius(float currentRadius) { 126 | mCurrentRadius = currentRadius; 127 | invalidate(); 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /app/src/main/java/com/ooolab/whatiswhat/VoiceInputFragment.java: -------------------------------------------------------------------------------- 1 | package com.ooolab.whatiswhat; 2 | 3 | import android.content.ComponentName; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.os.Bundle; 7 | import android.speech.RecognitionListener; 8 | import android.speech.SpeechRecognizer; 9 | import android.support.v4.app.Fragment; 10 | import android.view.LayoutInflater; 11 | import android.view.View; 12 | import android.view.ViewGroup; 13 | import android.widget.TextView; 14 | 15 | import com.baidu.speech.VoiceRecognitionService; 16 | 17 | import java.util.ArrayList; 18 | 19 | /*enum VSRErrors { 20 | NETWORK_TIMEOUT(1, "error_on_network_timeout"), 21 | NETWORK_UNKNOWN(2, "error_on_network_unknown"), 22 | AUDIO_RECORDING(3, "error_on_audio_recording"), 23 | SERVER_RESPONSE(4, "error_on_server_response"), 24 | CLIENT_UNKNOWN(5, "error_on_client_unknown"), 25 | SPEECH_TIMEOUT(6, "error_on_speech_timeout"), 26 | NO_RESULT(7, "error_on_no_result"), 27 | RECOGNIZER_BUSY(8, "error_on_recognizer_busy"), 28 | INSUFFICIENT_PERMISSIONS(9, "error_on_insufficient_permissions"); 29 | 30 | private final int code; 31 | private final String message; 32 | 33 | private VSRErrors(int code, String message) { 34 | this.code = code; 35 | this.message = message; 36 | } 37 | 38 | public String getMessage() { 39 | return message; 40 | } 41 | 42 | public int getCode() { 43 | return code; 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | return code + ": " + message; 49 | } 50 | }*/ 51 | 52 | /** 53 | * A simple {@link Fragment} subclass. 54 | * Activities that contain this fragment must implement the 55 | * {@link VoiceInputFragment.OnFragmentInteractionListener} interface 56 | * to handle interaction events. 57 | * Use the {@link VoiceInputFragment#newInstance} factory method to 58 | * create an instance of this fragment. 59 | */ 60 | public class VoiceInputFragment extends Fragment implements RecognitionListener { 61 | private SpeechRecognizer mSpeechRecognizer; 62 | private TextView mRecogTextView; 63 | private MicrophoneView mMicButtonView; 64 | 65 | private OnRecogResultListener mListener; 66 | 67 | public VoiceInputFragment() { 68 | // Required empty public constructor 69 | } 70 | 71 | /** 72 | * Use this factory method to create a new instance of 73 | * this fragment using the provided parameters. 74 | * 75 | * @param param1 Parameter 1. 76 | * @param param2 Parameter 2. 77 | * @return A new instance of fragment VoiceInputFragment. 78 | */ 79 | // TODO: Rename and change types and number of parameters 80 | // public static VoiceInputFragment newInstance(String param1, String param2) { 81 | // VoiceInputFragment fragment = new VoiceInputFragment(); 82 | // Bundle args = new Bundle(); 83 | // args.putString(ARG_PARAM1, param1); 84 | // args.putString(ARG_PARAM2, param2); 85 | // fragment.setArguments(args); 86 | // return fragment; 87 | // } 88 | 89 | @Override 90 | public void onCreate(Bundle savedInstanceState) { 91 | super.onCreate(savedInstanceState); 92 | mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(getContext(), new ComponentName(getContext(), VoiceRecognitionService.class)); 93 | mSpeechRecognizer.setRecognitionListener(this); 94 | } 95 | 96 | private void startRecognition() { 97 | Intent intent = new Intent(); 98 | mSpeechRecognizer.startListening(intent); 99 | mRecogTextView.setText(R.string.voice_input_intro); 100 | } 101 | 102 | 103 | public void stopRecognition() { 104 | mSpeechRecognizer.stopListening(); 105 | } 106 | 107 | @Override 108 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 109 | Bundle savedInstanceState) { 110 | // Inflate the layout for this fragment 111 | View v = inflater.inflate(R.layout.fragment_voice_input, container, false); 112 | mRecogTextView = (TextView) v.findViewById(R.id.voice_input_partial); 113 | mMicButtonView = (MicrophoneView) v.findViewById(R.id.mic_btn); 114 | mMicButtonView.setOnClickListener(new View.OnClickListener() { 115 | public void onClick(View v) { 116 | stopRecognition(); 117 | } 118 | }); 119 | startRecognition(); 120 | return v; 121 | } 122 | 123 | @Override 124 | public void onAttach(Context context) { 125 | super.onAttach(context); 126 | if (context instanceof OnRecogResultListener) { 127 | mListener = (OnRecogResultListener) context; 128 | } else { 129 | throw new RuntimeException(context.toString() 130 | + " must implement OnFragmentInteractionListener"); 131 | } 132 | } 133 | 134 | @Override 135 | public void onDetach() { 136 | super.onDetach(); 137 | mListener = null; 138 | mSpeechRecognizer.destroy(); 139 | } 140 | 141 | 142 | /** 143 | * This interface must be implemented by activities that contain this 144 | * fragment to allow an interaction in this fragment to be communicated 145 | * to the activity and potentially other fragments contained in that 146 | * activity. 147 | *
148 | * See the Android Training lesson Communicating with Other Fragments for more information.
151 | */
152 | public interface OnRecogResultListener {
153 | // TODO: Update argument type and name
154 | void onRecogResult(Bundle bundle);
155 | }
156 |
157 | @Override
158 | public void onReadyForSpeech(Bundle bundle) {
159 |
160 | }
161 |
162 | @Override
163 | public void onBeginningOfSpeech() {
164 |
165 | }
166 |
167 | @Override
168 | public void onRmsChanged(float v) {
169 | mMicButtonView.animateRadius(v);
170 | }
171 |
172 | @Override
173 | public void onBufferReceived(byte[] bytes) {
174 |
175 | }
176 |
177 | @Override
178 | public void onEndOfSpeech() {
179 |
180 | }
181 |
182 | @Override
183 | public void onError(int i) {
184 | Bundle bundle = new Bundle();
185 | bundle.putInt("error", i);
186 | if (mListener != null) {
187 | mListener.onRecogResult(bundle);
188 | }
189 | }
190 |
191 | @Override
192 | public void onResults(Bundle bundle) {
193 | if (mListener != null) {
194 | mListener.onRecogResult(bundle);
195 | }
196 | }
197 |
198 | @Override
199 | public void onPartialResults(Bundle bundle) {
200 | ArrayList