Click here to Skip to main content
15,889,200 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I really have to implement a Speech-to-text API in android studio. Help me please.
I searched some codes but it requires MS visual studio.

What I have tried:

i tried this code;
private void startSpeechToText() {
        Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
                RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
        intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Speech-to-text input");
        startActivityForResult(intent, REQUEST_CODE);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == REQUEST_CODE && resultCode == RESULT_OK)
        {
            ArrayList<String> result = data
                    .getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
            String text = result.get(0);
            itemName.setText(text);

        }
        super.onActivityResult(requestCode, resultCode, data);
    }

private final int REQUEST_CODE = 1234;
Posted
Updated 25-Jan-17 4:01am

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900