Unreal 中的语音输入Voice Input in Unreal

概述Overview

使用 Unreal 中的语音输入,无需使用手手势即可与全息图进行交互,并且仅支持 HoloLens 2。Voice input in Unreal allows you to interact with a hologram without having to use hand gestures and is only supported HoloLens 2. 即使 HoloLens 2 上的语音输入由支持其他所有通用 Windows 应用程序中的语音的同一引擎提供支持,Unreal 也使用一个更有限的引擎来处理语音输入。Even though voice input on HoloLens 2 is powered by the same engine that supports speech in all other Universal Windows Apps, Unreal uses a more limited engine of its own to process voice input. 这会将 Unreal 中的语音输入功能限制为预定义的语音映射,如以下部分所述。This limits voice input features in Unreal to predefined speech mappings, which is covered in the following sections.

启用语音识别Enabling Speech Recognition

在 HoloLens 上启用语音识别:To enable speech recognition on HoloLens:

  1. 选择 " 项目设置" > 平台 > HoloLens > 功能 并启用 麦克风Select Project Settings > Platform > HoloLens > Capabilities and enable Microphone.
  2. 已在 " 设置" > 隐私 > 语音 "中启用语音识别,然后选择" 英语"。Enabled speech recognition in Settings > Privacy > Speech and select English.

备注

语音识别始终在 " 设置 " 应用程序中配置的 Windows 显示语言中工作。Speech recognition always functions in the Windows display language configured in the Settings app. 建议你同时启用 在线语音识别 ,以获得最佳的服务质量。It’s recommended that you also enable Online speech recognition for the best service quality.

Windows 语音识别设置

  1. 当应用程序首次启动时,将显示一个对话框,询问你是否要启用麦克风。A dialog will show up when the application first starts to ask if you want to enable the microphone. 选择 "是" 将在应用中启动语音输入。Selecting Yes starts voice input in the app.

语音输入不需要任何特殊的 Windows Mixed Reality Api;它基于现有的 Unreal Engine 4 输入 映射 API 构建。Voice input doesn’t require any special Windows Mixed Reality APIs; it's built on the existing Unreal Engine 4 Input mapping API.

添加语音映射Adding Speech Mappings

使用语音输入时,将语音连接到操作非常重要。Connecting speech to action is an important step when using voice input. 这些映射会监视用户可能会说出的语音关键字应用,然后发出链接的操作。These mappings monitor the app for speech keywords that a user might say, then fire off a linked action. 可以通过以下方式找到语音映射:You can find Speech Mappings by:

  1. 选择 " 编辑 > 项目设置",滚动到 " 引擎 " 部分,然后单击 " 输入"。Selecting Edit > Project Settings, scrolling to the Engine section, and clicking Input.

添加跳转命令的新语音映射:To add a new Speech Mapping for a jump command:

  1. 单击 " + 数组元素 " 旁边的图标,然后填写以下值:Click the + icon next to Array elements and fill out the following values:
    • 操作名称jumpWordjumpWord for Action Name
    • 跳转****语音关键字jump for Speech Keyword

备注

() 的任何英语单词 () 或短句子都可以用作关键字。Any English word(s) or short sentence(s) can be used as a keyword.

UE4 引擎输入设置

语音映射可用作操作或轴映射等输入组件或事件图中的蓝图节点。Speech Mappings can be used as Input components like Action or Axis Mappings or as blueprint nodes in the Event Graph. 例如,可以链接 "跳转" 命令,根据字词的讲述时间打印出两个不同的日志:For example, you could link the jump command to print out two different logs depending on when the word is spoken:

  1. 双击蓝图以在 事件图 中打开它。Double-click a blueprint to open it in the Event Graph.
  2. 右键单击 并搜索语音映射的 操作名称 (在本例中为 JumpWord) ,然后按 EnterRight-click and search for the Action Name of your speech mapping (in this case jumpWord), then hit Enter. 这会将 " 输入操作 " 节点添加到关系图中。This adds an Input Action node to the graph.
  3. 按下 的 pin 拖放到 " 打印字符串 " 节点,如下图所示。Drag and drop the Pressed pin to Print String node as shown in the image below. 你可以保留已 释放 的 pin,而不会对语音映射执行任何操作。You can leave the Released pin empty, it won't execute anything for speech mappings.

简单的语音操作

  1. 播放应用,口述 " 跳转 " 并观看控制台打印日志!Play the app, say the word jump and watch the console print out the logs!

这就是在 Unreal 中开始向 HoloLens 应用添加语音输入所需的全部设置。That's all the setup you'll need to start adding voice input to your HoloLens apps in Unreal. 可以在下面的链接中找到有关语音和交互性的详细信息,并确保考虑要为用户创建的体验。You can find more information on speech and interactivity can be found at the links below, and be sure to think about the experience you're creating for your users.

下一个开发检查点Next Development Checkpoint

如果遵循我们所说的 Unreal 开发检查点旅程,则下一项任务是探索混合现实平台功能和 Api:If you're following the Unreal development checkpoint journey we've laid out, you're next task is exploring the Mixed Reality platform capabilities and APIs:

你可以随时返回到 Unreal 开发检查点You can always go back to the Unreal development checkpoints at any time.

另请参阅See also