다음을 통해 공유


Cortana VCD 구 목록을 동적으로 수정

Warning

이 기능은 Windows 10 2020년 5월 업데이트(버전 2004, 코드명 “20H1”)부터 더 이상 지원되지 않습니다.

Cortana가 최신적인 생산성 환경을 어떻게 변화시키고 있는지 알아보려면 Microsoft 365의 Cortana를 참조하세요.

음성 인식 결과를 사용하여 런타임에 VCD(음성 명령 정의) 파일에서 지원되는 구(PhraseList 요소) 목록에 액세스하고 업데이트합니다.

참고 항목

음성 명령은 VCD(음성 명령 정의) 파일에 정의된 특정 의도가 있는 단일 발화로 Cortana를 통해 설치된 앱으로 전달됩니다.

VCD 파일은 각각 고유한 의도를 가진 하나 이상의 음성 명령을 정의합니다.

음성 명령 정의는 복잡성이 다를 수 있습니다. 제한된 단일 발화에서 더 유연한 자연어 발화 컬렉션에 이르기까지 모든 것을 지원할 수 있으며 모두 동일한 의도를 나타냅니다.

런타임 시 구 목록을 동적으로 수정하는 것은 음성 명령이 일종의 사용자 정의 또는 일시적인 앱 데이터와 관련된 작업과 관련된 경우에 유용합니다.

예를 들어 목적지를 입력할 수 있는 여행 앱에서 사용자가 앱 이름을 말한 다음 "<목적지>로의 여행을 보여 주세요."라고 말하여 앱을 시작할 수 있도록 하려는 경우를 가정해 보겠습니다. ListenFor 요소 자체에서 다음과 같이 지정합니다. <ListenFor> Show trip to {destination} </ListenFor>, 여기서 "목적지"는 PhraseList에 대한 Label 특성 값입니다.

런타임에 구 목록을 업데이트하면 가능한 각 대상에 대해 별도의 ListenFor 요소를 만들 필요가 없습니다. 대신 사용자가 여정을 입력할 때 지정한 목적지로 PhraseList를 동적으로 채울 수 있습니다.

PhraseList 및 기타 VCD 요소에 대한 자세한 내용은 VCD 요소 및 특성 v1.2 참조를 참조하세요.

필수 조건

UWP(유니버설 Windows 플랫폼) 앱을 처음 개발하는 경우 다음 항목을 살펴보고 여기서 설명하는 기술을 숙지하세요.

사용자 환경 참고 자료

앱을 Cortana와 통합하는 방법에 대한 정보는 Cortana 디자인 가이드라인을 참조하고 유용하고 매력적인 음성 지원 앱을 디자인하는 데 유용한 팁은 음성 상호 작용을 참조하세요.

명령 식별 및 구 목록 업데이트

다음은 Adventure Works 여행 앱에서 목적지에 대한 세 가지 옵션을 정의하는 명령 "showTripToDestination"과 PhraseList를 정의하는 VCD 파일의 예입니다. 사용자가 앱에서 목적지를 저장하고 삭제하면 앱이 PhraseList의 옵션을 업데이트합니다.

<?xml version="1.0" encoding="utf-8"?>
<VoiceCommands xmlns="https://schemas.microsoft.com/voicecommands/1.1">
  <CommandSet xml:lang="en-us" Name="AdventureWorksCommandSet_en-us">
    <AppName> Adventure Works, </AppName>
    <Example> Show trip to London </Example>

    <Command Name="showTripToDestination">
      <Example> show trip to London  </Example>
      <ListenFor> show trip to {destination} </ListenFor>
      <Feedback> Showing trip to {destination} </Feedback>
      <Navigate/>
    </Command>

    <PhraseList Label="destination">
      <Item> London </Item>
      <Item> Dallas </Item>
      <Item> New York </Item>
    </PhraseList>

  </CommandSet>

<!-- Other CommandSets for other languages -->

</VoiceCommands>

VCD 파일에서 PhraseList 요소를 업데이트하려면 구 목록이 포함된 CommandSet 요소를 가져옵니다. 해당 CommandSet 요소의 Name 특성(Name은 VCD 파일에서 고유해야 함)을 키로 사용하여 VoiceCommandManager에 액세스합니다. InstalledCommandSets 특성을 추가하고 VoiceCommandSet 참조를 가져옵니다.

명령어 세트를 식별한 후 수정하려는 구 목록에 대한 참조를 가져오고 SetPhraseListAsync 메서드를 호출합니다. PhraseList 요소의 Label 특성과 문자열 배열을 구 목록의 새 콘텐츠로 사용합니다.

참고 항목

구 목록을 수정하면 전체 구 목록이 바뀝니다. 구 목록에 새 항목을 삽입하려면 SetPhraseListAsync 호출에서 기존 항목과 새 항목을 모두 지정해야 합니다.

이 예에서는 이전 예에 표시된 PhraseList를 Phoenix에 대한 추가 대상으로 업데이트합니다.

Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinition.VoiceCommandSet commandSetEnUs;

if (Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinitionManager.
      InstalledCommandSets.TryGetValue(
        "AdventureWorksCommandSet_en-us", out commandSetEnUs))
{
  await commandSetEnUs.SetPhraseListAsync(
    "destination", new string[] {“London”, “Dallas”, “New York”, “Phoenix”});
}

설명

인식을 제한하기 위해 PhraseList를 사용하는 것은 상대적으로 작은 집합 또는 단어에 적합합니다. 단어 집합이 너무 크거나(예: 수백 개의 단어) 전혀 제한되지 않아야 하는 경우 PhraseTopic 요소와 Subject 요소를 사용하여 음성 인식 결과의 관련성을 개선하여 확장성을 개선합니다.

이 예에는 "검색"의 시나리오가 있는 PhraseTopic이 있으며, "City\State"의 주체로 더욱 세분화됩니다.

<?xml version="1.0" encoding="utf-8"?>
<VoiceCommands xmlns="https://schemas.microsoft.com/voicecommands/1.1">
  <CommandSet xml:lang="en-us" Name="AdventureWorksCommandSet_en-us">
    <AppName> Adventure Works, </AppName>
    <Example> Show trip to London </Example>

    <Command Name="showTripToDestination">
      <Example> show trip to London  </Example>
      <ListenFor> show trip to {destination} </ListenFor>
      <Feedback> Showing trip to {destination} </Feedback>
      <Navigate/>
    </Command>

    <PhraseList Label="destination">
      <Item> London </Item>
      <Item> Dallas </Item>
      <Item> New York </Item>
    </PhraseList>

    <PhraseTopic Label="destination" Scenario="Search">
      <Subject>City/State</Subject>
    </PhraseTopic>

  </CommandSet>