Android-TTS-STT
Android-TTS-STT copied to clipboard
Don't use it - it supports only english
and i was trying to modify libs to add support of multi language for tts and voice recognition - but it is hard
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");
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");
what if we want to change languages at runtime