> ## Documentation Index
> Fetch the complete documentation index at: https://assemblyai.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Profanity Filtering

export const LanguageTable = ({languages, columns = 3}) => {
  return <div className="grid gap-2" style={{
    gridTemplateColumns: `repeat(${columns}, 1fr)`
  }}>
      {languages.map(language => <div key={language.code} className="flex justify-between items-center">
          <span>{language.name}</span>
          <code className="text-sm bg-gray-100 px-2 py-1 rounded">
            {language.code}
          </code>
        </div>)}
    </div>;
};

<Tip>
  **Streaming profanity filtering**

  For real-time profanity filtering on streaming transcripts, see [Filter profanity](/streaming/filter-profanity-from-transcripts).
</Tip>

<AccordionGroup>
  <Accordion title="Supported languages">
    <LanguageTable
      languages={[
  { name: "Global English", code: "en" },
  { name: "Australian English", code: "en_au" },
  { name: "British English", code: "en_uk" },
  { name: "US English", code: "en_us" },
  { name: "Spanish", code: "es" },
  { name: "French", code: "fr" },
  { name: "German", code: "de" },
  { name: "Italian", code: "it" },
  { name: "Portuguese", code: "pt" },
  { name: "Dutch", code: "nl" },
  { name: "Hindi", code: "hi" },
  { name: "Japanese", code: "ja" },
]}
      columns={2}
    />

    <br />
  </Accordion>

  <Accordion title="Supported models">
    <LanguageTable
      languages={[
  { name: "Universal-3 Pro", code: "universal-3-pro" },
  { name: "Universal-2", code: "universal-2" },
]}
      columns={2}
    />

    <br />
  </Accordion>

  <Accordion title="Supported regions">
    US & EU <br />
  </Accordion>
</AccordionGroup>

You can automatically filter out profanity from the transcripts by setting `filter_profanity` to `true` in your transcription config.

Any profanity in the returned `text` will be replaced with asterisks.

<CodeGroup>
  ```python title="Python SDK" highlight={8}  theme={null}
  import assemblyai as aai

  aai.settings.api_key = "<YOUR_API_KEY>"

  # audio_file = "./local_file.mp3"
  audio_file = "https://assembly.ai/wildfires.mp3"

  config = aai.TranscriptionConfig(
      speech_models=["universal-3-pro", "universal-2"],
      language_detection=True,
      filter_profanity=True
  )

  transcript = aai.Transcriber(config=config).transcribe(audio_file)

  if transcript.status == "error":
    raise RuntimeError(f"Transcription failed: {transcript.error}")

  print(transcript.text)
  ```

  ```python title="Python" highlight={19}  expandable theme={null}
  import requests
  import time

  base_url = "https://api.assemblyai.com"

  headers = {
      "authorization": "<YOUR_API_KEY>"
  }

  with open("./my-audio.mp3", "rb") as f:
    response = requests.post(base_url + "/v2/upload",
                            headers=headers,
                            data=f)

  upload_url = response.json()["upload_url"]

  data = {
      "audio_url": upload_url, # You can also use a URL to an audio or video file on the web
      "speech_models": ["universal-3-pro", "universal-2"],
      "language_detection": True,
      "filter_profanity": True
  }

  url = base_url + "/v2/transcript"
  response = requests.post(url, json=data, headers=headers)

  transcript_id = response.json()['id']
  polling_endpoint = base_url + "/v2/transcript/" + transcript_id

  while True:
    transcription_result = requests.get(polling_endpoint, headers=headers).json()

    if transcription_result['status'] == 'completed':
      print(f"Transcript ID: {transcript_id}")
      break

    elif transcription_result['status'] == 'error':
      raise RuntimeError(f"Transcription failed: {transcription_result['error']}")

    else:
      time.sleep(3)

  ```

  ```javascript title="JavaScript SDK" highlight={12}  expandable theme={null}
  import { AssemblyAI } from "assemblyai";

  const client = new AssemblyAI({
    apiKey: "<YOUR_API_KEY>",
  });

  // const audioFile = './local_file.mp3'
  const audioFile = "https://assembly.ai/wildfires.mp3";

  const params = {
    audio: audioFile,
    speech_models: ["universal-3-pro", "universal-2"],
    language_detection: true,
    filter_profanity: true,
  };

  const run = async () => {
    const transcript = await client.transcripts.transcribe(params);

    console.log(transcript.text);
  };

  run();
  ```

  ```javascript title="JavaScript" highlight={19}  expandable theme={null}
  import fs from "fs-extra";

  const baseUrl = "https://api.assemblyai.com";

  const headers = {
    authorization: "<YOUR_API_KEY>",
  };

  const path = "./my-audio.mp3";
  const audioData = await fs.readFile(path);
  let res = await fetch(`${baseUrl}/v2/upload`, {
    method: "POST",
    headers,
    body: audioData,
  });
  if (!res.ok) throw new Error(`Error: ${res.status}`);
  const uploadResponse = await res.json();
  const uploadUrl = uploadResponse.upload_url;

  const data = {
    audio_url: uploadUrl, // You can also use a URL to an audio or video file on the web
    speech_models: ["universal-3-pro", "universal-2"],
    language_detection: true,
    filter_profanity: true,
  };

  const url = `${baseUrl}/v2/transcript`;
  res = await fetch(url, {
    method: "POST",
    headers: { ...headers, "Content-Type": "application/json" },
    body: JSON.stringify(data),
  });
  if (!res.ok) throw new Error(`Error: ${res.status}`);
  const response = await res.json();

  const transcriptId = response.id;
  const pollingEndpoint = `${baseUrl}/v2/transcript/${transcriptId}`;

  while (true) {
    res = await fetch(pollingEndpoint, { headers });
    if (!res.ok) throw new Error(`Error: ${res.status}`);
    const transcriptionResult = await res.json();

    if (transcriptionResult.status === "completed") {
      console.log(transcriptionResult.text);
      break;
    } else if (transcriptionResult.status === "error") {
      throw new Error(`Transcription failed: ${transcriptionResult.error}`);
    } else {
      await new Promise((resolve) => setTimeout(resolve, 3000));
    }
  }
  ```
</CodeGroup>

<Note>
  Profanity filter isn't perfect. Certain words may still be missed or
  improperly filtered.
</Note>
