简体   繁体   English

是否可以阻止Google Assistant在Android TV应用中接管RCU麦克风按钮信号?

[英]Is it possible to prevent Google Assistant from taking over RCU mic button signal in an Android TV app?

The Android TV (ATV) app I'm working on has voice control capabilities. 我正在使用的Android TV(ATV)应用程序具有语音控制功能。 Basically, when the user presses the microphone button on a remote controller, the key event (identified by KeyEvent.KEYCODE_SEARCH ) is handled by the app, speech recognition starts (using android.speech.SpeechRecognizer ), the results (parsed speech) are obtained and parsed further by the app logic (eg showing the user search results or performing some in-app action). 基本上,当用户按下遥控器上的麦克风按钮时,按键事件(由KeyEvent.KEYCODE_SEARCH标识)由应用程序处理,语音识别开始(使用android.speech.SpeechRecognizer ),获得结果(解析语音)并由应用逻辑进一步解析(例如,显示用户搜索结果或执行某些应用内操作)。

Everything has been working as intended and described above, until, quite recently, Google Assistant (GA) was introduced to ATV platforms (the first one being Nvidia Shield box). 一切都按预期的方式进行了上述工作,直到最近,Google Assistant(GA)才引入ATV平台(第一个是Nvidia Shield盒)。 Now, when the RCU mic button is pressed, the GA overlay appears and the mic key event doesn't even reach the app. 现在,当按下RCU麦克风按钮时,GA叠加层出现,并且麦克风按键事件甚至没有到达应用程序。

For the last few days I've done some extensive research (documentation, internet, forums, stackoverflow etc.) and experimented with some potential workarounds, but nothing's worked so far and I haven't been able to find any definite information on the topic (probably due to the ATV+GA combination being rather new on the scene, and the ATV ecosystem not being as large as the Android one). 在过去的几天里,我进行了一些广泛的研究(文档,Internet,论坛,stackoverflow等),并尝试了一些可能的解决方法,但到目前为止,没有任何效果,并且我无法找到关于该主题的任何明确信息(可能是由于ATV + GA组合在现场是相当新的,并且ATV生态系统没有Android系统那么大)。

The best hint I got so far is what's been done with the Spotify app for Android TV . 到目前为止,我得到的最好的提示是Android TVSpotify应用已完成了什么工作。 When it's run on an ATV device with no GA, it basically behaves as I described above; 当它在没有GA的ATV设备上运行时,其行为基本上与我上述相同; but when GA is present, the GA overlay appears, receives the parsed speech and shows the search results, with results from Spotify in the first line - so, the Spotify app is integrated with GA, and this integration replaces the in-app voice control mechanism. 但是当存在GA时,GA叠加层就会出现,接收经过解析的语音并显示搜索结果,第一行中有Spotify的结果-因此,Spotify应用程序已与GA集成,并且此集成替代了应用内语音控制机制。 This suggests that either there is no way to ignore/disable GA inside your app in order to receive the mic key event and proceed with voice control as usual, or at least this is the preferred way of handling voice commands now. 这表明,要么没有办法忽略/禁用应用程序内的GA以便接收麦克风按键事件并像往常一样进行语音控制,要么至少这是现在处理语音命令的首选方式。 It also shows that there are apps for ATV that approach voice control the way I described, so maybe someone here has already encountered similar problem. 它还表明,有一些ATV应用程序可以按照我所描述的方式进行语音控制,所以这里的某人可能已经遇到了类似的问题。

My question(s): 我的问题:

  • is it possible to prevent Google Assistant from taking over RCU mic button signal? 是否可以阻止Google Assistant接管RCU麦克风按钮信号?
  • is it ok to do so? 这样可以吗? (by "not ok" I would mean - are there any official guidelines that discourage such behavior - or at least are there valid reasons not to do so?) (我的意思是“不行”-是否有任何官方准则劝阻此类行为-或至少有正当理由不这样做?)
  • if so, can it be done? 如果可以,可以做到吗?
  • if not, is there a resource documenting how to integrate with GA (the way Spotify for ATV app does)? 如果没有,是否有资源记录如何与GA集成(Spotify for ATV应用程序的方式)?

Starting with your last question: 从您的最后一个问题开始:

if not, is there a resource documenting how to integrate with GA (the way Spotify for ATV app does)? 如果没有,是否有资源记录如何与GA集成(Spotify for ATV应用程序的方式)?

I wrote about how to integrate on the Android Developer's Blog . 我在Android开发者博客上写了关于如何集成的文章 Spotify has onboarded their content catalog to Google's services which is why the Google Assistant is able to work so well. Spotify已将其内容目录加入了Google的服务 ,这就是Google Assistant能够如此出色地工作的原因。 You can achieve similar results if you make your app searchable (covered in the blog). 如果使应用程序可搜索(在博客中介绍),则可以实现类似的结果。

is it possible to prevent Google Assistant from taking over RCU mic button signal? 是否可以阻止Google Assistant接管RCU麦克风按钮信号?

No, not at this time. 不,目前不行。 The Google Assistant is a system app that takes control over the mic to give a uniform experience across all apps. Google助手是一个系统应用程序,可以控制麦克风,以在所有应用程序中提供统一的体验。

is it ok to do so? 这样可以吗? (by "not ok" I would mean - are there any official guidelines that discourage such behavior - or at least are there valid reasons not to do so?) (我的意思是“不行”-是否有任何官方准则劝阻此类行为-或至少有正当理由不这样做?)

if so, can it be done? 如果可以,可以做到吗?

You can still have an in-app search experience. 您仍然可以享受应用内搜索的体验。 There is an example in the leanback sample. leanback示例中有一个示例。 You will need to set a listener on a BrowseFragment and implement a SearchFragment . 您将需要在BrowseFragment上设置侦听器并实现SearchFragment We know this can be confusing, have in-app search and Google Assistant search competing, but we are working on how to improve this. 我们知道这可能会造成混淆,应用程序内搜索和Google Assistant搜索之间存在竞争,但是我们正在研究如何改善这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 谷歌助手是否可以在 Android 上的某个应用程序中按下按钮? - Is it possible for google assistant to press a button in a certain app on Android? 通过语音命令(例如Google助手)启动android应用 - Lanch android app from voice command like google assistant Android-AudioRecord:通过音频插孔(麦克风)检测脉宽调制信号 - Android - AudioRecord: Detect a pulse-width modulated signal over the audio jack (mic) 通过Google TV(Android非根设备)从端口查找pid - find pid from port over Google TV (Android non-rooted device) 如何使用谷歌助手为我的应用测试 android 切片 - how to test android slices using google assistant for my app 防止返回按钮退出Cordova插件中的android应用 - Prevent the back button from quitting android app inside a Cordova plugin 从其他Android设备(如Google电视遥控器)远程控制Android驱动的电视 - Remote control Android powered TV from another Android device like google Tv remote 防止工作缓慢接管线程池 - Prevent from slow job taking over a thread pool 谷歌助手和打开非午餐应用 - Google assistant and opening unlunched app 从Android麦克风获取频率 - Get frequency from Android mic
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM