Skip to content

Commit

Permalink
Prepare to merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
uvlad7 committed Jun 5, 2021
1 parent 64efa22 commit b5141be
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ public class RecognizeFragment extends Fragment implements RecognitionListener {
private static final String KEYPHRASE = "активировать";
/* Named searches allow to quickly reconfigure the decoder */
private static final String PHRASE_SEARCH = "phrase";
private static String grammar_name;
private SpeechRecognizer recognizer;
private Pattern splitter;
private int permissionCheck;
private static final int PERMISSIONS_REQUEST_RECORD_AUDIO = 1;
private List<String> arguments;
private List<Integer> video;
private TextView textViewCommand;
private FloatingActionButton recognizeStart;

private MultipleVideoView videoViewFragmentRecognize;

Expand All @@ -70,11 +70,17 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
View view = inflater.inflate(R.layout.fragment_recognize, container, false);
videoViewFragmentRecognize = new MultipleVideoView(view.findViewById(R.id.videoViewFragmentRecognize));

FloatingActionButton recognizeStart = view.findViewById(R.id.recognizeStartbutton);
recognizeStart = view.findViewById(R.id.recognizeStartbutton);
recognizeStart.setScaleType(ImageView.ScaleType.FIT_CENTER);
textViewCommand = view.findViewById(R.id.textViewCommand);

recognizeStart.setOnClickListener(view1 -> switchSearch(PHRASE_SEARCH));
if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
recognizeStart.setOnClickListener(view1 -> requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, PERMISSIONS_REQUEST_RECORD_AUDIO));
recognizeStart.setEnabled(true);
// recognizeStart.setImageResource(android.R.drawable.ic_lock_silent_mode);
} else {
recognizeStart.setOnClickListener(view1 -> switchSearch(PHRASE_SEARCH));
}
return view;
}

Expand All @@ -100,7 +106,6 @@ public void onCreate(@Nullable Bundle savedInstanceState) {

private void startSetup() {
if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, PERMISSIONS_REQUEST_RECORD_AUDIO);
return;
}
// Recognizer initialization is a time-consuming and it involves IO,
Expand All @@ -113,7 +118,7 @@ private void setupRecognizer(File assetsDir) throws IOException {
// of different kind and switch between them
SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);
int threshold = sharedPref.getInt("sensitivity_of_the_activation_phrase", 6);
grammar_name = sharedPref.getString("grammar_name", getString(R.string.grammar_name_default_value));
String grammar_name = sharedPref.getString("grammar_name", getString(R.string.grammar_name_default_value));
SpeechRecognizerSetup setup = SpeechRecognizerSetup.defaultSetup()
.setAcousticModel(new File(assetsDir, "ru-ru-ptm"))
.setDictionary(new File(assetsDir, "car.dict"))
Expand Down Expand Up @@ -158,9 +163,10 @@ public void onRequestPermissionsResult(int requestCode,
// Recognizer initialization is a time-consuming and it involves IO,
// so we execute it in async task
permissionCheck = PackageManager.PERMISSION_GRANTED;
recognizeStart.setEnabled(false);
recognizeStart.setOnClickListener(view1 -> switchSearch(PHRASE_SEARCH));
// recognizeStart.setImageResource(android.R.drawable.ic_btn_speak_now);
new SetupTask(this).execute();
} else {
requireFragmentManager().beginTransaction().remove(RecognizeFragment.this).commit();
}
}
}
Expand Down

0 comments on commit b5141be

Please sign in to comment.