.android 语音(声音)转文字
2013-01-26 20:43
337 查看
public class SoundTestActivity extends Activity {
/** Called when the activity is first created. */
private static final int RECOGNIZER_EXAMPLE=101;
private TextView result;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
result=(TextView)findViewById(R.id.text_result);
Button start=(Button)findViewById(R.id.start_button);
start.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent=new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Say a word or phrase\nand it will show as text");
startActivityForResult(intent,RECOGNIZER_EXAMPLE);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
if(requestCode==RECOGNIZER_EXAMPLE&&resultCode==RESULT_OK){
ArrayList<String> resultList=data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
StringBuffer resultListString=new StringBuffer();;
for(String s:resultList){
resultListString.append(s+",");
}
result.setText(resultListString.toString());
}
super.onActivityResult(requestCode, resultCode, data);
}
}
/** Called when the activity is first created. */
private static final int RECOGNIZER_EXAMPLE=101;
private TextView result;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
result=(TextView)findViewById(R.id.text_result);
Button start=(Button)findViewById(R.id.start_button);
start.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent=new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Say a word or phrase\nand it will show as text");
startActivityForResult(intent,RECOGNIZER_EXAMPLE);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
if(requestCode==RECOGNIZER_EXAMPLE&&resultCode==RESULT_OK){
ArrayList<String> resultList=data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
StringBuffer resultListString=new StringBuffer();;
for(String s:resultList){
resultListString.append(s+",");
}
result.setText(resultListString.toString());
}
super.onActivityResult(requestCode, resultCode, data);
}
}
相关文章推荐
- Android 通知(Notification)设置声音,震动,LED灯,长文字,图片,等级重要程度
- Android TTS 中文 文字转语音 使用TextToSpeech Svox
- 语音转为文字 android
- 关于集成百度导航 TTS语音没有声音 android安卓
- android自学之TextToSpeech例子实现将文字转化为语音功能
- Android中集成讯飞语音,语音转文字以及文字转语音操作
- Android文字转语音引擎(TTS)简单比较及下载
- android 百度地图导航TTS 语音播报没有声音
- Android 通过流播放声音(语音全双工通信)
- Android 文字转语音功能
- android 语音转换文字(科大讯飞SDK简易封装)
- android 轻松实现在线即时聊天【图片、语音、表情、文字】等!含源码!
- android自学之TextToSpeech实现文字向语音的转换
- android MediaCodec 音频解码+讯飞语音 实现本地语音转文字功能
- Android TTS 中文 文字转语音 使用TextToSpeech Svox
- android 轻松实现在线即时聊天【图片、语音、表情、文字】等!含源码!
- Android中使用TTS(TextToSpeech)将文字转为语音
- Android TTS 中文 文字转语音 使用TextToSpeech Svox .
- Android TTS文字转语音开发
- android采用语音文件形式让TextView和EditText发出声音