相关疑难解决方法(0)

有没有办法直接使用SpeechRecognizer API进行语音输入?

Android Dev网站提供了使用内置Google语音输入活动进行语音输入的示例.该活动显示带麦克风的预配置弹出窗口并使用其传递结果onActivityResult()

我的问题:有没有办法SpeechRecognizer直接使用该类进行语音输入而不显示固定活动?这将让我构建自己的语音输入活动.

android speech-recognition speech-to-text

22
推荐指数
2
解决办法
3万
查看次数

Android语音识别和录音同时进行

我的应用程序使用AsyncTask中的MediaRecorder类记录音频,并使用Google API转换语音到文本 - Recognizer Intent - 使用此问题的代码:如何在没有Android手机烦人的对话框的情况下使用语音识别

我也试过在Thread中录制音频,但这是更糟糕的解决方案.它会导致更多问题.我的问题是我的应用程序在模拟器上正常工作.但是由于缺乏语音识别服务,模拟器不支持语音重新识别.在我的设备上,当我开始录制音频和语音识别时,我的应用程序崩溃了 - "已意外停止".但是当我关闭wifi时,应用程序就像在模拟器上一样正常工作.

在AndroidManifest中录制音频需要:

<uses-permission android:name="android.permission.RECORD_AUDIO" />
Run Code Online (Sandbox Code Playgroud)

和语音识别要求:

<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />
Run Code Online (Sandbox Code Playgroud)

我想这是单音频输入的问题?我该如何解决这个问题?Google Speech Recognizer需要在主UI线程中工作,因此我无法在Async Task中执行此操作.所以我在Async Task中录音.我不知道为什么会导致问题.

我已将设备连接到Eclipse,并且我已使用USB调试.这是我在LogCat中的执行:

08-23 14:50:03.528: ERROR/ActivityThread(12403): Activity go.android.Activity has leaked ServiceConnection android.speech.SpeechRecognizer$Connection@48181340 that was originally bound here
08-23 14:50:03.528: ERROR/ActivityThread(12403): android.app.ServiceConnectionLeaked: Activity go.android.Activity has leaked ServiceConnection android.speech.SpeechRecognizer$Connection@48181340 that was originally bound here
08-23 14:50:03.528: ERROR/ActivityThread(12403):     at android.app.ActivityThread$PackageInfo$ServiceDispatcher.<init>(ActivityThread.java:1121)
08-23 14:50:03.528: ERROR/ActivityThread(12403):     at android.app.ActivityThread$PackageInfo.getServiceDispatcher(ActivityThread.java:1016)
08-23 14:50:03.528: ERROR/ActivityThread(12403):     at android.app.ContextImpl.bindService(ContextImpl.java:951)
08-23 14:50:03.528: ERROR/ActivityThread(12403):     at android.content.ContextWrapper.bindService(ContextWrapper.java:347)
08-23 14:50:03.528: ERROR/ActivityThread(12403): …
Run Code Online (Sandbox Code Playgroud)

android speech-recognition android-asynctask

22
推荐指数
2
解决办法
2万
查看次数

SpeechRecognizer导致ANR ......我需要Android语音API的帮助

编辑:我应该已经提到过这个,但我在服务中运行此代码.整个应用程序由小部件按钮打开/关闭,没有任何活动.


更新:我尝试将SDK源附加到项目中,这样我就可以更准确地了解发生故障的位置,但从外观来看,只包含公共API,这似乎使它们的用处更少.任何人都可以建议至少一种调试方法来解决这个问题吗?我有点卡住了.


我正在尝试使用Android的语音识别软件包来记录用户语音并将其翻译成文本.不幸的是,当我尝试启动监听时,我收到的ANR错误并未指出任何具体内容.

正如SpeechRecognizer API指示的那样,如果您尝试从主线程调用它,则抛出RuntimeException.这会让我想知道处理是否过于苛刻......但我知道其他应用程序使用Android API就可以实现这一目的,而且它通常非常活泼.

java.lang.RuntimeException: SpeechRecognizer should be used only from the application's main thread

这是我试图从我的服务中调用的代码的一个(修剪过的)示例.这是正确的方法吗?

感谢您抽出宝贵时间提供帮助.这是一个我无法克服的障碍.

Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
        RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
        "com.domain.app");

SpeechRecognizer recognizer = SpeechRecognizer
        .createSpeechRecognizer(this.getApplicationContext());
RecognitionListener listener = new RecognitionListener() {
    @Override
    public void onResults(Bundle results) {
        ArrayList<String> voiceResults = results
                .getStringArrayList(RecognizerIntent.EXTRA_RESULTS);
        if (voiceResults == null) {
            Log.e(getString(R.string.log_label), "No voice results");
        } else {
            Log.d(getString(R.string.log_label), "Printing matches: ");
            for (String match : voiceResults) {
                Log.d(getString(R.string.log_label), match); …
Run Code Online (Sandbox Code Playgroud)

android speech-to-text android-service

12
推荐指数
2
解决办法
2万
查看次数

MainActivity已泄露最初绑定的ServiceConnection android.speech.SpeechRecognizer$Connection@414ee400

在我的应用程序中,我认识到用户说"退出"或"关闭",应用程序应关闭.有了这段代码

SpeechRecognizer sr;
Map<String, Integer> dictionary;
private static final int EXIT = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    populateDictionary();
    SpeechRecognizer sr = SpeechRecognizer.createSpeechRecognizer(this);
    sr.setRecognitionListener(this);
    Intent voiceIntent = RecognizerIntent.getVoiceDetailsIntent(getApplicationContext());
    sr.startListening(voiceIntent);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

private void populateDictionary() {
    dictionary = new HashMap<String, Integer>();
    dictionary.put("exit", EXIT);
    dictionary.put("close", EXIT);
}

@Override
public void onResults(Bundle results) {
    ArrayList<String> …
Run Code Online (Sandbox Code Playgroud)

android speech-recognition serviceconnection

9
推荐指数
2
解决办法
2万
查看次数

是否可以在不显示对话框的情况下使用android的语音识别?

我想在android中使用语音文本api,但我不想被这些对话框放慢速度.没有它们可以使用这些功能吗?

android

7
推荐指数
3
解决办法
1万
查看次数

没有Google对话框的语音识别

我将尝试在没有带有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)

android speech voice-recognition

7
推荐指数
2
解决办法
1万
查看次数

SpeechRecognizer:没有选定的语音识别服务

这就是我启动我的RecogniseListener意图的方法:

Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);   
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);

intent.putExtra("android.speech.extra.DICTATION_MODE", true);               
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,this.getPackageName());
intent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true);
intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS,1);
sr.startListening(intent);
Run Code Online (Sandbox Code Playgroud)

但是,我得到一个奇怪的行为.它适用于某些手机(三星galaxy S5,在这种情况下),但我在联想K50-T5上收到以下错误:

E/SpeechRecognizer: no selected voice recognition service
Run Code Online (Sandbox Code Playgroud)

这是我的AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="lips.deafcommunication.deaflips">

<uses-permission android:name="android.permission.RECORD_AUDIO" />

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppThemeNoBar">
    <activity android:name=".MainActivity"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".ChatInProgressActivity" android:screenOrientation="portrait"
                android:windowSoftInputMode="adjustPan"
                android:configChanges="keyboardHidden|orientation|screenSize"
        ></activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)

java android speech-recognition speech-to-text

4
推荐指数
3
解决办法
2954
查看次数

Android RecognizerIntent语音识别

如果由于用户不说话而在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

android speech-recognition recognizer-intent

1
推荐指数
1
解决办法
6638
查看次数