New Azure free account - AI Translator resource 2M free requests per month - profanity filter cannot be turned off

Steve 0 Reputation points
2023-09-21T10:13:01.29+00:00

I made a new free tier Azure account with the $200 free credit. I'm attempting to test the Microsoft.CognitiveServicesTextTranslation service 2M free character translations per month, however profanity words are being deleted. Eg, a sentence such as "(profane word) there" is simply translated to "there".

According to https://learn.microsoft.com/en-us/azure/ai-services/translator/profanity-filtering the default behaviour is that profanity isn't deleted. However the behaviour I'm experiencing is as if "ProfanityAction value" is set to "Deleted".

As a potential work-around I explicitly tested setting the ProfanityAction in the http request to both NoAction and, after that did nothing, to Marked, however neither of these things worked, the same behaviour resulted in that profanity is simply removed, no asterisk replacing it, no profanity retained, just the profanity being removed as if these header's are being ignored altogether.

Any idea what's going on? Allowing profanity is essential for the service I intend to work on and is something that will be handled on my end, I don't wish for Azure to handle it.

Thanks

Azure Translator
Azure Translator
An Azure service to easily conduct machine translation with a simple REST API call.
388 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Steve 0 Reputation points
    2023-09-21T20:51:45.4433333+00:00

    Thank you @VasaviLankipalle-MSFT

    Please find below an example translation from Japanese to English in my python script (I've omitted my key but can provide this if required privately) -

    import requests
    
    def translate_text_external(text, show_status = True):
        # Set your Azure subscription key and endpoint
        subscription_key = "(removed)"
        endpoint = "https://api.cognitive.microsofttranslator.com/"
        path = '/translate'
        constructed_url = endpoint + path
    
        # Add your text to translate here
        body = [{'text': text}]
    
        # Set the translation parameters
        params = {
            'api-version': '3.0',
            'from': 'ja',
            'to': 'en'
        }
        headers = {
            'Ocp-Apim-Subscription-Key': subscription_key,
            'Ocp-Apim-Subscription-Region' : 'eastus',
            'Content-type': 'application/json'
        }
    
        # Make the API request
        request = requests.post(constructed_url, params=params, headers=headers, json=body)
    
        # Check for errors
        if request.status_code != 200:
            print("Error with request:")
            print(request.json())
            return None
    
        response = request.json()
    
        # Extract the translated text
        try:
            translated_text = response[0]['translations'][0]['text']
            if show_status:
                print(f"translated: {translated_text}")
            return translated_text
        except KeyError:
            print("Unexpected response format:")
            print(response)
            return None
    
    translate_text_external("あなたをファック")
    
    
    

    The translation is only returning "You" for example, whereas in the Bing translator at https://www.bing.com/translator the proper sentence is being returned without omissions.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.