---
title: "AudioInstanceQ"
language: "en"
type: "Symbol"
summary: "AudioInstanceQ[audio, obj] gives True if audio sounds to be an instance of the object obj, and gives False otherwise. AudioInstanceQ[audio, obj, cat] assumes that audio is the sound of something in the category cat."
keywords: 
- sample audio
- audio instance
- sample sound
- sound instance
- instance of a thing
- audio of
- audio identification
- sound identification
- sound recognition
- audioset
- audio class
- sound class
- audio understanding
- audio analysis
- sound category
- audio category
canonical_url: "https://reference.wolfram.com/language/ref/AudioInstanceQ.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Video Computation: Update History"
    link: "https://reference.wolfram.com/language/guide/VideoComputation-UpdateHistory.en.md"
  - 
    title: "Audio Processing"
    link: "https://reference.wolfram.com/language/guide/AudioProcessing.en.md"
  - 
    title: "Audio Analysis"
    link: "https://reference.wolfram.com/language/guide/AudioAnalysis.en.md"
related_functions: 
  - 
    title: "AudioIdentify"
    link: "https://reference.wolfram.com/language/ref/AudioIdentify.en.md"
  - 
    title: "SpeechInterpreter"
    link: "https://reference.wolfram.com/language/ref/SpeechInterpreter.en.md"
  - 
    title: "SpeechCases"
    link: "https://reference.wolfram.com/language/ref/SpeechCases.en.md"
  - 
    title: "SpeechRecognize"
    link: "https://reference.wolfram.com/language/ref/SpeechRecognize.en.md"
  - 
    title: "SpeakerMatchQ"
    link: "https://reference.wolfram.com/language/ref/SpeakerMatchQ.en.md"
  - 
    title: "Classify"
    link: "https://reference.wolfram.com/language/ref/Classify.en.md"
  - 
    title: "MemberQ"
    link: "https://reference.wolfram.com/language/ref/MemberQ.en.md"
  - 
    title: "ImageInstanceQ"
    link: "https://reference.wolfram.com/language/ref/ImageInstanceQ.en.md"
---
[EXPERIMENTAL]

# AudioInstanceQ

AudioInstanceQ[audio, obj] gives True if audio sounds to be an instance of the object obj, and gives False otherwise.

AudioInstanceQ[audio, obj, cat] assumes that audio is the sound of something in the category cat.

## Details and Options

* ``AudioInstanceQ`` tries to identify whether an audio signal is an instance of a given category.

* Possible forms for both object ``obj`` and category ``cat`` are:

|                             |                                                |
| --------------------------- | ---------------------------------------------- |
| "class"                     | named sound class, as used in "Sound" entities |
| Entity[…]                   | any appropriate entity                         |
| instance1 \| instance2 \| … | any of the instancei                           |

* The following options can be given:

|                      |           |                                            |
| -------------------- | --------- | ------------------------------------------ |
| AcceptanceThreshold  | Automatic | minimum probability to consider acceptable |
| Masking              | All       | interval of interest                       |
| PerformanceGoal      | Automatic | what to optimize in the identification     |
| RecognitionPrior     | 0.5       | prior probability for a True result        |
| TargetDevice         | "CPU"     | the target device on which to compute      |

* ``AudioInstanceQ`` uses machine learning. Its methods, training sets and biases included therein may change and yield varied results in different versions of the Wolfram Language.

* ``AudioInstanceQ`` may download resources that will be stored in your local object store at ``\$LocalBase``, and can be listed using ``LocalObjects[]`` and removed using ``ResourceRemove``.

---

## Examples (10)

### Basic Examples (2)

Test whether an audio signal is an instance of a particular object:

```wl
In[1]:= AudioInstanceQ[ExampleData[{"Audio", "DogBark"}], "dog"]

Out[1]= True

In[2]:= AudioInstanceQ[ExampleData[{"Audio", "DogBark"}], "cat"]

Out[2]= False

In[3]:= AudioInstanceQ[Import@"ExampleData/rule30.wav", "guitar"]

Out[3]= True
```

---

Test whether an audio signal is an instance of either of the given categories:

```wl
In[1]:= AudioInstanceQ[Import@"ExampleData/rule30.wav", "drum" | "guitar"]

Out[1]= True
```

