XSpeechToTextBeginHypothesisString

仮説を開始して、その文字列をテキスト オーバーレイに表示します。

構文

HRESULT XSpeechToTextBeginHypothesisString(  
         const char* speakerName,  
         const char* content,  
         XSpeechToTextType type,  
         uint32_t* hypothesisId  
)  

パラメーター

speakerName_In_z_
型: char*

仮説の文字列と共に表示される話者の名前。

content _In_z_
型: char*

最初の仮説の文字列。

type _In_
型: XSpeechToTextType

仮説の文字列のソース タイプ。

hypothesisId _Out_
型: uint32_t*

仮説の ID。

戻り値

型: HRESULT

HRESULT 成功またはエラー コード。

解説

仮説とは、話者が話している内容の推測です。通常、話者が話している間に音声認識エンジンによって生成されます。 音声変換オーバーレイ API では、ゲームの画面上に仮説の文字列を表示できます。

音声変換オーバーレイ API は、入力したテキストもサポートします。 type パラメーターでは、仮説の文字列のソースを識別します。

アプリでは、仮説が確定されるかキャンセルされるまで hypothesisId の値を維持することが求められます。

オーバーレイの仮説文字列を更新するには、XSpeechToTextUpdateHypothesisString を使用します。

仮説をキャンセルしてオーバーレイから削除するには、XSpeechToTextCancelHypothesisString を使用します。

仮説を確定するには、XSpeechToTextFinalizeHypothesisString を使用します。

プラットフォームによっては、アプリが XSpeechToTextFinalizeHypothesisString を呼び出すまでは仮説文字列が表示されません。 仮説がキャンセルされない限り、アプリは常に XSpeechToTextFinalizeHypothesisString を呼び出して、必ず文字列が表示されるようにする必要があります。

次のコード例は、仮説を作成し、更新して、確定するアプリを示しています。

void RowanHypothesisSample() 
{ 
    UINT32 hypothesisId; 
    XSpeechToTextBeginHypothesisString("Rowan", "I am typing some text.", XSpeechToTextType::Text, &hypothesisId); 
 
    // Some time passes. 
 
    XSpeechToTextUpdateHypothesisString(hypothesisId, "I am still typing some text."); 
 
    // Some time passes. 
 
    XSpeechToTextFinalizeHypothesisString(hypothesisId, "I typed some text. I am done typing."); 
} 

次のコード例は、仮説を作成し、更新して、キャンセルするアプリを示しています。

void QuincyHypothesisSample() 
{ 
    UINT32 hypothesisId; 
    XSpeechToTextBeginHypothesisString("Quincy", "I am speaking some text.", XSpeechToTextType::Voice, &hypothesisId); 
 
    // Some time passes. 
 
    XSpeechToTextUpdateHypothesisString(hypothesisId, "I am still speaking some text."); 
 
    // Some time passes. 
 
    XSpeechToTextCancelHypothesisString(hypothesisId); 
} 

要件

ヘッダー: XAccessibility.h

ライブラリ: xgameruntime.lib

サポートされているプラットフォーム: Windows、Xbox One ファミリー本体、Xbox Series 本体

関連項目

XAccessibility