Ejemplo n.º 1
0
 public void init() {
   if (mSpeechSynthesizer == null) {
     SpeechUtility.createUtility(
         mContext, SpeechConstant.APPID + mContext.getString(R.string.app_id));
     // 初始化合成对象.
     mSpeechSynthesizer = SpeechSynthesizer.createSynthesizer(mContext, minitListener);
     initSpeechSynthesizer();
   }
 }
  public void init(Context context) {
    mContext = context;

    SpeechUtility.createUtility(context, SpeechConstant.APPID + "=565eb095");
    // 1.创建SpeechRecognizer对象,第二个参数:本地听写时传InitListener
    mIat = SpeechRecognizer.createRecognizer(context, null);

    setParam(mIat);
  }
Ejemplo n.º 3
0
 private void initSpeech() {
   // 用于验证应用的key
   SpeechUtility.createUtility(RecodeActivity.this, "appid=5577f954");
   // 创建语音听写对象
   mIat = SpeechRecognizer.createRecognizer(this, mInitListener);
   // 初始化听写Dialog,如果只使用有UI听写功能,无需创建SpeechRecognizer
   // 创建语音听写UI
   iatDialog = new RecognizerDialog(this, mInitListener);
   // 创建语音合成对象
   mTts = SpeechSynthesizer.createSynthesizer(this, mInitListener);
 }
  @Override
  public void onCreate() {
    // 应用程序入口处调用,避免手机内存过小,杀死后台进程后通过历史intent进入Activity造成SpeechUtility对象为null
    // 如在Application中调用初始化,需要在Mainifest中注册该Applicaiton
    // 注意:此接口在非主进程调用会返回null对象,如需在非主进程使用语音功能,请增加参数:SpeechConstant.FORCE_LOGIN+"=true"
    // 参数间使用半角“,”分隔。
    // 设置你申请的应用appid,请勿在'='与appid之间添加空格及空转义符

    // 注意: appid 必须和下载的SDK保持一致,否则会出现10407错误

    SpeechUtility.createUtility(
        GlobalParameterApplication.this, "appid=" + getString(R.string.app_id));
    // SpeechUtility.createUtility(GlobalParameterApplication.this, "appid=" +
    // getString(R.string.app_id));

    // 以下语句用于设置日志开关(默认开启),设置成false时关闭语音云SDK日志打印
    // Setting.setShowLog(false);
    super.onCreate();
  }
Ejemplo n.º 5
0
  @Override
  public void onCreate() {

    // 应用程序入口处调用,避免手机内存过小,杀死后台进程后通过历史intent进入Activity造成SpeechUtility对象为null
    // 注意:此接口在非主进程调用会返回null对象,如需在非主进程使用语音功能,请增加参数:SpeechConstant.FORCE_LOGIN+"=true"
    // 参数间使用“,”分隔。
    super.onCreate();
    SpeechUtility.createUtility(this, "appid=" + getString(R.string.app_id));

    /*
     * 百度地图SDK初始化
     *
     * 初始化全局 context,指定 sdcard 路径,若采用默认路径,请使用initialize(Context context)
     * 重载函数 参数:
     *
     * sdcardPath - sd 卡路径,请确保该路径能正常使用 context - 必须是 application context,SDK
     * 各组件中需要用到。
     */
    try {
      SDKInitializer.initialize(Constant.Path.SD_CARD_INTERNAL, getApplicationContext());
    } catch (Exception e) {

    }
  }
 /** 初始化语音识别对象 */
 private void initiFlytek() {
   // 初始化识别对象
   SpeechUtility.createUtility(this, SpeechConstant.APPID + "=" + getString(R.string.app_id));
   mSpeechRecognizer = SpeechRecognizer.createRecognizer(this, miFlytekInitListener);
 }