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


Java SpeechRecognizer.createRecognizer方法代码示例

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


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

示例1: IflyRecognizer

import com.iflytek.cloud.SpeechRecognizer; //导入方法依赖的package包/类
private IflyRecognizer(Context context, SystemVoiceMediator mediator) {
    super.mContext = context;
    super.mediator = mediator;
    mPlayer = SpeechPlayer.createInstance(mContext, mediator);
    mRecorder = new PcmRecorder(context);
    mRecorder.setOnRecordListener(recordListener);
    Log.i(TAG, "before SpeechRecognizer.createRecognizer");
    recognizer = SpeechRecognizer.createRecognizer(context, rInitListener);
    Log.i(TAG, "after SpeechRecognizer.createRecognizer");
    mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    new Timer().schedule(new TimerTask() {
        @Override
        public void run() {
            if (!initParam)
                setDefaultRecognizerParam(false);
        }
    }, 3000);
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:19,代码来源:IflyRecognizer.java

示例2: onCreate

import com.iflytek.cloud.SpeechRecognizer; //导入方法依赖的package包/类
@SuppressLint("ShowToast")
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	requestWindowFeature(Window.FEATURE_NO_TITLE);
	setContentView(R.layout.iatdemo);

	initLayout();
	// 初始化识别无UI识别对象
	// 使用SpeechRecognizer对象,可根据回调消息自定义界面;
	mIat = SpeechRecognizer.createRecognizer(IatDemo.this, mInitListener);
	
	// 初始化听写Dialog,如果只使用有UI听写功能,无需创建SpeechRecognizer
	// 使用UI听写功能,请根据sdk文件目录下的notice.txt,放置布局文件和图片资源
	mIatDialog = new RecognizerDialog(IatDemo.this, mInitListener);

	mSharedPreferences = getSharedPreferences(IatSettings.PREFER_NAME,
			Activity.MODE_PRIVATE);
	mToast = Toast.makeText(this, "", Toast.LENGTH_SHORT);
	mResultText = ((EditText) findViewById(R.id.iat_text));
}
 
开发者ID:SoulEaterVTT,项目名称:KotlinStudy,代码行数:21,代码来源:IatDemo.java

示例3: doVoiceInput

import com.iflytek.cloud.SpeechRecognizer; //导入方法依赖的package包/类
@Permission(PermissionUtils.CODE_AUDIO)
private void doVoiceInput() {
    boolean has = PermissionUtils.hasPermission4Audio(mContext);
    if (has) {
        mIsVoiceOpen = true;
        if (mIat == null) {
            // 使用SpeechRecognizer对象,可根据回调消息自定义界面;
            mIat = SpeechRecognizer.createRecognizer(mContext, mInitListener);
        }
        //todo 如果是title怎么办
        mContentString = mEditTextView.getNoteContent();
        setVoiceParam();
        ret = mIat.startListening(mRecognizerListener);
        if (ret != ErrorCode.SUCCESS) {
            YLog.e(TAG, "听写失败,错误码:" + ret);
        }
    } else {
        PermissionUtils.requestPermissions(mActivity, mContext.getString(R.string.permission_audio),
                PermissionUtils.PERMISSION_AUDIO, PermissionUtils.CODE_AUDIO, null);
    }
}
 
开发者ID:fanwucoder,项目名称:mvpChat,代码行数:22,代码来源:EditTextPresenterImpl.java

示例4: initData

import com.iflytek.cloud.SpeechRecognizer; //导入方法依赖的package包/类
private void initData(){
    //注册广播
    IntentFilter intentFilter=new IntentFilter();
    intentFilter.addAction("com.zhengsonglan.cold.broadcastreceiver.MyReceiver");
    registerReceiver(myReceiver, intentFilter);

    //初始化语音听写
    recognizer=SpeechRecognizer.createRecognizer(this,initListener);
    //初始化UI
    dialog=new RecognizerDialog(this,initListener);
    //初始化聊天数据
    data=new ArrayList<ChatMsgEntity>();
    ChatMsgEntity chatMsgEntity=new ChatMsgEntity(you_name,"{\"code\":100000,\"text\":\"你好,啾啾为你服务\"}", ChatMsgEntity.Type.you,new Date());
    data.add(chatMsgEntity);
    chatAdapter=new ChatAdapter(this,data);
    lv_chat.setAdapter(chatAdapter);


}
 
开发者ID:yy1300326388,项目名称:Intelligent_robot,代码行数:20,代码来源:MainActivity.java

示例5: initComponent

