Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

43
LINES

< > BotCompany Repo | #1001128 // Android: Speech recognition test (works with JavaX 26 :)

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (163L/2K/5K).

!747

import android.app.*;
import android.widget.*;
import android.view.*;
import android.view.View;
import android.view.KeyEvent;
import android.view.inputmethod.*;
import android.text.*;
import android.content.*;
import android.speech.*;

m {
  static Activity androidContext;
  static final int REQUEST_CODE = 1234;  
 
  p {
    print("Starting voice recog");
    startVoiceRecognitionActivity();
    print("Starting done");
  }
  
  static void startVoiceRecognitionActivity() {
    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
      RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
    intent.putExtra(RecognizerIntent.EXTRA_PROMPT,
      "AndroidBite Voice Recognition...");
    androidContext.startActivityForResult(intent, REQUEST_CODE);
  }
 
  static void onActivityResult(int requestCode, int resultCode, Intent data) {
    print("onActivityResult");
    if (requestCode == REQUEST_CODE && resultCode == Activity.RESULT_OK) {
      ArrayList<String> matches = data
        .getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
      /*resultList.setAdapter(new ArrayAdapter<string>(this,
       android.R.layout.simple_list_item_1, matches));*/
      print("Matches: " + structure(matches));
    }
    //super.onActivityResult(requestCode, resultCode, data);
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1001128
Snippet name: Android: Speech recognition test (works with JavaX 26 :)
Eternal ID of this version: #1001128/1
Text MD5: c2ef7dc0ee6fcef848c0630ac432d5fd
Transpilation MD5: 3fea2d39808f153ac830544dd4fb34e6
Author: stefan
Category:
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-09-23 16:50:26
Source code size: 1402 bytes / 43 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 662 / 811
Referenced in: [show references]