Skip to content

sayyedrizwan/TextConvertor

Repository files navigation

TextConvertor

Convert Text into Voice(Speech) and Speech into Text..



Speech converting into Text



Text converting into Speech

How to add TextConvertor

Define maven() into repositories

    allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Add the dependency

dependencies {
        implementation 'com.github.sayyedrizwan:TextConvertor:1.4'
}

How to use TextConvertor

To Convert speech into text

TextConvertor.speechtoText(context);  // It will activate voice control to get your voice


// put full switch case in onActivityResult class to get the output

@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    switch (requestCode){
        case 1:
            if (resultCode == RESULT_OK && null!= data){
                ArrayList<String> result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);

                //Get the output of speech
                editText.setText(result.get(0)); // result.get(0) is the output
            }
            break;
    }


}

To Convert text into speech

    TextConvertor.textToSpeech(context, stringoutput);