Android-TTS-STT icon indicating copy to clipboard operation
Android-TTS-STT copied to clipboard

Don't use it - it supports only english

Open superzebra2 opened this issue 5 years ago • 3 comments

and i was trying to modify libs to add support of multi language for tts and voice recognition - but it is hard

superzebra2 avatar May 13 '19 22:05 superzebra2

Change language in intent,


class SpeechToTextConverter(private val conversionCallback: ConversionCallback)  : TranslatorFactory.IConverter {
    private   val  TAG = SpeechToTextConverter::class.java.name
    override fun initialize(message: String, appContext: Activity): SpeechToTextConverter {
        val intent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
                RecognizerIntent.LANGUAGE_MODEL_FREE_FORM)
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault())

example for chinease

intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "zh-cmn");

hiteshsahu avatar May 15 '19 08:05 hiteshsahu

For Text to speech

Replace

textToSpeech!!.language = Locale.getDefault()

in


override fun initialize(message: String, appContext: Activity): TranslatorFactory.IConverter {
       textToSpeech = TextToSpeech(appContext, TextToSpeech.OnInitListener { status ->
           if (status != TextToSpeech.ERROR) {
               textToSpeech!!.language = Locale.getDefault()

with your local example chinese:

textToSpeech!!.language =new Locale("zh-cmn");

hiteshsahu avatar May 15 '19 08:05 hiteshsahu

what if we want to change languages at runtime

ahmedbilal205 avatar Dec 11 '22 00:12 ahmedbilal205