Dialogflow-为社交机器人老人重复最后一句话(语音) [英] Dialogflow - Repeat last sentence (voice) for Social Robot Elderly

查看:112
本文介绍了Dialogflow-为社交机器人老人重复最后一句话(语音)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Google行动和Dialogflow为老年人构建社交机器人.

我想知道如何在用户询问时轻松地重复最后一句话(请重复"),因为老年人通常是第一次不听该句子.

一种方法是在Dialogflow中具有重复的跟踪意图,但是由于:

  • 您需要在每个意图后添加一个,而我有很多
  • 在多用户环境中,您需要跟踪每个用户的最后一句话...

另一种方法是利用Dialogflow上下文.发送消息时,还可以将该消息添加到上下文中(例如,可以将其称为"last_message").然后,您可以具有另一个Intent,该Intent会将"last_message"上下文作为输入上下文,如果被触发,则使用保存在上下文中的值来重复它.

  • 但是,我仍然有一个问题,我需要为我的每一个意图添加一个上下文,这有很多.

有人知道如何更快地做到这一点吗?我找到了这个包,但是它在JS中,我需要Python: https://github.com/SysCoder/VoiceRepeater/pulls .

如何实现此VoiceRepeater库?我是否将代码放在我已经实现的实现功能重复"下,并映射到我创建的意图重复",该意图响应诸如对不起,您能重复一遍"之类的话吗?另外,我在哪里安装VoiceRepeater库(代码:npm install voice-repeater --save)?

解决方案

使用跟进意图可能是错误的方法.如您所述,对于多个Intent来说,它太重了.如果您希望重复"的消息以不同的方式阐明响应,则在某些情况下可能会很有用,但是总的来说,它不是很有用. (还应注意,后续意图使用上下文,但与下文讨论的方式不同.)

您不需要将上下文作为发送上下文的一部分添加到UI中-您可以将其设置为实现"的一部分.它包含一个参数,该参数要么完全包含您所说的内容,要么包含重新创建您所说的内容所需的信息(可能的话,可以采用其他形式).在重复"意图中,您将读取在此上下文中保存的值,然后再次将其作为输出发送.如果您使用的是SSML,则可能需要更改速度或音量.

根据新问题进行更新

VoiceRepeater的自述文件具有使用它所需的基本知识,但是它确实对Node有一点熟悉.但是总的来说,是的,您可以按照描述的方式进行安装,设置一个捕获重复请求的Intent,并注册一个处理程序功能(自述文件中的repeatLastStatement(app)),用于处理通过voiceRepeater.lastPromptWithPrefix()发送答复的Intent./p>

也可能假设您使用的是Google Actions-on-Google库的版本1.我还没有对代码进行过深入的研究,但是看起来它用它自己的库代替了ask函数,而且我不确定Google Actions-on-Google库的版本2是否能很好地发挥作用./p>

与Voice Repeater不同,multivocal不需要您专门注册处理程序,因为它会尝试在封面下隐藏尽可能多的样板.您只需要定义您可能希望使用的答复即可.它使用我在上面概述的上下文方案来存储响应,并在用户要求重复该响应时使它们可用.

没有任何关于使用 multivocal 的视频,但是

但是,如果要为Python实现,这两个都不对您有直接帮助.但是,如果您查看VoiceRepeater的源代码,则可以了解如何在Python中自己实现它.

关键位在第47行将回复保存在上下文中. (它还会保存带有前缀消息的答复.)然后调用将发送答复的原始函数:

  app.setContext("last_prompt", 100,
    {
      "last_prompt": textToSpeech,
      "prefixed_last_prompt": repeatPrefix + lastStatement,
    });
  originalAsk(response);

稍后,在对 lastPromptWithPrefix() ,它将使用上下文的内容发送回复.

  lastPromptWithPrefix() {
     return this.app.getContext("last_prompt") !== null
         ? this.app.getContextArgument("last_prompt", "prefixed_last_prompt").value
         : "um....I don't remember what I said!";
  }

I am using actions-on-google and Dialogflow to build a social robot for Elderly.

I was wondering how I can easily repeat the last sentence when asked by the user ("repeat please") as often the Senior doesn't hear the sentence the first time.

One way would be to have repeat followup intents in Dialogflow but this is quite heavy since :

  • you need to add one after each intent and I have many
  • in a multi-user environment you need to keep track of the last sentence for every user ...

Another way would be be to take advantage of Dialogflow Contexts. As you send the message, you can also add that message to a context (for example, you can call it "last_message"). You can then have another Intent that takes as an input context the "last_message" context and, if triggered, uses the value saved in the context to repeat it.

  • However, I still have the problem that I need to add a context to every intent I have, which are many.

Does anyone know how to accomplish this in a quicker way? I found this package but it is in JS and I need it Python: https://github.com/SysCoder/VoiceRepeater/pulls .

How do I implement this VoiceRepeater library? Do I put the code under fulfillment function 'repeat' I have made and mapped to an intent called 'repeat' that I have made which responds to utterances such as 'Sorry, could you repeat that'? Also, where do I install the VoiceRepeater library (code: npm install voice-repeater --save)?

解决方案

Using Followup Intents is probably the wrong way to do this. As you note, it is way too heavy for more than a few Intents. It may be useful in certain circumstances if you want the "repeated" message to clarify the response in a different way, but in general, it isn't very useful. (It should also be noted that Followup Intents use Contexts, but in a different way than discussed below.)

You don't need to add the Context to the UI as part of the Outgoing Context - you would set this as part of your Fulfillment. It would include a parameter that either contained exactly what you said, or the information you needed to recreate what you said (possibly in a different form, if appropriate). In your "repeat" Intent, you'd read the value that you had saved in this Context, and send it as the output again. If you're using SSML, you may wish to change the speed or volume, if that is appropriate.

Update based on new questions

The readme for VoiceRepeater has the basics of what you need to do to use it, but it does assume a little familiarity with Node. But in general, yes, you install it the way you describe, setup an Intent that captures requests to repeat, and registers a handler function (repeatLastStatement(app) in the readme) that handles the Intent to send a reply through voiceRepeater.lastPromptWithPrefix().

It also may assume you're using version 1 of the actions-on-google library. I haven't dug too deeply into the code, but it looks like it replaces the library's ask function with its own, and I'm not sure how well that works with version 2 of the actions-on-google library.

Unlike Voice Repeater, multivocal doesn't require you to register handlers specifically since it tries to hide as much boilerplate under the covers. You just need to define the replies that you might want it to use. It uses the Context scheme I outline above to store responses and make them available when the user asks for it to be repeated.

There aren't any videos on using multivocal, but the simple example does include the configuration illustrating how to configure responses for the "multivocal.repeat" Intent. While VoiceRepeater works with the actions-on-google library, multivocal is a complete replacement, offering a more template-based approach to building fulfillment.

However, neither of these directly help you if you want to implement it for Python. But if you look at the source for VoiceRepeater, you can get a sense for how to implement it yourself in Python.

The key bit is on line 47 where it saves the reply in a context. (It also saves the reply with a prefix message.) It then calls the original function that would send the reply:

  app.setContext("last_prompt", 100,
    {
      "last_prompt": textToSpeech,
      "prefixed_last_prompt": repeatPrefix + lastStatement,
    });
  originalAsk(response);

Later, in the call to lastPromptWithPrefix(), it uses the contents of the Context to send a reply.

  lastPromptWithPrefix() {
     return this.app.getContext("last_prompt") !== null
         ? this.app.getContextArgument("last_prompt", "prefixed_last_prompt").value
         : "um....I don't remember what I said!";
  }

这篇关于Dialogflow-为社交机器人老人重复最后一句话(语音)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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