import com.iflytek.cloud.SpeechRecognizer; //导入方法依赖的package包/类
private void initComponent(Context context) {
    if (mRecorder == null) {
        mRecorder = new PcmRecorder(context);
        mRecorder.setOnRecordListener(recordListener);
    }
    if (recognizer == null) {
        mPlayer = new SpeechPlayer();
        recognizer = SpeechRecognizer.createRecognizer(context, rInitListener);
        if (!"-1".equals(recognizer.getParameter(SpeechConstant.AUDIO_SOURCE))) {
            setRecognizeParams();
        }
    }
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:14,代码来源:VoiceInputComponent.java

示例6: reset

import com.iflytek.cloud.SpeechRecognizer; //导入方法依赖的package包/类
public void reset() {
    try {
        Log.e(TAG, "stopRecognize>>destroy>>reset");
        recognizer.destroy();
        recognizer.stopListening();
        recognizer = SpeechRecognizer.createRecognizer(mContext, rInitListener);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:11,代码来源:IflyRecognizer.java

示例7: startRecognize

import com.iflytek.cloud.SpeechRecognizer; //导入方法依赖的package包/类
public void startRecognize() {
    if (null == mIat) {
        mIat = SpeechRecognizer.createRecognizer(getContext(), mInitListener);
    }
    if (mIat.isListening()) {
        return;
    }
    setParam();
    int ret = mIat.startListening(this);
    if (ret != ErrorCode.SUCCESS) {
        RLog.d(TAG, "startRecognize ret error " + ret);
    }
}
 
开发者ID:hushengjun,项目名称:FastAndroid,代码行数:14,代码来源:Recognizer.java

示例8: initXFVoice

import com.iflytek.cloud.SpeechRecognizer; //导入方法依赖的package包/类
private void initXFVoice() {
    SpeechUtility.createUtility(getActivity(), SpeechConstant.APPID + BuildConfig.XF_APP_ID);
    mIat = SpeechRecognizer.createRecognizer(getActivity(), this);
    mIat.setParameter(SpeechConstant.DOMAIN, "iat");
    mIat.setParameter(SpeechConstant.LANGUAGE, "zh_cn");
    mIat.setParameter(SpeechConstant.ACCENT, "mandarin ");
    mIat.setParameter(SpeechConstant.ENGINE_TYPE, SpeechConstant.TYPE_CLOUD);
    mIat.setParameter(SpeechConstant.ASR_PTT, "0");
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:10,代码来源:VoiceMenuFragment.java

示例9: startRecognize

import com.iflytek.cloud.SpeechRecognizer; //导入方法依赖的package包/类
private void startRecognize() {
    if (null == mIat) {
        mIat = SpeechRecognizer.createRecognizer(getContext(), mInitListener);
    }
    if (mIat.isListening()) {
        return;
    }
    setParam();
    int ret = mIat.startListening(this);
    if (ret != ErrorCode.SUCCESS) {
        Log.d(TAG, "startRecognize ret error " + ret);
    }
}
 
开发者ID:LanguidSheep,项目名称:sealtalk-android-master,代码行数:14,代码来源:RecognizerView.java

示例10: onCreate

import com.iflytek.cloud.SpeechRecognizer; //导入方法依赖的package包/类
@SuppressLint("ShowToast")
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	requestWindowFeature(Window.FEATURE_NO_TITLE);
	setContentView(R.layout.isrdemo);
	initLayout();
	
	// 初始化识别对象
	mAsr = SpeechRecognizer.createRecognizer(AsrDemo.this, mInitListener);		
	mCloudGrammar = FucUtil.readFile(this,"grammar_sample.abnf","utf-8");
	
	mSharedPreferences = getSharedPreferences(getPackageName(),	MODE_PRIVATE);
	mToast = Toast.makeText(this,"",Toast.LENGTH_SHORT);	
	
}
 
开发者ID:SoulEaterVTT,项目名称:KotlinStudy,代码行数:16,代码来源:AsrDemo.java

示例11: initUI

import com.iflytek.cloud.SpeechRecognizer; //导入方法依赖的package包/类
private void initUI() {
    mDanmakuView = (DanmakuView) findViewById(R.id.danmakuView);//弹幕
    sendDanmu = (ImageView) findViewById(R.id.imageView5);//发送弹幕
    mIat = SpeechRecognizer.createRecognizer(MainActivity.this, mInitListener);
    // 初始化听写Dialog,如果只使用有UI听写功能,无需创建SpeechRecognizer
    // 使用UI听写功能,请根据sdk文件目录下的notice.txt,放置布局文件和图片资源
    mIatDialog = new RecognizerDialog(MainActivity.this, mInitListener);
    mToast = Toast.makeText(this, "", Toast.LENGTH_SHORT);
    sendDanmu.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mIatResults.clear();
            danmucontent = "";
            // 设置参数
            setParam();
            boolean isShowDialog = true;
            if (isShowDialog) {
                // 显示听写对话框
                mIatDialog.setListener(mRecognizerDialogListener);
                mIatDialog.show();
                showTip(getString(R.string.text_begin));
            } else {
                // 不显示听写对话框
                ret = mIat.startListening(mRecognizerListener);
                if (ret != ErrorCode.SUCCESS) {
                    showTip("听写失败,错误码:" + ret);
                } else {
                    showTip(getString(R.string.text_begin));
                }
            }
        }
    });
}
 
