小编C. *_* IV的帖子

如何从带有短语主题的Cortana命令中提取参数,通过文本激活?

高水平:

我想在TEXT模式下使用我的自定义Cortana命令"Notepad" .例如,按下WIN + S并输入"appname Notepad Example sentence!".
(这将打开记事本并输入"例句!".)

记事本命令已经在VOICE模式下工作:当我按下WIN + C并说"appname Notepad Example sentence!"时,我的记事本脚本与有效负载一起运行"例句!".

问题:

当我按下WIN + S并输入"appname Notepad Example sentence!"时,SpeechRecognitionResult的text属性为"Notepad ..."(与语音相反,它是"Notepad Example sentence!",如预期的那样).

码:

VCD.xml摘录

<Command Name="notepad">
  <Example> Notepad Example Sentence! </Example>
  <ListenFor> Notepad {wildcardArgs} </ListenFor>
  <Feedback> Notepadding {wildcardArgs} </Feedback>
  <Navigate/>
</Command>

<PhraseTopic Label="wildcardArgs" Scenario="Dictation">
  <!--<Subject>Wildcard</Subject>-->
</PhraseTopic>
Run Code Online (Sandbox Code Playgroud)

CommandHandler.cs

public static CortanaCommand ProcessCommand(SpeechRecognitionResult speechRecognitionResult, CommandDiagnostics diagnostics)
{
    // Get the name of the voice command and the raw text
    string voiceCommandName = speechRecognitionResult.RulePath[0];
    string text …
Run Code Online (Sandbox Code Playgroud)

c# win-universal-app cortana

5
推荐指数
1
解决办法
736
查看次数

标签 统计

c# ×1

cortana ×1

win-universal-app ×1