Как извлечь сущность из Microsoft LUIS с помощью python? - PullRequest
1 голос
/ 18 июня 2020

Следуя примеру кода в этой ссылке , я могу извлечь намерение с помощью intent_result.intent_id, но как я могу извлечь сущность / сущности высказывания?

'' '

import azure.cognitiveservices.speech as speechsdk

print("Say something...")

intent_config = speechsdk.SpeechConfig(subscription="YourLanguageUnderstandingSubscriptionKey", region="YourLanguageUnderstandingServiceRegion")

intent_recognizer = speechsdk.intent.IntentRecognizer(speech_config=intent_config)

model = speechsdk.intent.LanguageUnderstandingModel(app_id="YourLanguageUnderstandingAppId")
intents = [
    (model, "HomeAutomation.TurnOn"),
    (model, "HomeAutomation.TurnOff")
]
intent_recognizer.add_intents(intents)

start_continuous_recognition() instead.
intent_result = intent_recognizer.recognize_once()

if intent_result.reason == speechsdk.ResultReason.RecognizedIntent:
    print("Recognized: \"{}\" with intent id `{}`".format(intent_result.text, intent_result.intent_id))
elif intent_result.reason == speechsdk.ResultReason.RecognizedSpeech:
    print("Recognized: {}".format(intent_result.text))
elif intent_result.reason == speechsdk.ResultReason.NoMatch:
    print("No speech could be recognized: {}".format(intent_result.no_match_details))
elif intent_result.reason == speechsdk.ResultReason.Canceled:
    print("Intent recognition canceled: {}".format(intent_result.cancellation_details.reason))
    if intent_result.cancellation_details.reason == speechsdk.CancellationReason.Error:
        print("Error details: {}".format(intent_result.cancellation_details.error_details))
# </IntentRecognitionOnceWithMic>

' ''

...