【问题标题】:Sending text input to google assistant in windows 10在 Windows 10 中向谷歌助手发送文本输入
【发布时间】:2021-06-19 15:44:08
【问题描述】:

好的,首先,这里的主要想法是在到达时自动化一些电灯开关。我住在一个混淆 gps 的树林里,所以我对 tuya 等的到达功能不能像预期的那样可靠地工作。它们有时确实有效,但我需要它是可靠的。

所以计划是安装 google assistant sdk 并让 textinput 正常工作。下载并安装了所有东西,做了谷歌云平台的事情,一切都很好。我可以在cmd中输入“关闭卧室灯”,然后卧室灯就会关闭。现在,这很好用,不要误会我的意思,我很可能会调整它来满足我的需要。但这需要启动一个交互式控制台,然后实际输入我想问的短语。

这个问题的解决方案是如果我可以用类似的东西查询文本输入

py -m googlesamples.assistant.grpc.textinput --device-id "insert_device_id" --device-model-id "insert_device_model_id" --textquery "turn off the bedroom light"

然后我就不必启动交互式提示并手动退出它。我希望能够在不与谷歌助手交互的情况下向助手发送文本。

最终目标是用我的电脑ping我的手机静态IP地址,并通过电脑上的谷歌助手打开设备/灯。

【问题讨论】:

  • 编辑this sample code 以使用命令行参数替换交互部分非常容易。到目前为止,您尝试过什么?
  • 我尝试在 stackoverflow 上发帖,cmon 你期待什么?除了大声笑,我还没有尝试过任何事情,因为我不确定这是否可能。所以你的意思是修改示例代码以绕过交互式shell,只获取结果或执行操作是微不足道的吗?另外,感谢您抽出宝贵时间提供帮助。
  • 我找到了一个使用文本到语音在线工具和 pushtotalk '-I' 选项的解决方法。到目前为止,它会ping手机,如果检测到它,它将检查灯的状态,如果它关闭,它会打开它。这里有最先进的技术吗?

标签: python google-api google-assistant


【解决方案1】:

只是为了让您入门,这是基于 sample source code 的替代方案:

# Add along with other click.options
@click.option('--textquery',
              metavar='<text to send>',
              required=False,
              help=(('Text to send. If not specified, use interactive mode')))

# Next add the flag to main
def main(api_endpoint, credentials,
         device_model_id, device_id, lang, display, verbose,
         grpc_deadline, textquery, *args, **kwargs):

# Then the main loop
with SampleTextAssistant(lang, device_model_id, device_id, display,
                         grpc_channel, grpc_deadline) as assistant:
    while True:
        # If textquery data set, use that as the query
        if textquery:
            query = textquery
        else:
            query = click.prompt('')
        click.echo('<you> %s' % query)
        response_text, response_html = assistant.assist(text_query=query)
        if display and response_html:
            system_browser = browser_helpers.system_browser
            system_browser.display(response_html)
        if response_text:
            click.echo('<@assistant> %s' % response_text)
        # If we're doing text, quit the loop
        if textquery:
            break

虽然完全未经测试,但希望您能理解!

【讨论】:

    猜你喜欢
    • 2021-10-04
    • 2018-05-21
    • 1970-01-01
    • 2019-11-21
    • 2018-01-09
    • 1970-01-01
    • 1970-01-01
    • 2018-01-02
    • 2018-06-08
    相关资源
    最近更新 更多