Libraryless. Click here for Pure Java version (163L/2K/5K).
1 | !747 |
2 | |
3 | import android.app.*; |
4 | import android.widget.*; |
5 | import android.view.*; |
6 | import android.view.View; |
7 | import android.view.KeyEvent; |
8 | import android.view.inputmethod.*; |
9 | import android.text.*; |
10 | import android.content.*; |
11 | import android.speech.*; |
12 | |
13 | m {
|
14 | static Activity androidContext; |
15 | static final int REQUEST_CODE = 1234; |
16 | |
17 | p {
|
18 | print("Starting voice recog");
|
19 | startVoiceRecognitionActivity(); |
20 | print("Starting done");
|
21 | } |
22 | |
23 | static void startVoiceRecognitionActivity() {
|
24 | Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); |
25 | intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, |
26 | RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); |
27 | intent.putExtra(RecognizerIntent.EXTRA_PROMPT, |
28 | "AndroidBite Voice Recognition..."); |
29 | androidContext.startActivityForResult(intent, REQUEST_CODE); |
30 | } |
31 | |
32 | static void onActivityResult(int requestCode, int resultCode, Intent data) {
|
33 | print("onActivityResult");
|
34 | if (requestCode == REQUEST_CODE && resultCode == Activity.RESULT_OK) {
|
35 | ArrayList<String> matches = data |
36 | .getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); |
37 | /*resultList.setAdapter(new ArrayAdapter<string>(this, |
38 | android.R.layout.simple_list_item_1, matches));*/ |
39 | print("Matches: " + structure(matches));
|
40 | } |
41 | //super.onActivityResult(requestCode, resultCode, data); |
42 | } |
43 | } |
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: | 899 / 1089 |
| Referenced in: | [show references] |