class Intent::IntentRecognizer

class Intent::IntentRecognizer
  : public AsyncRecognizer< IntentRecognitionResult, IntentRecognitionEventArgs, IntentRecognitionCanceledEventArgs >

除了执行语音转文本识别外,IntentRecognizer 还提取有关说话人意图的结构化信息,该信息可用于使用专用意向触发器推动进一步操作(请参阅 IntentTrigger)。

成员

性能

语法:public PropertyCollection & Properties;

为此 IntentRecognizer 定义的属性及其值的集合。

IntentRecognizer

语法:public inline explicit IntentRecognizer ( SPXRECOHANDLE hreco );

内部构造函数。 使用提供的句柄创建新实例。

参数

  • hreco 识别器句柄。

~IntentRecognizer

语法:public inline ~IntentRecognizer ( );

破坏者

RecognizeOnceAsync

语法:public inline virtual std::future< std::shared_ptr< IntentRecognitionResult > > RecognizeOnceAsync ( );

启动意向识别,并在识别单个话语后返回。 单个言语的结尾是通过在末尾侦听静音或最多处理大约 30 秒的音频来确定的。 任务返回识别文本作为结果。 注意:由于 RecognizeOnceAsync() 仅返回单个话语,因此它仅适用于单次识别(如命令或查询)。 对于长时间运行的多言语识别,请改用 StartContinuousRecognitionAsync。。

返回

将来包含异步意向识别的结果值(指向 IntentRecognitionResult 的共享指针)。

RecognizeOnceAsync

语法:public inline std::future< std::shared_ptr< IntentRecognitionResult > > RecognizeOnceAsync ( std::string text );

启动意向识别,并从传入的文本生成结果。 当语音输入未绑定到 IntentRecognizer 时,这对于测试和其他时间非常有用。 注意:意向服务当前不支持此功能,因此它仅适用于脱机模式匹配或完全匹配意向。

参数

  • text 要计算的文本。

返回

将来包含异步意向识别的结果值(指向 IntentRecognitionResult 的共享指针)。

StartContinuousRecognitionAsync

语法:public inline virtual std::future< void > StartContinuousRecognitionAsync ( );

异步启动连续意向识别操作。

返回

空的未来。

StopContinuousRecognitionAsync

语法:public inline virtual std::future< void > StopContinuousRecognitionAsync ( );

异步终止正在进行的连续意向识别操作。

返回

空的未来。

StartKeywordRecognitionAsync

语法:public inline virtual std::future< void > StartKeywordRecognitionAsync ( std::shared_ptr< KeywordRecognitionModel > model );

异步启动关键字识别操作。

参数

  • model 指定要使用的关键字模型。

返回

空的未来。

StopKeywordRecognitionAsync

语法:public inline virtual std::future< void > StopKeywordRecognitionAsync ( );

异步终止关键字识别操作。

返回

空的未来。

AddIntent

语法:public inline void AddIntent ( const std::string & simplePhrase );

添加一个简单的短语,该短语可由用户朗读,指示特定用户意向。 这个简单的短语可以是一种模式,包括大括号和包围的诱惑。 例如“单击 {checkboxName} 复选框”。

参数

  • simplePhrase 与意向对应的短语。

识别后,IntentRecognitionResult 的 IntentId 属性将与此处指定的 simplePhrase 匹配。 如果指定并匹配任何实体,则它们将在 IntentResult->GetEntities() 调用中使用。

AddIntent

语法:public inline void AddIntent ( const std::string & simplePhrase , const std::string & intentId );

添加一个简单的短语,该短语可由用户朗读,指示特定用户意向。 这个简单的短语可以是一种模式,包括大括号和包围的诱惑。 例如“单击 {checkboxName} 复选框”。

参数

  • simplePhrase 与意向对应的短语。

  • intentId 在 IntentRecognitionResult 的 IntentId 属性中返回的自定义 ID 字符串。

识别后,结果的意向 ID 将与此处提供的 ID 匹配。 如果指定并匹配任何实体,则它们将在 IntentResult->GetEntities() 调用中使用。

AddIntent

语法:public inline void AddIntent ( std::shared_ptr< LanguageUnderstandingModel > model , const std::string & intentName );

按名称从指定的语言理解模型添加单个意向。 对于 PatternMatchingModel 和 ConversationalLanguageUnderstandingModel 类型,这将在启用之前清除任何现有模型。 对于这些类型,将忽略 intentName。

