使用脚本而不是麦克风将命令发送到Google Assistant [英] Sending commands to google assistant using script instead of mic

查看:112
本文介绍了使用脚本而不是麦克风将命令发送到Google Assistant的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Raspberry Pi 3中配置了Google Assistant SDK,演示应用程序运行正常.有什么方法可以使用Python脚本将"OK Google,示例命令"发送到Google Assistant SDK?还是只接受来自麦克风的输入?

I have configured Google Assistant SDK in Raspberry Pi 3 and demo application is working fine. Is there any way to send "OK Google, Example Command" to Google Assistant SDK using Python script? Or it will only take input from Mic?

我正计划编写一个微型移动应用程序,它将向我的Raspberry Pi Google助手应用程序发送命令.

I am planning to write tiny mobile application which will send commands to my Raspberry Pi google assistant application.

推荐答案

UPDATE :即使是一个老问题,这也是最新的更新.

UPDATE: even if it is an old question, here is the latest update.

现在可以使用 v1alpha2 版本. gRPC消息AssistConfig被定义为一个并集,您可以在其中选择音频输出配置文本查询.

It is now possible using the v1alpha2 version. The gRPC message AssistConfig is defined as an union where you can choose between an audio out config or a text query.

如果您使用的是 python 库,请参见

If you are using the python library, see the AssistConfig. Here is an example of config using a text query (adapted from the pushtotalk.py sample, line 183):

config = embedded_assistant_pb2.AssistConfig(
        # instead of audio_in_config
        # note: no need to use 'OK google'
        text_query = "who are you ?", 
        audio_out_config=embedded_assistant_pb2.AudioOutConfig(
            encoding='LINEAR16',
            sample_rate_hertz=self.conversation_stream.sample_rate,
            volume_percentage=self.conversation_stream.volume_percentage,
        ),
        dialog_state_in=dialog_state_in,
        device_config=embedded_assistant_pb2.DeviceConfig(
            device_id=self.device_id,
            device_model_id=self.device_model_id,
        )
    )

如果您使用的是 golang ,则 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