SmartCarApp/app/src/main/java/com/example/smartcarapp/HomeFragment.java
/*gets the mic input, plays the audio file that's corresponds to the direction of the car
     and calls the metersProcessing funnction to convert the string into an integer if it contains meters*/
gets the mic input, plays the audio file that's corresponds to the direction of the car
and calls the metersProcessing funnction to convert the string into an integer if it contains meters
gets the mic input plays the audio file that ' s corresponds to the direction of the car and calls the metersProcessing funnction to convert the string into an integer if it contains meters
public  void speechCommands(int requestCode, int resultCode, Intent data){
        if (requestCode==10 && resultCode == RESULT_OK && data != null) {
            ArrayList<String> result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
            String stringResult = result.get(0);
            message = SpeechToText.speechCommands(stringResult);
            CountDownTimer cntr_aCounter = new CountDownTimer(150, 1000) {
                @Override
                public void onTick(long l) {
                    if(audioPath!=5){
                        playAudio(audioPath);
                    }
                }
                @Override
                public void onFinish() {
                    if(!message.equals("")){
                        mMqttClient.publish("smartcar/voice", message, 1, null);
                        targetMeters = SpeechToText.metersProcessing(stringResult);
                        if (targetMeters > 0) {
                            String centimeters = String.valueOf(targetMeters*100);
                            mMqttClient.publish("smartcar/voice",centimeters,QOS,null);
                        }
                    }
                }
            };cntr_aCounter.start();
        }
    }
public void speechCommands ( int requestCode , int resultCode , Intent data ) { if ( requestCode == 10 && resultCode == RESULT_OK && data != null ) { ArrayList < String > result = data . getStringArrayListExtra ( RecognizerIntent . EXTRA_RESULTS ) ; String stringResult = result . get ( 0 ) ; message = SpeechToText . speechCommands ( stringResult ) ; CountDownTimer cntr_aCounter = new CountDownTimer ( 150 , 1000 ) { @ Override public void onTick ( long l ) { if ( audioPath != 5 ) { playAudio ( audioPath ) ; } } @ Override public void onFinish ( ) { if ( ! message . equals ( "" ) ) { mMqttClient . publish ( "smartcar/voice" , message , 1 , null ) ; targetMeters = SpeechToText . metersProcessing ( stringResult ) ; if ( targetMeters > 0 ) { String centimeters = String . valueOf ( targetMeters * 100 ) ; mMqttClient . publish ( "smartcar/voice" , centimeters , QOS , null ) ; } } } } ; cntr_aCounter . start ( ) ; } }
gets the mic input, plays the audio file that's corresponds to the direction of the car
and calls the metersProcessing funnction to convert the string into an integer if it contains meters
gets the mic input plays the audio file that ' s corresponds to the direction of the car and calls the metersProcessing funnction to convert the string into an integer if it contains meters
//200 IQ if statement