2

Google Speech-to-Text API supports Marathi as per their documentation here. However I have not been able to get it working on my Android phone. I have already added 'Marathi' in languages for my Android device (Moto G6, running android 7.1.1). However, I am not yet able to get a simple SMS converted from speech-to-text with this. Marathi typing works fine though.

Do I need to modify any other setting? What else is required? Any pointers for this would be highly appreciated.

Manish
  • 1,735
  • 2
  • 17
  • 30
  • Do you have add in the manifest the permission READ_SMS ? – Gianluca Benucci Mar 19 '19 at 07:54
  • I was referring to directly using Marathi speech-to-text with SMS on android, app is not even in the picture at this stage. Even that is not working :( – Manish Mar 21 '19 at 18:20
  • A good starting point for Speech API is the [samples app](https://github.com/GoogleCloudPlatform/android-docs-samples/tree/master/speech/Speech) on Github. Take also a look at [this](https://github.com/GoogleCloudPlatform/android-docs-samples/blob/master/speech/Speech/app/src/main/java/com/google/cloud/android/speech/SpeechService.java) is the **SpeechService** that handle all stuff related to SpeechApi and remember to read the [best practices](https://cloud.google.com/speech-to-text/docs/best-practices) – Gianluca Benucci Mar 19 '19 at 08:02

1 Answers1

0

Have you configured your intent to detect marathi languages as below?

intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,"mr-IN");

You can checkout other languages codes here.

You can use following code for your reference:

@Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.RecordBtn:
                Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);

                //  Use Off line Recognition Engine only...
                intent.putExtra(RecognizerIntent.EXTRA_PREFER_OFFLINE, false);

                //  Use Marathi Speech Recognition Model...
                intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "mr-IN");

                try {
                    startActivityForResult(intent, SST_REQUEST_CODE);
                } catch (ActivityNotFoundException a) {
                    Toast.makeText(getApplicationContext(),
                            getString(R.string.error),
                            Toast.LENGTH_SHORT).show();
                }

                break;
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        switch (requestCode) {
            case SST_REQUEST_CODE:
                if (resultCode == RESULT_OK && null != data) {
                    ArrayList<String> getResult = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
                    Original.setText(getResult.get(0));
                    conversionTable = new ConversionTable();
                    String Transformed_String = conversionTable.transform(getResult.get(0));
                    result.setText(Transformed_String);
                }
                break;
        }
    }
Jay Dangar
  • 3,271
  • 1
  • 16
  • 35