我有一个实现的活动RecognitionListener.为了使它连续,每次onEndOfSpeech()我再次启动监听器:
speech.startListening(recognizerIntent);
Run Code Online (Sandbox Code Playgroud)
但是,它需要一些时间(大约半秒钟),直到它开始,所以有这个半秒的差距,没有什么是听.因此,我想念那个时差中所说的话.
另一方面,当我使用谷歌的语音输入时,指示消息而不是键盘 - 这个时间差距不存在.意义 - 有一个解决方案.
它是什么?
谢谢
我正在实现一个响应RecognizerIntent的活动.除此之外,此活动必须处理两个指定待处理意图的附加附加内容及其附加内容:
EXTRA_RESULTS_PENDINGINTENTEXTRA_RESULTS_PENDINGINTENT_BUNDLE解释文档:
如果您使用EXTRA_RESULTS_PENDINGINTENT提供a PendingIntent,则结果将添加到其包中,PendingIntent并将结果发送到其目标.
如果您使用EXTRA_RESULTS_PENDINGINTENT提供转发意图,您还可以使用EXTRA_RESULTS_PENDINGINTENT_BUNDLE为最终意图提供额外的额外内容.搜索结果将添加到此捆绑包中,组合捆绑包将发送到目标.
我一直在寻找可以证明以下内容的示例代码.
PendingIntent从捆绑中提取a的最佳方法是什么?
我应该这样做:
(PendingIntent)
extras.getParcelable(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT)
Run Code Online (Sandbox Code Playgroud)
如何在一组现有的附加内容中添加额外内容PendingIntent?
如何启动修改PendingIntent?
我们可以为RecognizerIntent添加自定义语言吗?
我搜索了许多SO问题,如/sf/ask/145628101/
这解决了我在语音到文本转换过程中使用有限数量的语言的问题.
我的问题是,我需要使用Burmese(缅甸语言)语音并将其转换为文本.任何其他帮助可以得到赞赏.
更新:
谷歌的服务器目前支持英语,普通话和日语. 用于Android的语音输入API
android speech-recognition google-api speech-to-text recognizer-intent
当设备离线时,SpeechRecognizer在onResults中返回ERROR_NO_MATCH,同时它返回onPartialResults()回调中的部分结果.我最后一次玩SpeechRecognizer它离线工作得很好,我想知道是否有人找到了它的解决方案.
我使用Google API进行语音识别,但希望限制收听时间.例如两秒钟.两秒钟后,即使用户继续说话,识别器仍应停止收听.我尝试了一些类似的EXTRA
EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS
EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS
EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS
但它没有帮助我.我的完整代码在这里,如果有人可以帮助我,我将不胜感激
public void promptSpeechInput()
{
//This intent recognize the peech
Intent i = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
i.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
i.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());
i.putExtra(RecognizerIntent.EXTRA_PROMPT, "Say Something");
try {
startActivityForResult(i, 100);
}
catch (ActivityNotFoundException a)
{
Toast.makeText(MainActivity.this,"Your device does not support",Toast.LENGTH_LONG).show();
}
}
//For receiving speech input
public void onActivityResult(int request_code, int result_code, Intent i)
{
super.onActivityResult(request_code, result_code, i);
switch (request_code)
{
case 100: if(result_code == RESULT_OK && i != null)
{
ArrayList<String> result = i.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
resultTEXT.setText(result.get(0));
}
break;
} …Run Code Online (Sandbox Code Playgroud) 我有一个曾经工作过的代码,但由于某种原因它突然停止工作,我试图在希伯来语中使用语音识别,但似乎几天前它才开始用英语进行语音识别。
这是我的代码
sr = SpeechRecognizer.createSpeechRecognizer(getApplicationContext());
test_voice_recognitiona listener = new test_voice_recognitiona();
sr.setRecognitionListener(listener);
Intent fl = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
fl.putExtra("android.speech.extra.LANGUAGE", "he");
fl.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "he");
fl.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
this.getPackageName());
sr.startListening(fl);
Run Code Online (Sandbox Code Playgroud)
test_voice_recognitiona 是我的 RecognitionListener 类名。
代码运行良好,但出于某种原因,它一直在用英语收听。
我究竟做错了什么?
顺便说一下,我在谷歌对话框中尝试了更简单的代码,它正在工作。
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "he");
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Talk to Me " + user_name);
startActivityForResult(intent,REQUEST_CODE);
Run Code Online (Sandbox Code Playgroud)
也许是谷歌现在更新错误
android speech-recognition voice-recognition recognizer-intent
我创建了一个简单的 android 应用程序来控制连接到我的 Raspberry Pi 的继电器。我使用按钮以及基本的语音识别来触发这些按钮并打开/关闭相应的中继通道。
到目前为止,语音识别部分由 RecognizerIntent 处理,其中我需要按下我的应用程序上的一个按钮来打开一个谷歌语音提示,它会听取我的语音命令并激活/停用控制继电器开关的相应按钮。
我想通过连续语音识别来做同样的事情,它允许应用程序连续收听我的命令,而无需用户按下应用程序上的按钮,从而实现免提操作。
这是我现有的代码,这是一种非常简单的语音识别方法,可以让我打开和关闭连接到继电器的各种设备的按钮:
public void micclick(View view) {
if(view.getId()==R.id.mic)
{promptSpeechInput();}
}
private void promptSpeechInput() {
Intent i= new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
i.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
i.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());
i.putExtra(RecognizerIntent.EXTRA_PROMPT,"Speak!");
try{
startActivityForResult(i,100);
}
catch (ActivityNotFoundException a)
{
Toast.makeText(MainActivity.this,"Sorry your device doesn't support",Toast.LENGTH_SHORT).show();
}
}
public void onActivityResult(int requestCode, int resultCode, Intent i) {
super.onActivityResult(requestCode, resultCode, i);
String voicetxt;
switch (requestCode) {
case 100:
if (resultCode == RESULT_OK && i != null) {
ArrayList<String> result2 = i.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); …Run Code Online (Sandbox Code Playgroud) 如果由于用户不说话而在RecognizerIntent完成的情况下如何处理图像(ImageView)的可见性
if (RecognizerIntent.EXTRA_RESULTS == null){
image1.setVisibility(View.VISIBLE);///microphone icon
}
Run Code Online (Sandbox Code Playgroud)
要么
if (RecognizerIntent.ACTION_RECOGNIZE_SPEECH == null){
image1.setVisibility(View.INVISIBLE);///microphone
}
Run Code Online (Sandbox Code Playgroud)
日Thnx