开发者ID:xbw12138,项目名称:shadowsocks_android,代码行数:34,代码来源:MainActivity.java

示例12: onCreateView

import com.iflytek.cloud.SpeechRecognizer; //导入方法依赖的package包/类
/**
 * Create this Fragments View.
 */
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.fragment_voice_view, container, false);
    SpeechUtility.createUtility(getActivity(), SpeechConstant.APPID+"=581c7563");

    listener = new Listener("android_remote_control", std_msgs.String._TYPE, new MessageListener<std_msgs.String>() {
        @Override
        public void onNewMessage(std_msgs.String message) {
            String str = message.getData();
            mTts.startSpeaking(str, mTtsListener);
        }
    });

    talker = new Talker("pc_remote_control", std_msgs.String._TYPE);

    virtualVoiceView = (ImageButton) view.findViewById(R.id.voice_button);

    mToast = Toast.makeText(getActivity(),null,Toast.LENGTH_SHORT);

    // 初始化对象
    mIat = SpeechRecognizer.createRecognizer(getActivity(), mInitListener);
    mTts = SpeechSynthesizer.createSynthesizer(getActivity(), mInitListener);

    virtualVoiceView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if(mTts.isSpeaking())
                mTts.stopSpeaking();
            iat();
        }
    });

    iat_setParam();
    tts_setParam();

    return view;
}
 
开发者ID:NEU-TEAM,项目名称:JARVIS,代码行数:43,代码来源:VoiceFragment.java

示例13: onCreate

import com.iflytek.cloud.SpeechRecognizer; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test);
    findViews();
    // 初始化识别无UI识别对象
    // 使用SpeechRecognizer对象,可根据回调消息自定义界面;
    mIat = SpeechRecognizer.createRecognizer(this, mInitListener);
    mIatDialog = new RecognizerDialog(TestActivity.this, mInitListener);
    mToast = Toast.makeText(this, "", Toast.LENGTH_SHORT);
}
 
开发者ID:lungerWang,项目名称:SmartChat,代码行数:12,代码来源:TestActivity.java

示例14: xfVoice

import com.iflytek.cloud.SpeechRecognizer; //导入方法依赖的package包/类
public void xfVoice(View view) {

        SpeechRecognizer mIat = SpeechRecognizer.createRecognizer(context, mInitListener);
        //2.设置听写参数,详见《科大讯飞MSC API手册(Android)》SpeechConstant类
        mIat.setParameter(SpeechConstant.DOMAIN, "iat");
        mIat.setParameter(SpeechConstant.LANGUAGE, "zh_cn");
        mIat.setParameter(SpeechConstant.ACCENT, "mandarin ");
        mIat.setParameter(SpeechConstant.ASR_PTT, "0");

        //3.开始听写
        mIat.startListening(mRecoListener);

    }
 
开发者ID:hanks-zyh,项目名称:Conquer,代码行数:14,代码来源:AddTaskActivity.java

示例15: initSpeech

import com.iflytek.cloud.SpeechRecognizer; //导入方法依赖的package包/类
/**
 * 初始化语言功能
 * 
 * @param context
 */
private void initSpeech(Context context) {

	mIat = SpeechRecognizer.createRecognizer(context, mInitListener);
	// 2.设置听写参数,详见《科大讯飞MSC API手册(Android)》SpeechConstant类
	setSpeechParam();
	// 3.开始听写 mIat.startListening(mRecoListener);//无界面的说话
	mIatDialog = new RecognizerDialog(context, mInitListener);

}
 
开发者ID:justingboy,项目名称:CouldBooks,代码行数:15,代码来源:SearchFragment.java


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