Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.25k stars 4.59k forks source link

[BUG] Cognitive Speech: Unable to set profanity filter #36133

Open sebllll opened 1 year ago

sebllll commented 1 year ago

Library name and version

Microsoft.CognitiveServices.Speech 1.28.0

Describe the bug

SpeechConfig.SetProfanity(ProfanityOption) has no effect when using Intentrecognizer.

Expected behavior

I expect the same effect for all recognizers.

When setting up a SpeechConfig, i did set the Profanity like so:

SpeechConfig.SetProfanity(ProfanityOption.Raw)

So far so good - when using the speechConfig for a Speechrecognizer.

But when using an intentrecognizer instead of the speechrecognizer, the setting has no effect no matter which enum i select.

Actual behavior

SpeechConfig.SetProfanity(ProfanityOption) has no effect (in case of being used in an intentrecognizer)

Reproduction Steps

note: this is pseudocode based on the ms examples. just for illustration

static string speechKey = Environment.GetEnvironmentVariable("SPEECH_KEY");
static string speechRegion = Environment.GetEnvironmentVariable("SPEECH_REGION");

var speechConfig = SpeechConfig.FromSubscription(speechKey, speechRegion);        
speechConfig.SpeechRecognitionLanguage = "en-US";
speechConfig.SetProfanity(ProfanityOption.Raw);

using var audioConfig = AudioConfig.FromDefaultMicrophoneInput();
using var speechRecognizer = new SpeechRecognizer(speechConfig, audioConfig);

Console.WriteLine("Speak into your microphone.");
var speechRecognitionResult = await speechRecognizer.RecognizeOnceAsync();

this is correct, the output is conforming the profanityOption

static string languageKey = Environment.GetEnvironmentVariable("LANGUAGE_KEY");
static string languageEndpoint = Environment.GetEnvironmentVariable("LANGUAGE_ENDPOINT");
static string speechKey = Environment.GetEnvironmentVariable("SPEECH_KEY");
static string speechRegion = Environment.GetEnvironmentVariable("SPEECH_REGION");

using var audioConfig = AudioConfig.FromDefaultMicrophoneInput();
using var intentRecognizer = new IntentRecognizer(speechConfig, audioConfig)

var cluModel = new ConversationalLanguageUnderstandingModel(
languageKey,
languageEndpoint,
cluProjectName, 
cluDeploymentName);
var collection = new LanguageUnderstandingModelCollection();
collection.Add(cluModel);
intentRecognizer.ApplyLanguageModels(collection);

Console.WriteLine("Speak into your microphone.");
var intentRecognitionResult = await intentRecognizer.RecognizeOnceAsync();

this is not correct, the output is ignoring the profanityOption

Environment

Win 10 and Win 11

Visual Studio 17.3.3 (among others)

dotnet sdk 6.0.403 (among others)

The issue is existent at least since version 1.23.0 of the package. At least i started developing with that version and had the issue since then.

github-actions[bot] commented 1 year ago

Thank you for your feedback. This has been routed to the support team for assistance.

navba-MSFT commented 1 year ago

Adding Service team to look into this.

github-actions[bot] commented 1 year ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @robch.