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.

DictationRecognizer

class in UnityEngine.Windows.Speech

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 は入力された音声を聞き、どんなフレーズかを決定します。

ユーザーは仮設とフレーズ完了イベントを登録し聞けます。Start() と Stop() メソッドは、音声認識を有効、無効にします。Recognizer の処理が終わったら、Dispose() メソッドを使って使用したリソースを破棄する必要があります。このメソッドは、以前に破棄されていないリソースがある場合は、性能に追加負荷はかかりますが、ガベージコレクションのときにこれらを自動的に破棄します。

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

#pragma strict
public class DictationScript extends MonoBehaviour {
		@SerializeField
		private var m_Hypotheses: Text;
	
		@SerializeField
		private var m_Recognitions: Text;
		private var m_DictationRecognizer: DictationRecognizer;
	
		function Start() {
			m_DictationRecognizer = new DictationRecognizer();
			m_DictationRecognizer.DictationResult += function(text, confidence) {
				Debug.LogFormat("Dictation result: {0}", text);
				m_Recognitions.text += text + "\n";
			};

m_DictationRecognizer.DictationHypothesis += function(text) { Debug.LogFormat("Dictation hypothesis: {0}", text); m_Hypotheses.text += text + Env; };

m_DictationRecognizer.DictationComplete += function(completionCause) { if (cause != DictationCompletionCause.Complete) Debug.LogErrorFormat("Dictation completed unsuccessfully: {0}.", cause); };

m_DictationRecognizer.DictationError += function(error, hresult) { Debug.LogErrorFormat("Dictation error: {0}; HResult = {1}.", error, hresult); };

m_DictationRecognizer.Start(); } }
public class DictationScript : MonoBehaviour
{
		[SerializeField]
		private Text m_Hypotheses;

[SerializeField] private Text m_Recognitions;

private DictationRecognizer m_DictationRecognizer;

void Start() { m_DictationRecognizer = new DictationRecognizer();

m_DictationRecognizer.DictationResult += (text, confidence) => { Debug.LogFormat("Dictation result: {0}", text); m_Recognitions.text += text + "\n"; };

m_DictationRecognizer.DictationHypothesis += (text) => { Debug.LogFormat("Dictation hypothesis: {0}", text); m_Hypotheses.text += text + Env; };

m_DictationRecognizer.DictationComplete += (completionCause) => { if (cause != DictationCompletionCause.Complete) Debug.LogErrorFormat("Dictation completed unsuccessfully: {0}.", cause); };

m_DictationRecognizer.DictationError += (error, hresult) => { Debug.LogErrorFormat("Dictation error: {0}; HResult = {1}.", error, hresult); };

m_DictationRecognizer.Start(); } }

Variables

AutoSilenceTimeoutSecondsThe time length in seconds before dictation recognizer session ends due to lack of audio input.
InitialSilenceTimeoutSecondsThe time length in seconds before dictation recognizer session ends due to lack of audio input in case there was no audio heard in the current session.
StatusIndicates the status of dictation recognizer.

Constructors

DictationRecognizerCreate a DictationRecognizer with the specified minimum confidence and dictation topic constraint. Phrases under the specified minimum level will be ignored.

Public Functions

DisposeDisposes the resources this dictation recognizer uses.
StartStarts the dictation recognization session. Dictation recognizer can only be started if PhraseRecognitionSystem is not running.
StopStops the dictation recognization session.

Events

DictationCompleteEvent that is triggered when the recognizer session completes.
DictationErrorEvent that is triggered when the recognizer session encouters an error.
DictationHypothesisEvent that is triggered when the recognizer changes its hypothesis for the current fragment.
DictationResultEvent indicating a phrase has been recognized with the specified confidence level.

Delegates

DictationCompletedDelegateDictationComplete イベントのデリゲート
DictationErrorHandlerDictationError イベントのデリゲート
DictationHypothesisDelegate仮説変更のイベントを示すコールバック。DictationHypothesis イベントを登録する必要があります。
DictationResultDelegateフレーズが特定の認識精度で認識されたことを示すコールバック。DictationResult イベントを登録する必要があります。