二、Windows10平台下Unity3d的语音识别——语法识别

一、Windows10平台下Unity3d的语音识别——关键字识别
如果使用SRGS XML文件定义要侦听的特定语法,则使用语法识别器。关于SRGS XML文件格式的详细信息可以在MSDN网站上找到。

一旦您有了SRGS XML语法,就将它放到项目的流文件夹中。实现了与关键字识别相同的语法识别。
Step 1: 加载 SRGS Grammar
Step 2: 处理OnPhraseRecognized事件.
Step 3: 开始Grammar recognizer

using UnityEngine;
using UnityEngine.Windows.Speech;
using System;

public class GrammerRecognizerBehaviour : MonoBehaviour {

	GrammarRecognizer grammerRecognizer;

	// Use this for initialization
	void Start () {
		// pass path of your grammar XML in the constructor
		grammerRecognizer = new GrammarRecognizer ("Grammer path from streaming asset folder");
		grammerRecognizer.OnPhraseRecognized += OnGrammerRecognized;
		grammerRecognizer.Start ();
	}

	void OnGrammerRecognized(PhraseRecognizedEventArgs args)
	{
		// write your own logic
	}
}

三、Windows10平台下Unity3d的语音识别——听写识别

你可能感兴趣的:(Unity)