参数

  • model 包含意向的语言理解模型。

  • intentName 要从语言理解模型包含的单个意向的名称。

识别后,IntentRecognitionResult 的 IntentId 属性将包含此处指定的 intentName。

AddIntent

语法:public inline void AddIntent ( std::shared_ptr< LanguageUnderstandingModel > model , const std::string & intentName , const std::string & intentId );

按名称从指定的语言理解模型添加单个意向。 对于 PatternMatchingModel 和 ConversationalLanguageUnderstandingModel 类型,这将在启用之前清除任何现有模型。 对于这些类型,将忽略 intentName 和 intentId。

参数

  • model 包含意向的语言理解模型。

  • intentName 要从语言理解模型包含的单个意向的名称。

  • intentId 在 IntentRecognitionResult 的 IntentId 属性中返回的自定义 ID 字符串。

AddAllIntents

语法:public inline void AddAllIntents ( std::shared_ptr< LanguageUnderstandingModel > model );

从指定的语言理解模型添加所有意向。 对于 PatternMatchingModel 和 ConversationalLanguageUnderstandingModel 类型,这将在启用之前清除任何现有模型。

参数

  • model 包含意向的语言理解模型。

识别后,IntentRecognitionResult 的 IntentId 属性将包含识别的意向的名称。

AddAllIntents

语法:public inline void AddAllIntents ( std::shared_ptr< LanguageUnderstandingModel > model , const std::string & intentId );

从指定的语言理解模型添加所有意向。 对于 PatternMatchingModel 和 ConversationalLanguageUnderstandingModel 类型,这将在启用之前清除任何现有模型。

参数

  • model 包含意向的语言理解模型。

  • intentId 在 IntentRecognitionResult 的 IntentId 属性中返回的自定义字符串 ID。

AddIntent

语法:public inline void AddIntent ( std::shared_ptr< IntentTrigger > trigger , const std::string & intentId );

添加指定的 IntentTrigger。

参数

  • trigger 与意向对应的 IntentTrigger。

  • intentId 在 IntentRecognitionResult 的 IntentId 属性中返回的自定义字符串 ID。

SetAuthorizationToken

语法:public inline void SetAuthorizationToken ( const std::string & token );

设置将用于连接到服务的授权令牌。 注意:调用方需要确保授权令牌有效。 在授权令牌过期之前,调用方需要使用新的有效令牌调用此 setter 来刷新它。 否则,识别器将在识别过程中遇到错误。

参数

  • token 表示授权令牌的字符串。

GetAuthorizationToken

语法:public inline std::string GetAuthorizationToken ( );

获取授权令牌。

返回

授权令牌

ApplyLanguageModels

语法:public inline bool ApplyLanguageModels ( const std::vector< std::shared_ptr< LanguageUnderstandingModel > > & collection );

获取语言理解模型的集合,对其进行复制,并将其应用于识别器。 此应用程序在不同的时间发生,具体取决于语言理解模型类型。 简单语言模型几乎会立即处于活动状态,而使用 LUIS 的语言理解模型将在下一个语音轮次上处于活动状态。 这将替换以前应用的任何模型。

参数

  • collection 指向 LanguageUnderstandingModels 的共享指针的向量。

返回

如此 如果模型的应用程序立即生效。 否则为 false。

FromConfig

语法:public inline static std::shared_ptr< IntentRecognizer > FromConfig ( std::shared_ptr< SpeechConfig > speechConfig , std::shared_ptr< Audio::AudioConfig > audioInput );

从语音配置和音频配置创建意向识别器。用户应使用此函数创建意向识别器的新实例。

参数

  • speechConfig 语音配置。

  • audioInput 音频配置。

返回

意向识别器实例。

FromConfig

语法:public inline static std::shared_ptr< IntentRecognizer > FromConfig ( std::shared_ptr< EmbeddedSpeechConfig > speechConfig , std::shared_ptr< Audio::AudioConfig > audioInput );

从嵌入式语音配置和音频配置创建意向识别器。用户应使用此函数创建意向识别器的新实例。 在版本 1.19.0 中添加。

参数

  • speechConfig 嵌入式语音配置。

  • audioInput 音频配置。

返回

意向识别器实例。

BaseType

语法:typedef BaseType;