我想开发一个模块,它将使用Android中的语音到文本支持。我发现了许多与RecogenerIntent等相关的文档和演示。但我发现所有这些演示都只是在10秒左右的时间里播放声音。但我想让我的演示运行5-10分钟以上。如果不是离线运行,我不会有任何问题,因为我的应用程序总是在线运行。
我也看过Android上的Pocketsphinx,但效果不太好。此外,它只支持Android Studio,而不支持Eclipse。
我见过许多应用程序提供连续5-10分钟将语音转换为文本的功能,例如:语音到文本记事本。
有人能推荐其他可以实现这一点的演示代码库吗?TIA。
在谷歌云语音API的帮助下,我成功地完成了这项工作。他们还在这里添加了一个演示。
Google Cloud Speech to Text使开发人员能够通过在易于使用的API中应用强大的神经网络模型将音频转换为文本。API可识别120种语言和变体,以支持您的全球用户群。您可以启用语音命令和控制、从呼叫中心转录音频等功能。它可以使用谷歌的机器学习技术处理实时流媒体或预录音频。
您可以转录用户对应用程序麦克风口述的文本,通过语音启用命令和控制,或转录音频文件,以及许多其他用例。使用Google用于为自己的产品提供动力的相同技术,识别请求中上传的音频,并与Google Cloud Storage上的音频存储集成。
一般来说,长音频语音识别是一个具有挑战性的问题,所以你几乎找不到任何可以解决这个问题的方法。相反,我建议您应用其中一种音频分割算法,并分别识别它们。此外,如果您的音频中有文本记录,并且只想获得时间帧(例如视频字幕问题),那么任务就会变得容易得多,您可以尝试进行长音频对齐。
请参阅此Android语音识别无对话自定义活动。
尝试重写方法onEndOfSpeech,然后使用SpeechRecognitor重新启动服务。startListening(识别意图)
我得到的结果与你引用语音到文本记事本的应用程序相同,下面是我的活动
import java.util.ArrayList;
import android.speech.RecognitionListener;
import android.speech.RecognizerIntent;
import android.speech.SpeechRecognizer;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.ToggleButton;
public class VoiceRecognitionActivity extends Activity implements
RecognitionListener {
private TextView returnedText;
private ToggleButton toggleButton;
private ProgressBar progressBar;
private SpeechRecognizer speech = null;
private Intent recognizerIntent;
private String LOG_TAG = "VoiceRecognition";
String speechString = "";
boolean spechStarted = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_voice_recognition);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
returnedText = (TextView) findViewById(R.id.textView1);
progressBar = (ProgressBar) findViewById(R.id.progressBar1);
toggleButton = (ToggleButton) findViewById(R.id.toggleButton1);
progressBar.setVisibility(View.INVISIBLE);
speech = SpeechRecognizer.createSpeechRecognizer(this);
speech.setRecognitionListener(this);
recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE,
"en");
recognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
this.getPackageName());
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS,
true);
toggleButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
if (isChecked) {
speech.setRecognitionListener(VoiceRecognitionActivity.this);
progressBar.setVisibility(View.VISIBLE);
progressBar.setIndeterminate(true);
speech.startListening(recognizerIntent);
} else {
progressBar.setIndeterminate(false);
progressBar.setVisibility(View.INVISIBLE);
speech.stopListening();
speech.destroy();
}
}
});
}
@Override
protected void onPause() {
super.onPause();
if (speech != null) {
speech.destroy();
Log.i(LOG_TAG, "destroy");
}
}
@Override
public void onBeginningOfSpeech() {
Log.i(LOG_TAG, "onBeginningOfSpeech");
spechStarted = true;
progressBar.setIndeterminate(false);
progressBar.setMax(10);
}
@Override
public void onBufferReceived(byte[] buffer) {
Log.i(LOG_TAG, "onBufferReceived: " + buffer);
}
@Override
public void onEndOfSpeech() {
spechStarted = false;
Log.i(LOG_TAG, "onEndOfSpeech");
speech.startListening(recognizerIntent);
}
@Override
public void onError(int errorCode) {
Log.d(LOG_TAG, "FAILED ");
if (!spechStarted)
speech.startListening(recognizerIntent);
}
@Override
public void onEvent(int arg0, Bundle arg1) {
Log.i(LOG_TAG, "onEvent");
}
@Override
public void onPartialResults(Bundle arg0) {
Log.i(LOG_TAG, "onPartialResults");
ArrayList<String> matches = arg0
.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
returnedText.setText(speechString + matches.get(0));
}
@Override
public void onReadyForSpeech(Bundle arg0) {
Log.i(LOG_TAG, "onReadyForSpeech");
}
@Override
public void onResults(Bundle results) {
Log.i(LOG_TAG, "onResults");
ArrayList<String> matches = results
.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
speechString = speechString + ". " + matches.get(0);
}
@Override
public void onRmsChanged(float rmsdB) {
Log.i(LOG_TAG, "onRmsChanged: " + rmsdB);
progressBar.setProgress((int) rmsdB);
}
}
我已经搜索了Google的所有可用文档,但我找不到Python音频流上的流式语音识别示例。 目前,我正在Django中使用Python语音识别从用户那里获取音频,然后收听音频。然后,我可以保存文件并运行google语音识别,或者直接从创建的音频实例中运行。 有人能指导我如何对音频流执行流式语音识别吗?
问题内容: 我有一把吉他,我需要我的电脑能够分辨出正在演奏的音符,并识别出音调。可以在python中做到吗,也可以在pygame中做到吗?能够在pygame中做到这一点将非常有帮助。 问题答案: 要识别音频信号的频率,可以使用FFT(快速傅立叶变换)算法。据我所知,PyGame无法记录音频,也不支持FFT转换。 首先,您需要从声卡捕获原始采样数据。这种数据称为PCM(脉冲编码调制)。在Python
我正在寻找一个Android语音识别库。我只需要它来理解“是/否”的答案(用不同的语言,如英语、德语、法语)。 有什么建议吗?
[可能重复]但我没有找到下面问题的答案。 在过去的两天里,我一直在做一些语音识别方面的研究,但我的问题没有得到答案: 是否可以将语音识别作为一项服务运行?我想实现这样的功能:虽然我的手机处于睡眠模式,但我需要拨打一个号码
我目前正在从事一个Android AppEngine项目,使用语音作为主要输入方法。在android上,您可以使用语音包将语音命令转换为纯文本。语音识别不是在设备本身上完成的,而是发送到一个谷歌服务器,该服务器返回文本。 供您参考:http://developer.android.com/resources/articles/speech-input.html 我的目标是使用相同的google服务
问题内容: 我正在研究语音识别,需要一些示例程序。 谁能指导我? 问题答案: 让我剪切粘贴一下,向您展示所需的代码。 编辑:您还可以从该项目下载一个方便的抽象类。 您将需要此意图(在您认为合适的情况下进行参数化): 然后,您需要将自己的意图发送到语音识别活动,例如, 然后,您需要让自己的活动处理语音结果: