Version: 5.4 (switch to 5.5b)
言語English
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

KeywordRecognizer

class in UnityEngine.Windows.Speech

/

Inherits from: Windows.Speech.PhraseRecognizer

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

マニュアルに切り替える

Description

DictationRecognizer は入力された音声を聞き、フレーズを登録したキーワード (keyword)のリストと照合しようとします。

どんな時でも、多くの KeywordRecognizer がアクティブになっているかもしれませんが、複数の KeywordRecognizer が同じキーワード (keyword) を聞いていることはありません。

#pragma strict
public class KeywordScript extends MonoBehaviour {

@SerializeField private var m_Keywords: String[];

private var m_Recognizer: KeywordRecognizer;

function Start() { m_Recognizer = new KeywordRecognizer(m_Keywords); m_Recognizer.OnPhraseRecognized += OnPhraseRecognized; m_Recognizer.Start(); }

private function OnPhraseRecognized(args: PhraseRecognizedEventArgs) { var builder: var = new StringBuilder(); builder.AppendFormat("{0} ({1}){2}", args.text, args.confidence, Environment.NewLine); builder.AppendFormat("\tTimestamp: {0}{1}", args.phraseStartTime, Environment.NewLine); builder.AppendFormat("\tDuration: {0} seconds{1}", args.phraseDuration.TotalSeconds, Environment.NewLine); Debug.Log(builder.ToString()); } }
using System;
using System.Text;
using UnityEngine;
using UnityEngine.Windows.Speech;

public class KeywordScript : MonoBehaviour { [SerializeField] private string[] m_Keywords;

private KeywordRecognizer m_Recognizer;

void Start() { m_Recognizer = new KeywordRecognizer(m_Keywords); m_Recognizer.OnPhraseRecognized += OnPhraseRecognized; m_Recognizer.Start(); }

private void OnPhraseRecognized(PhraseRecognizedEventArgs args) { StringBuilder builder = new StringBuilder(); builder.AppendFormat("{0} ({1}){2}", args.text, args.confidence, Environment.NewLine); builder.AppendFormat("\tTimestamp: {0}{1}", args.phraseStartTime, Environment.NewLine); builder.AppendFormat("\tDuration: {0} seconds{1}", args.phraseDuration.TotalSeconds, Environment.NewLine); Debug.Log(builder.ToString()); } }

KeywordRecognizer は現在 Windows 10 でのみ機能します。

Variables

KeywordsKeywordRecognizer を作成するときに提供されたキーワードのリストを返します。

Constructors

KeywordRecognizer指定したキーワードを指定した最低音声認識精度で聞く KeywordRecognizer を作成します。指定した最低音声認識精度より低い精度のフレーズは無視されます。

Inherited members

Variables

IsRunningPhraseRecognizer がフレーズを聞いているかどうか

Public Functions

DisposePhraseRecognizer が使用したリソースを破棄します。
StartPhraseRecognizer がフレーズを聞くのを開始します。
StopPhraseRecognizer がフレーズを聞くのを停止します。

Events

OnPhraseRecognizedPhraseRecognizer がフレーズを認識したときに発生するイベント

Delegates

PhraseRecognizedDelegateOnPhraseRecognized イベントのデリゲート