【问题标题】:MRTK V2.2 - Access Speech Command via ScriptMRTK V2.2 - 通过脚本访问语音命令
【发布时间】:2020-03-23 16:58:13
【问题描述】:

在我的场景中,按钮是在运行时创建的。这些将通过语音命令单击。出于这个原因,我试图找出如何在运行时添加语音命令。但我找不到任何方法。

我尝试了什么: 我用两种方法扩展了接口IMixedRealitySpeechSystemRefreshRecognitionAddSpeechCommand:

/// <summary>
/// Refresh recognition after adding new commands
/// </summary>
void RefreshRecognition();

/// <summary>
/// Add command to already existing commands[]
/// </summary>
/// <param name="command"></param>
void AddSpeechCommand(SpeechCommands command);

我已经在WindowsSpeechInputProvider: MixedRealitySpeechSystem 类中实现了这些。但是有两个问题。

首先:我无法访问 WindowsSpeechInputProvider。我想我可以试试这个:

private IMixedRealitySpeechSystem SpeechSystem
{
    get
    {
        if(_speechSystem is null)
        {
            MixedRealityServiceRegistry.TryGetService(out _speechSystem);
        }
        return _speechSystem;
    }
}

public void SomeMethod()
{
    SpeechCommands command = new SpeechCommands("TestCommand", default, default, null);
    SpeechSystem.AddSpeechCommand(command);
    SpeechSystem.RefreshRecognition();
}

但问题是MixedRealityServiceRegistry 不包含该服务的实例,或者准确地说,它甚至不是服务。

第二:即使这样可行,也不是一个好方法。因为这样我更改了 MRTK 并再次升级到新版本,所以这些行被覆盖了。

我的问题
那么如何在运行时访问和添加命令呢?

【问题讨论】:

    标签: unity3d augmented-reality hololens mrtk


    【解决方案1】:

    有一个开放的功能请求允许在 Github 中添加动态语音命令:Add keywords dynamically to MRTK speech commands #6369. 目前不可能。

    此线程对处理整体方案的替代方法提出了一些建议。总之,建议您使用语法识别器并使用 SRGS XML 文件来定义您的语音识别规则。 Voice input in UnityHologram 212 有一个示例说明如何使用它。

    【讨论】:

    • 哦,好的,我会热切地等待这个功能:D!感谢回复
    猜你喜欢
    • 1970-01-01
    • 2022-11-23
    • 1970-01-01
    • 2016-05-08
    • 1970-01-01
    • 2014-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多