### Scope (1)

By default, no assumptions are made about the sound category of the audio signal:

```wl
In[1]:= AudioInstanceQ[Import["ExampleData/rule30.wav"], "guitar"]

Out[1]= True
```

Assume that the audio signal belongs to a specific sound category:

```wl
In[2]:= AudioInstanceQ[Import@"ExampleData/rule30.wav", "guitar", "Musical instrument"]

Out[2]= True
```

Assume that the audio signal belongs to a specific set of sound categories:

```wl
In[3]:= AudioInstanceQ[Import@"ExampleData/rule30.wav", "guitar", "Musical instrument" | "Animal"]

Out[3]= True
```

### Options (3)

#### AcceptanceThreshold (1)

By default, an automatic acceptance threshold is used:

```wl
In[1]:= AudioInstanceQ[ExampleData[{"Audio", "FogHorn"}], "musical instrument"]

Out[1]= False
```

Specify the acceptance threshold:

```wl
In[2]:= AudioInstanceQ[ExampleData[{"Audio", "FogHorn"}], "musical instrument", AcceptanceThreshold -> .4]

Out[2]= True
```

#### Masking (1)

By default, the entire audio signal is checked for the specified object:

```wl
In[1]:= a = AudioJoin[{ExampleData[{"Audio", "Cat"}], ExampleData[{"Audio", "DogBark"}]}];

In[2]:= AudioInstanceQ[a, "cat"]

Out[2]= True
```

Restrict the test to a specific interval:

```wl
In[3]:= AudioInstanceQ[a, "cat", Masking -> {Quantity[1, "Seconds"], Quantity[5, "Seconds"]}]

Out[3]= False
```

#### RecognitionPrior (1)

The default ``RecognitionPrior`` is 0.5:

```wl
In[1]:= AudioInstanceQ[Import@"ExampleData/rule30.wav", "drum" | "guitar"]

Out[1]= True
```

Assign a very low prior probability to the object to be tested for:

```wl
In[2]:= AudioInstanceQ[Import@"ExampleData/rule30.wav", "drum" | "guitar", RecognitionPrior -> 1 / 20]

Out[2]= False
```

### Applications (2)

Find all recordings in the ``ExampleData`` collection that are recognized as a musical instrument:

```wl
In[1]:= exampleData = AssociationMap[ExampleData, ExampleData["Audio"]];

In[2]:= instrumentSounds = Select[exampleData, AudioInstanceQ[#, "musical instrument"]&];

In[3]:= Keys[instrumentSounds]

Out[3]= {{"Audio", "Cello"}, {"Audio", "CelloScale"}, {"Audio", "ChurchBell"}, {"Audio", "CreakyDoor"}, {"Audio", "Drums"}, {"Audio", "Flute"}, {"Audio", "FluteScale"}, {"Audio", "Piano"}, {"Audio", "PianoScale"}, {"Audio", "ThaiBells"}}
```

---

Find other sounds that are similar to a recording:

```wl
In[1]:= a = ExampleData[{"Audio", "Bird"}];
```

Compute an object identification using ``AudioIdentify`` :

```wl
In[2]:= obj = AudioIdentify[a]

Out[2]= Entity["Sound", "ChirpTweet::9f9m7"]
```

Find sounds with the same identification in the ``ExampleData`` collection:

```wl
In[3]:= examples = AssociationMap[ExampleData, ExampleData["Audio"]];

In[4]:= sameSounds = Select[DeleteCases[examples, a], AudioInstanceQ[#, obj]&];

In[5]:= Keys[sameSounds]

Out[5]= {{"Audio", "BlackcapWarbler"}}
```

Compute a list of more general objects using the broader sound property of ``Entity`` objects:

```wl
In[6]:= categories = obj["BroaderSounds"]

Out[6]= {Entity["Sound", "BirdVocalizationBirdCallBirdSong::4852z"], Entity["Sound", "BriefTone::2qxg6"]}
```

Find sounds within broader categories:

```wl
In[7]:= broaderSounds = Select[DeleteCases[exampleData, a], AudioInstanceQ[#, Alternatives@@categories]&];

In[8]:= Keys[similarSounds]

Out[8]= {{"Audio", "BlackcapWarbler"}, {"Audio", "ThaiBells"}}
```

