1.1. 翻译

SpeechRecognizer 中指定对应的参数后,可以使用翻译功能,即传入当前语种音频,返回识别并翻译后的目标语种文本结果。

主要涉及以下参数

  • SpeechConstant.ASR_SCH 启用翻译
  • SpeechConstant.ADD_CAP 翻译通道
  • SpeechConstant.ORI_LANG 原始语种
  • SpeechConstant.TRANS_LANG 目标语种
  • SpeechConstant.TRS_SRC 结果格式
  1. mAsr.setParameter( SpeechConstant.ASR_SCH, "1" );
  2. mAsr.setParameter( SpeechConstant.ADD_CAP, "translate" );
  3. mAsr.setParameter( SpeechConstant.TRS_SRC, "its" );
  4. mAsr.setParameter( SpeechConstant.ORI_LANG, "cn" );
  5. mAsr.setParameter( SpeechConstant.TRANS_LANG, "en" );
  6. mAsr.startListening( mRecognizerListener );

翻译结果格式,参考附录-翻译结果