如何开发类似Talking Tom的语音识别应用程序

14

如何开发像Talking Tom这样的语音识别应用程序?
1. 我的要求是如何在没有任何事件(如按钮、触摸事件)的情况下识别声音。
2. 所有的录音示例都是通过按钮进行的,但我的要求是当用户说话时自动记录语音,并在用户停止说话时自动将语音转换成其他声音(如Tom或鹦鹉)。
3. 我已经通过按钮完成了这个功能。

我的.java文件

File storageDir = new File(Environment.getExternalStorageDirectory(), "SRAVANTHI");
storageDir.mkdir();
Log.d(APP_TAG, "Storage directory set to " + storageDir);
outfile = File.createTempFile("hascode", ".3gp", storageDir);

// init recorder
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(outfile.getAbsolutePath());

// init player
player.setDataSource(outfile.getAbsolutePath());

try {
    recorder.prepare();
    recorder.start();
    recording = true;
} catch (IllegalStateException e) {
    Log.w(APP_TAG, "Invalid recorder state .. reset/release should have been called");
} catch (IOException e) {
    Log.w(APP_TAG, "Could not write to sd card");
}

recorder.stop();

播放按钮

try {
    playing = true;
    player.prepare();
    player.start();
} catch (IllegalStateException e) {
    Log.w(APP_TAG, "illegal state .. player should be reset");
} catch (IOException e) {
    Log.w(APP_TAG, "Could not write to sd card");
}
1个回答

1

先检查声音音量,只有当其超过一定值后才开始录制,如何看待这种方式?

也许这个链接会有所帮助: android: 检测声音水平


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接