I tried a lot but can´t find it out, so I hope you can help me.
I am trying to build my own voice recognition app, which doesn´t show up the dialog.
I already wrote some code and it works quite fine, but my problem is that the recognizer seems to stop without any errors or other messanges in the LogCat.
A strange fact is that the "onRmsChanged" from the "RecognitionListener" interface is still called all the time, but no …
我正在尝试创建一个在Android 4.2中运行连续语音识别的服务.使用此链接的答案(Android 4.1和4.2上的Android语音识别作为服务),我创建了一个从Activity运行的服务.我的问题是我在访问mTarget.mAudioManager
或mTarget.mSpeechRecognizerIntent
在handleMessage方法中获得null异常.目标(以及从中创建的mTarget对象)不是null,而是其中的所有对象.
我在这做错了什么?
相关活动代码(从activity调用的静态方法,activityContext是调用此方法的活动):
public static void init(Context context)
{
voiceCommandService = new VoiceCommandService();
activityContext = context;
}
public static void startContinuousListening()
{
Intent service = new Intent(activityContext, VoiceCommandService.class);
activityContext.startService(service);
Message msg = new Message();
msg.what = VoiceCommandService.MSG_RECOGNIZER_START_LISTENING;
try
{
voiceCommandService.mServerMessenger.send(msg);
}
catch (RemoteException e)
{
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
服务代码:
public class VoiceCommandService extends Service
{
protected AudioManager mAudioManager;
protected SpeechRecognizer mSpeechRecognizer;
protected Intent mSpeechRecognizerIntent;
protected final Messenger mServerMessenger = new …
Run Code Online (Sandbox Code Playgroud) 我想在用户按下按钮时启动Google即时语音搜索.但是,我找不到意图在文档中开始搜索.
有人知道如何开始Google Now语音搜索的活动吗?
我有一个应用程序的想法,但我还没有找到一个部分.在Android上的Google即时中,它为您提供了以下搜索选项:
我想知道他们是如何使#3工作的.我需要一个关键字,当说,启动语音搜索.
我想他们有一些类型的后台运行服务,不断听取语音动作.有谁知道这是如何实现的?
以下是Google即时应用的图片:
我正在尝试开发一个使用TTS
引擎和语音识别的酷应用程序.到目前为止它还可以,但我想要更多.我想创建一个服务(我认为服务是正确的方式),总是"倾听",当有人说"ok google"
或其他什么时,语音识别开始,就像谷歌现在.例如,如果你说"ok google"
谷歌现在开始.我不知道从哪里开始所以我在这里直接询问是否有可能.我试着看这个帖子[这里](在任何时候都在听关键字,比如4.4上的"Ok google"),最后一个回答谈到了服务,正如我想的那样.有人能用我的代码帮助我吗?
例如,这是通过点击按钮开始语音识别的代码:
/**
* Instruct the app to listen for user speech input
*/
private void listenToSpeech() {
//start the speech recognition intent passing required data
Intent listenIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
//indicate package
listenIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, getClass().getPackage().getName());
//message to display while listening
listenIntent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Say a word!");
//set speech model
listenIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
//specify number of results to retrieve
listenIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 10);
//start listening
startActivityForResult(listenIntent, VR_REQUEST);
}
Run Code Online (Sandbox Code Playgroud)
你认为listenIntent
只用语音而不按任何按钮就可以开始吗?这就是我的意思.
我正在构建一个使用语音命令执行某些功能的应用程序.我从这里得到了一些代码
private static final int SPEECH_REQUEST_CODE = 0;
// Create an intent that can start the Speech Recognizer activity
private void displaySpeechRecognizer() {
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
// Start the activity, the intent will be populated with the speech text
startActivityForResult(intent, SPEECH_REQUEST_CODE);
}
// This callback is invoked when the Speech Recognizer returns.
// This is where you process the intent and extract the speech text from the intent.
@Override
protected void onActivityResult(int requestCode, int …
Run Code Online (Sandbox Code Playgroud) 我有一个实现的活动RecognitionListener
.为了使它连续,每次onEndOfSpeech()
我再次启动监听器:
speech.startListening(recognizerIntent);
Run Code Online (Sandbox Code Playgroud)
但是,它需要一些时间(大约半秒钟),直到它开始,所以有这个半秒的差距,没有什么是听.因此,我想念那个时差中所说的话.
另一方面,当我使用谷歌的语音输入时,指示消息而不是键盘 - 这个时间差距不存在.意义 - 有一个解决方案.
它是什么?
谢谢
我正在尝试使用Android SpeechRecognizer类进行"免提"连续语音,但它似乎根本不起作用.当SpeechRecognizer启动时,它会发出一声嘟嘟声,但由于某种原因,它会将自己的蜂鸣声检测为语音,然后结束语音但没有检测到任何内容.
奇怪的是,如果我使用德语离线库,一切都按预期工作.因为哔哔声(三星S4和其他人)只是英语退出但是,我的三星平板电脑似乎在英语中工作正常.
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "en");
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en");
//intent.putExtra(RecognizerIntent.EXTRA_PREFER_OFFLINE, true);
this.speech.startListening(intent);
Run Code Online (Sandbox Code Playgroud) 我正在开发的基于语音识别的应用程序适用于从API 8(Android 2.2)开始的所有Android版本.
但是在Nexus S 4G(Android 4.1.1)上,RecognitionListener将暂停大约1分钟,然后通过其onError()回调发出ERROR_SERVER .
如果在1-2秒内(在onReadyForSpeech上发出哔哔声)说话,它将按预期正常运行.
在JellyBean中有什么变化可以解释这种行为?
更重要的是,是否有一种方法可以使其在旧版本的Android中表现得像?(即继续听,如果没有在默认的10秒内说出,则发出ERROR_SPEECH_TIMEOUT )
我将尝试在没有带有RecognitionListener的Google对话框的情况下使用语音识别,但在启动应用程序时只能发出蜂鸣声.我已将权限音频记录和互联网添加到清单文件中.我希望你告诉我并帮我找错...我在Log cat上没有错误...我想在用户说出问候时向一个循环显示一个消息进行循环Regognition OK并且列表视图显示结果.
public class MainActivity extends Activity implements RecognitionListener
{
private ListView wordsList;
private SpeechRecognizer mSpeechRecognizer;
private Intent mSpeechRecognizerIntent;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(this);
mSpeechRecognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
this.getPackageName());
wordsList = (ListView) findViewById(R.id.listView1);
mSpeechRecognizer.startListening(mSpeechRecognizerIntent);
}
public void onBeginningOfSpeech(){ }
public void onBufferReceived(byte[] buffer){ }
public void onEndOfSpeech(){ }
public void onError(int error){
//mSpeechRecognizer.startListening(mSpeechRecognizerIntent);
}
public void onEvent(int eventType, Bundle params){ }
public void onPartialResults(Bundle partialResults){ }
public void onReadyForSpeech(Bundle params){
Toast.makeText(getBaseContext(), …
Run Code Online (Sandbox Code Playgroud)