Compute a larger list of related sounds using ``AudioIdentify`` :

```wl
In[9]:= categories = DeleteDuplicates@Flatten@Values[AudioIdentify[a, All, All, "BroaderSounds"]]

Out[9]= {Entity["Sound", "BirdVocalizationBirdCallBirdSong::4852z"], Entity["Sound", "BriefTone::2qxg6"], Entity["Sound", "WildAnimals::xk99z"], Entity["Sound", "Cat::5yr44"]}
```

Find similar sounds among the ``ExampleData`` collection:

```wl
In[10]:= similarSounds = Select[DeleteCases[exampleData, a], AudioInstanceQ[#, Alternatives@@categories]&];

In[11]:= Keys[similarSounds]

Out[11]= {{"Audio", "Bee"}, {"Audio", "BlackcapWarbler"}, {"Audio", "Cat"}, {"Audio", "ThaiBells"}}
```

### Properties & Relations (2)

``AudioInstanceQ`` and ``AudioIdentify`` offer complementary functionality:

```wl
In[1]:= a = ExampleData[{"Audio", "Drums"}];
```

Compute the most probable object identification:

```wl
In[2]:= obj = AudioIdentify[a]

Out[2]= Entity["Sound", "BassDrum::3nd28"]
```

Pass the identification to ``AudioInstanceQ`` :

```wl
In[3]:= AudioInstanceQ[a, obj]

Out[3]= True
```

Get the probability associated with the identification:

```wl
In[4]:= AudioIdentify[a, All, 1, "Probability"]

Out[4]= <|Entity["Sound", "BassDrum::3nd28"] -> 0.769502|>

In[5]:= p = First[Values[%]]

Out[5]= 0.769502
```

The minimum acceptable probability corresponds to the confidence in the original identification:

```wl
In[6]:= AudioInstanceQ[a, obj, AcceptanceThreshold -> p + $MachineEpsilon]

Out[6]= False
```

---

Specifying a minimum acceptable probability for the tested-for object will have no effect if the tested-for object does not belong to one of the assumed categories, if specified.

Test whether a recording of an acoustic guitar is an animal:

```wl
In[1]:= AudioInstanceQ[Audio["ExampleData/rule30.wav"], "animal"]

Out[1]= False
```

Specify a very low acceptable threshold:

```wl
In[2]:= AudioInstanceQ[Audio["ExampleData/rule30.wav"], "animal", AcceptanceThreshold -> .1]

Out[2]= True
```

Test whether the recording is a guitar, assuming that it belongs to the category of animal sounds:

```wl
In[3]:= AudioInstanceQ[Audio["ExampleData/rule30.wav"], "guitar", "animal"]

Out[3]= False
```

Specifying a very low acceptance threshold will not yield a match since a "guitar" sound is not in the "animal" category:

```wl
In[4]:= AudioInstanceQ[Audio["ExampleData/rule30.wav"], "guitar", "animal", AcceptanceThreshold -> .1]

Out[4]= False
```

## See Also

* [`AudioIdentify`](https://reference.wolfram.com/language/ref/AudioIdentify.en.md)
* [`SpeechInterpreter`](https://reference.wolfram.com/language/ref/SpeechInterpreter.en.md)
* [`SpeechCases`](https://reference.wolfram.com/language/ref/SpeechCases.en.md)
* [`SpeechRecognize`](https://reference.wolfram.com/language/ref/SpeechRecognize.en.md)
* [`SpeakerMatchQ`](https://reference.wolfram.com/language/ref/SpeakerMatchQ.en.md)
* [`Classify`](https://reference.wolfram.com/language/ref/Classify.en.md)
* [`MemberQ`](https://reference.wolfram.com/language/ref/MemberQ.en.md)
* [`ImageInstanceQ`](https://reference.wolfram.com/language/ref/ImageInstanceQ.en.md)

## Related Guides

* [Video Computation: Update History](https://reference.wolfram.com/language/guide/VideoComputation-UpdateHistory.en.md)
* [Audio Processing](https://reference.wolfram.com/language/guide/AudioProcessing.en.md)
* [Audio Analysis](https://reference.wolfram.com/language/guide/AudioAnalysis.en.md)

## History

* [Introduced in 2020 (12.1)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn121.en.md)