当前位置: 首页>>代码示例>>Java>>正文


Java SpeechConstant类代码示例

本文整理汇总了Java中com.iflytek.cloud.SpeechConstant的典型用法代码示例。如果您正苦于以下问题:Java SpeechConstant类的具体用法?Java SpeechConstant怎么用?Java SpeechConstant使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SpeechConstant类属于com.iflytek.cloud包,在下文中一共展示了SpeechConstant类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setParams

import com.iflytek.cloud.SpeechConstant; //导入依赖的package包/类
public void setParams() {
    // 清空参数
    mTts.setParameter(SpeechConstant.PARAMS, null);
    // 根据合成引擎设置相应参数
    mTts.setParameter(SpeechConstant.ENGINE_TYPE, SpeechConstant.TYPE_CLOUD);
    // 设置在线合成发音人
    mTts.setParameter(SpeechConstant.VOICE_NAME, "xiaoqi");
    //设置合成语速
    mTts.setParameter(SpeechConstant.SPEED, "50");
    //设置合成音调
    mTts.setParameter(SpeechConstant.PITCH, "50");
    //设置合成音量
    mTts.setParameter(SpeechConstant.VOLUME, "50");

    //设置播放器音频流类型
    mTts.setParameter(SpeechConstant.STREAM_TYPE, "3");
    // 设置播放合成音频打断音乐播放,默认为true
    mTts.setParameter(SpeechConstant.KEY_REQUEST_FOCUS, "true");

    // 设置音频保存路径,保存音频格式支持pcm、wav,设置路径为sd卡请注意WRITE_EXTERNAL_STORAGE权限
    // 注:AUDIO_FORMAT参数语记需要更新版本才能生效
    mTts.setParameter(SpeechConstant.AUDIO_FORMAT, "wav");
    mTts.setParameter(SpeechConstant.TTS_AUDIO_PATH, Environment.getExternalStorageDirectory() + "/msc/tts.wav");
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:SpeechUtil.java

示例2: setRecognizeParams

import com.iflytek.cloud.SpeechConstant; //导入依赖的package包/类
private void setRecognizeParams() {
    if (recognizer != null) {
        recognizer.setParameter(SpeechConstant.DOMAIN, "iat");//识别:iat,search,video,poi,music
        recognizer.setParameter(SpeechConstant.ACCENT, "mandarin");//可选:mandarin,cantonese
        recognizer.setParameter(SpeechConstant.LANGUAGE, "zh_cn");//支持:zh_cn,zh_tw,en_us
        recognizer.setParameter(SpeechConstant.VAD_BOS, Integer.toString(4000));//默认值:短信转写5000,其他4000
        recognizer.setParameter(SpeechConstant.VAD_EOS, Integer.toString(1000));//默认值:短信转写1800,其他700
        recognizer.setParameter(SpeechConstant.AUDIO_SOURCE, "-1");
        recognizer.setParameter(SpeechConstant.NET_TIMEOUT, "6000");
        recognizer.setParameter(SpeechConstant.KEY_SPEECH_TIMEOUT, "6000");
        recognizer.setParameter(SpeechConstant.KEY_REQUEST_FOCUS, "0");
        recognizer.setParameter(SpeechConstant.PARAMS, "asr_ptt=1,asr_nbest=1");
        recognizer.setParameter(SpeechConstant.ENGINE_TYPE, SpeechConstant.TYPE_CLOUD);
        Log.e(TAG, "first search contacts!!!!!!!!!!!!!!!!!!!!!!!!");
        //        recognizer.updateLexicon("userword", AppConfig.getContactsText(), lexiconListener);
    }
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:18,代码来源:VoiceInputComponent.java

示例3: forceSwitchEngine

import com.iflytek.cloud.SpeechConstant; //导入依赖的package包/类
@Override
  protected void forceSwitchEngine(boolean online) {
      Log.i(TAG, "forceSwitchEngine>>" + Boolean.toString(online));
/*if(synthesizer.isSpeaking()){
	stopSpeakingAbsolte();
}*/
      //if(online){
      /*if (!isLocalEngine)
          return;
      isLocalEngine = false;*/
      synthesizer.setParameter(SpeechConstant.ENGINE_TYPE, SpeechConstant.TYPE_CLOUD);
      synthesizer.setParameter(SpeechConstant.SPEED, Integer.toString(mVoiceConfig.getVolSpeed()));
      synthesizer.setParameter(SpeechConstant.VOLUME, Integer.toString(mVoiceConfig.getVolume()));
      synthesizer.setParameter(SpeechConstant.VOICE_NAME, mVoiceConfig.getVolName());
/*}
else{
	if(isLocalEngine)return;
	isLocalEngine=true;
	synthesizer.setParameter(SpeechConstant.SPEED, OFFLINE_ENGINE_SPPED);
	synthesizer.setParameter(SpeechConstant.ENGINE_TYPE, SpeechConstant.TYPE_LOCAL);
	synthesizer.setParameter(SpeechConstant.VOICE_NAME, "xiaoyan");
}*/
  }
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:24,代码来源:IflySynthesizer.java

示例4: setRecognizeMode

import com.iflytek.cloud.SpeechConstant; //导入依赖的package包/类
/**
 * 通过改变音频源类型,设置识别模式。注意:必须在开启识别前设置
 *
 * @param mode false:讯飞默认模式,将音频交给讯飞录制和识别
 *             true:自定义长时间录音模式,本地录制并以音频流的方式持续发送给讯飞识别
 **/
public void setRecognizeMode(boolean mode) {
    Log.i("LingJu", "IflyRecognizer setRecognizeMode()>>>" + mode);
    long_time_record = mode;
    recognizer.setParameter(SpeechConstant.AUDIO_SOURCE, mode ? "-1" : null);
    // recognizer.setParameter(SpeechConstant.VAD_EOS, Integer.toString(mode ? 600 : 1000));
    if (wl == null) {
        PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
        wl = pm.newWakeLock(PowerManager.ON_AFTER_RELEASE | PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "BRIGHT");
    }
    //是否需计算锁的数量
    // wl.setReferenceCounted(false);
    if (mode && long_record_mode < DEFAULT_TAPE) {
        //点亮屏幕
        wl.acquire();
    } else if (!mode) {
        //释放
        if (wl.isHeld())
            wl.release();
        long_record_mode = -1;
    }
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:28,代码来源:IflyRecognizer.java

示例5: onSuccess

import com.iflytek.cloud.SpeechConstant; //导入依赖的package包/类
/**
 * 识别成功,结果处理
 **/
private void onSuccess(String content) {
    if (long_time_record && long_record_mode < DEFAULT_TAPE) {      //无限时识别,非保存录音模式
        IflyRecognizer.this.onLondRecordResult(content);
    } else if (long_record_mode == LONG_TAPE) {     //无限时识别,保存录音模式
        tapeText += content;
    } else if (long_record_mode == DEFAULT_TAPE) {     //正常识别,保存录音模式
        //停止录音
        mRecorder.stop(mediator.isWakeUpMode());
        mediator.onTapeResult(content);
    } else if (!long_time_record) {      //讯飞默认识别模式
        if (recognizer.getParameter(SpeechConstant.LANGUAGE).equals("en_us")) {
            recognizer.setParameter(SpeechConstant.LANGUAGE, "zh_cn");
        }
        mRecorder.stop(mediator.isWakeUpMode());
        mPlayer.playAssetsFile(mContext.getResources().getString(R.string.audio_result), false, null);
        IflyRecognizer.this.onResult(content);
    }
    temp.setLength(0);
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:23,代码来源:IflyRecognizer.java

示例6: setDefaultRecognizerParam

import com.iflytek.cloud.SpeechConstant; //导入依赖的package包/类
private void setDefaultRecognizerParam() {
    recognizer.setParameter(SpeechConstant.DOMAIN, "iat");//识别:iat,search,video,poi,music
    recognizer.setParameter(SpeechConstant.ACCENT, "mandarin");//可选:mandarin,cantonese
    recognizer.setParameter(SpeechConstant.LANGUAGE, "zh_cn");//支持:zh_cn,zh_tw,en_us
    recognizer.setParameter(SpeechConstant.VAD_BOS, Integer.toString(4000));//默认值:短信转写5000,其他4000
    recognizer.setParameter(SpeechConstant.VAD_EOS, Integer.toString(1000));//默认值:短信转写1800,其他700
    recognizer.setParameter(SpeechConstant.AUDIO_SOURCE, null);
    recognizer.setParameter(SpeechConstant.NET_TIMEOUT, "6000");
    recognizer.setParameter(SpeechConstant.KEY_SPEECH_TIMEOUT, "6000");
    recognizer.setParameter(SpeechConstant.KEY_REQUEST_FOCUS, "0");
    /**
     * SpeechConstant.PARAMS
     * 转写支持:
     asr_ptt:是否加入标点符号,如asr_ptt=0
     asr_nbest:多候选结果,如asr_nbest=3
     asr_audio_path:保存音频路径,如asr_audio_path=/sdcard/asr.pcm
     合成支持:
     tts_buffer_time:播放缓冲时间,即缓冲多少秒音频后开始播放,如tts_buffer_time=5000
     tts_audio_path:保存音频路径,如tts_audio_path=/sdcard/tts.pcm
     */
    recognizer.setParameter(SpeechConstant.PARAMS, "asr_ptt=1,asr_nbest=1");
    recognizer.setParameter(SpeechConstant.ENGINE_TYPE, SpeechConstant.TYPE_CLOUD);
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:24,代码来源:LingJuCloudAwakener.java

示例7: finish

import com.iflytek.cloud.SpeechConstant; //导入依赖的package包/类
@Override
public void finish() {
    switch (status) {
        case Idle:
            return;
        case Started:
        case Recording:
            status = RecognizeStatus.Idle;
            break;
        default:
            return;
    }
    // Log.i("LingJu", "LingJuCloudAwakener finish()");
    recognizer.setParameter(SpeechConstant.AUDIO_SOURCE, null);
    recognizer.stopListening();
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:17,代码来源:LingJuCloudAwakener.java

示例8: butlerSpeak

import com.iflytek.cloud.SpeechConstant; //导入依赖的package包/类
private void butlerSpeak(String text)
{
    //创建SpeechSynthesizer对象,本地合成时第二个参数传InitListener
    SpeechSynthesizer mTts=SpeechSynthesizer.createSynthesizer(BaseApplication.getContext(),null);
    //语音参数设置
    mTts.setParameter( SpeechConstant.ENGINE_TYPE, SpeechConstant.TYPE_CLOUD);//设置云端
    mTts.setParameter( SpeechConstant.SPEED,"50");//设置语速
    mTts.setParameter( SpeechConstant.VOICE_NAME, "xiaoyan" );//设置发音人
    mTts.setParameter(SpeechConstant.VOLUME,"80");//设置音量
    //语音播放
    mTts.startSpeaking(text,synthesizerListener);
}
 
开发者ID:WindFromFarEast,项目名称:SmartButler,代码行数:13,代码来源:ButlerFragment.java

示例9: init

import com.iflytek.cloud.SpeechConstant; //导入依赖的package包/类
private void init() {
    SpeechUtility.createUtility(context, SpeechConstant.APPID + "=5a376b82");
    SpeechSynthesizer synthesizer = SpeechSynthesizer.createSynthesizer(this.context, null);
    //设置发音人
    synthesizer.setParameter(SpeechConstant.VOICE_NAME, "xiaoyan");
    //设置语速,值范围:[0, 100],默认值:50
    synthesizer.setParameter(SpeechConstant.SPEED, "55");
    //设置音量
    synthesizer.setParameter(SpeechConstant.VOLUME, "tts_volume");
    //设置语调
    synthesizer.setParameter(SpeechConstant.PITCH, "tts_pitch");
    //设置与其他音频软件冲突的时候是否暂停其他音频
    synthesizer.setParameter(SpeechConstant.KEY_REQUEST_FOCUS, "false");
    //女生仅vixy支持多音字播报
    synthesizer.setParameter(SpeechConstant.VOICE_NAME, "vixy");
    this.synthesizer = synthesizer;
    this.listener = new SpeechSynthesizerListener();
}
 
开发者ID:luocongqiu,项目名称:cordova-plugin-navigation,代码行数:19,代码来源:IFlySpeech.java

示例10: findView

import com.iflytek.cloud.SpeechConstant; //导入依赖的package包/类
private void findView(View view) {

        //1.创建SpeechSynthesizer对象, 第二个参数:本地合成时传InitListener
        mTts = SpeechSynthesizer.createSynthesizer(getActivity(), null);
        //2.合成参数设置,详见《科大讯飞MSC API手册(Android)》SpeechSynthesizer 类
        mTts.setParameter(SpeechConstant.VOICE_NAME, "xiaoyan");//设置发音人
        mTts.setParameter(SpeechConstant.SPEED, "50");//设置语速
        mTts.setParameter(SpeechConstant.VOLUME, "80");//设置音量,范围0~100
        mTts.setParameter(SpeechConstant.ENGINE_TYPE, SpeechConstant.TYPE_CLOUD); //设置云端
        //设置合成音频保存位置(可自定义保存位置),保存在“./sdcard/iflytek.pcm”
        //保存在SD卡需要在AndroidManifest.xml添加写SD卡权限
        //如果不需要保存合成音频,注释该行代码
        //mTts.setParameter(SpeechConstant.TTS_AUDIO_PATH, "./sdcard/iflytek.pcm");

        mChatListView = (ListView) view.findViewById(R.id.mChatListView);
        et_text = (EditText) view.findViewById(R.id.et_text);
        btn_send = (Button) view.findViewById(R.id.btn_send);
        btn_send.setOnClickListener(this);

        //设置适配器
        adapter = new ChatListAdapter(getActivity(), mList);
        mChatListView.setAdapter(adapter);

        addLeftItem(getString(R.string.text_hello_tts));
    }
 
开发者ID:lijizhi,项目名称:studydemo,代码行数:26,代码来源:FuFragment.java

示例11: onClick

import com.iflytek.cloud.SpeechConstant; //导入依赖的package包/类
@Override
public void onClick(Fragment currentFragment, final RongExtension extension) {
    String[] permissions = {Manifest.permission.RECORD_AUDIO};
    if (!PermissionCheckUtil.requestPermissions(currentFragment, permissions)) {
        return;
    }
    if (SpeechUtility.getUtility() == null) {
        SpeechUtility.createUtility(extension.getContext().getApplicationContext(), SpeechConstant.APPID + "=581f2927"); //初始化
    }
    recognizerView = new RecognizerView(extension.getContext());
    recognizerView.setResultCallBack(new IRecognizedResult() {
        @Override
        public void onResult(String data) {
            Editable editable = extension.getInputEditText().getText();
            String str = editable.toString() + data;
            extension.getInputEditText().setText(str);
            extension.getInputEditText().setSelection(str.length());
        }

        @Override
        public void onClearClick() {
            extension.getInputEditText().setText("");
        }
    });
    extension.addPluginPager(recognizerView);
}
 
开发者ID:LanguidSheep,项目名称:sealtalk-android-master,代码行数:27,代码来源:RecognizePlugin.java

示例12: init

import com.iflytek.cloud.SpeechConstant; //导入依赖的package包/类
private void init(Bundle savedInstanceState) {
    mStartPoints.add(mNaviStart);
    mEndPoints.add(mNaviEnd);
    mAmapAMapNaviView.onCreate(savedInstanceState);
    mAmapAMapNaviView.setAMapNaviViewListener(this);
    AMapNavi.getInstance(this).calculateDriveRoute(mStartPoints, mEndPoints, null,
            PathPlanningStrategy.DRIVING_AVOID_CONGESTION);

    SpeechUtility.createUtility(this, SpeechConstant.APPID + "="
            + AMapNavigation.cordovaWebView.getPreferences().getString("iflytekappid", ""));
    mSpeechSynthesizer = SpeechSynthesizer.createSynthesizer(this, null);
    mSpeechSynthesizer.setParameter(SpeechConstant.VOICE_NAME, "xiaoyan");
    mSpeechSynthesizer.setParameter(SpeechConstant.SPEED, "50");
    mSpeechSynthesizer.setParameter(SpeechConstant.VOLUME, "80");

    mSpeechSynthesizer.setParameter(SpeechConstant.ENGINE_TYPE, SpeechConstant.TYPE_CLOUD);
}
 
开发者ID:starwander,项目名称:cordova-plugin-amap-navi,代码行数:18,代码来源:AMapActivity.java

示例13: onDestroy

import com.iflytek.cloud.SpeechConstant; //导入依赖的package包/类
/**
 * The final call you receive before your activity is destroyed.
 */
@Override
public void onDestroy() {
    super.onDestroy();
    wakeup.send(com.baidu.speech.asr.SpeechConstant.WAKEUP_STOP, "{}", null, 0, 0);
    if (null != this.mAIUIAgent) {
        AIUIMessage stopMsg = new AIUIMessage(AIUIConstant.CMD_STOP, 0, 0, null, null);
        mAIUIAgent.sendMessage(stopMsg);

        this.mAIUIAgent.destroy();
        this.mAIUIAgent = null;
    }
    if( null != mTts ){
        mTts.stopSpeaking();
        // 退出时释放连接
        mTts.destroy();
    }
}
 
开发者ID:rxnh8255,项目名称:aiui,代码行数:21,代码来源:AIUIPlugin.java

示例14: promptForRecord

import com.iflytek.cloud.SpeechConstant; //导入依赖的package包/类
private void promptForRecord() {
    if (PermissionHelper.hasPermission(this, permission)) {
        Log.i(TAG,"开启唤醒");

        wakeup = EventManagerFactory.create(getApplicationContext(), "wp");
        wakeup.registerListener(wakeupListener);

        Map<String, Object> params = new LinkedHashMap<String, Object>();
        params.put(com.baidu.speech.asr.SpeechConstant.APP_ID, "10099877");
        params.put(com.baidu.speech.asr.SpeechConstant.ACCEPT_AUDIO_VOLUME, false);
        params.put(com.baidu.speech.asr.SpeechConstant.WP_WORDS_FILE, "assets:///WakeUp.bin");
        String json = null; // 这里可以替换成你需要测试的json
        json = new JSONObject(params).toString();
        wakeup.send(com.baidu.speech.asr.SpeechConstant.WAKEUP_START, json, null, 0, 0);

    } else {
        getMicPermission(0);
    }

}
 
开发者ID:rxnh8255,项目名称:aiui,代码行数:21,代码来源:AIUIPlugin.java

示例15: onCreate

import com.iflytek.cloud.SpeechConstant; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();

    mContext = getApplicationContext();

    //初始化 Bugly
    CrashReport.initCrashReport(getApplicationContext(), StaticClass.BUGLY_APP_ID, true);

    //初始化 Bmob
    Bmob.initialize(this, StaticClass.BMOB_APP_ID);

    //初始化语音识别
    SpeechUtility.createUtility(getApplicationContext(), SpeechConstant.APPID + "=" +
            StaticClass.VOICE_KEY);

    //初始化百度地图
    SDKInitializer.initialize(getApplicationContext());

    //初始化litepal
    LitePalApplication.initialize(getApplicationContext());
}
 
开发者ID:Hultron,项目名称:LifeHelper,代码行数:23,代码来源:BaseApplication.java


注:本文中的com.iflytek.cloud.SpeechConstant类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。