You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WearOS设备(三星Galaxy4/5、Pixel)集成Google Speech Listener报错求助

WearOS语音识别服务绑定失败问题(三星Galaxy 4/5、Pixel手表)

我们开发了一款适配所有WearOS智能手表的应用,该应用在Ticwatch上运行完全正常。但在搭载相同版本WearOS的三星Galaxy 4、5以及Pixel智能手表上,集成Google Speech Listener时遇到问题,出现报错:E/SpeechRecognizer: no selected voice recognition service(设备已安装所有最新版本)。

为排查问题,我们制作了一个简化应用。将该应用安装在上述最新设备上后,尝试两种语音识别方式均出现相同问题:

  • 第一种方式报「未选择语音识别服务」
  • 第二种方式报「绑定识别服务失败」

调试截图:
Samsung_speechRecognizer_not_selected
Samsung bind failed
Pixel bind failed

若无法解决此问题,我们的创业项目将无法启动POC。(注:所有库已更新至最新Android版本)

以下是简化应用的MainActivity.kt代码:

package com.sustav.mytest.view.speech_listener_demo

import android.Manifest
import android.app.Activity
import android.content.ComponentName
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Build
import android.os.Bundle
import android.speech.RecognitionListener
import android.speech.RecognizerIntent
import android.speech.SpeechRecognizer
import android.util.Log
import android.widget.Toast
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import com.sustav.mytest.view.speech_listener_demo.databinding.ActivityMainBinding
import java.util.*

class MainActivity : Activity() {
    private lateinit var binding: ActivityMainBinding
    private val RecordAudioRequestCode = 1
    private var speechRecognizer: SpeechRecognizer? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        binding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(binding.root)

        if (ContextCompat.checkSelfPermission(
                this,
                Manifest.permission.RECORD_AUDIO
            ) != PackageManager.PERMISSION_GRANTED
        ) {
            checkPermission()
        }

        Log.d("SPEECH", "Is available: ${SpeechRecognizer.isRecognitionAvailable(this)}")

        //First approach E/SpeechRecognizer: no selected voice recognition service
        speechRecognizer = SpeechRecognizer.createSpeechRecognizer(this)
        //Second approach E/SpeechRecognizer: bind to recognition service failed
        speechRecognizer = SpeechRecognizer.createSpeechRecognizer(this,
            ComponentName.unflattenFromString("com.google.android.googlequicksearchbox/com.google.android.voicesearch.serviceapi.GoogleRecognitionService"));

        val voice = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)
          voice.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM)
        voice.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault())

        setUpSpeechListener()

        binding.mybutton.setOnClickListener {
            speechRecognizer!!.startListening(voice)
        }
    }

    private fun setUpSpeechListener() {
        speechRecognizer!!.setRecognitionListener(object : RecognitionListener {
            override fun onReadyForSpeech(bundle: Bundle) {}
            override fun onBeginningOfSpeech() {
                binding.text.text = "Listening..."
                binding.text.hint = "Listening..."
            }

            override fun onRmsChanged(v: Float) {}
            override fun onBufferReceived(bytes: ByteArray) {}
            override fun onEndOfSpeech() {}
            override fun onError(i: Int) {}
            override fun onResults(bundle: Bundle) {
                binding.mybutton.setImageResource(R.drawable.ic_mic_black_off)
                val data = bundle.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION)
                binding.text.text = data!![0]
                binding.text.hint = "Listening..."
            }

            override fun onPartialResults(bundle: Bundle) {}
            override fun onEvent(i: Int, bundle: Bundle) {}
        })
    }

    private fun checkPermission() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            ActivityCompat.requestPermissions(
                this,
                arrayOf(Manifest.permission.RECORD_AUDIO),
                RecordAudioRequestCode
            )
        }
    }

    override fun onRequestPermissionsResult(
        requestCode: Int,
        permissions: Array<String?>,
        grantResults: IntArray
    ) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults)
        if (requestCode == RecordAudioRequestCode && grantResults.size > 0) {
            if (grantResults[0] == PackageManager.PERMISSION_GRANTED) Toast.makeText(
                this,
                "Permission Granted",
                Toast.LENGTH_SHORT
            ).show()
        }
    }

    override fun onDestroy() {
        speechRecognizer!!.destroy()
        super.onDestroy()
    }
}

内容的提问来源于stack exchange,提问作者Yael Amitay

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 08:55:37