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.
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
open all close allBasic Examples (2)
Test whether an audio signal is an instance of a particular object:
AudioInstanceQ[ExampleData[{"Audio", "DogBark"}], "dog"]AudioInstanceQ[ExampleData[{"Audio", "DogBark"}], "cat"]AudioInstanceQ[Import@"ExampleData/rule30.wav", "guitar"]Test whether an audio signal is an instance of either of the given categories:
AudioInstanceQ[Import@"ExampleData/rule30.wav", "drum" | "guitar"]Scope (1)
By default, no assumptions are made about the sound category of the audio signal:
AudioInstanceQ[Import["ExampleData/rule30.wav"], "guitar"]Assume that the audio signal belongs to a specific sound category:
AudioInstanceQ[Import@"ExampleData/rule30.wav", "guitar", "Musical instrument"]Assume that the audio signal belongs to a specific set of sound categories:
AudioInstanceQ[Import@"ExampleData/rule30.wav", "guitar", "Musical instrument" | "Animal"]Options (3)
AcceptanceThreshold (1)
By default, an automatic acceptance threshold is used:
AudioInstanceQ[ExampleData[{"Audio", "FogHorn"}], "musical instrument"]Specify the acceptance threshold:
AudioInstanceQ[ExampleData[{"Audio", "FogHorn"}], "musical instrument", AcceptanceThreshold -> .4]Masking (1)
By default, the entire audio signal is checked for the specified object:
a = AudioJoin[{ExampleData[{"Audio", "Cat"}], ExampleData[{"Audio", "DogBark"}]}];AudioInstanceQ[a, "cat"]Restrict the test to a specific interval:
AudioInstanceQ[a, "cat", Masking -> {Quantity[1, "Seconds"], Quantity[5, "Seconds"]}]RecognitionPrior (1)
The default RecognitionPrior is 0.5:
AudioInstanceQ[Import@"ExampleData/rule30.wav", "drum" | "guitar"]Assign a very low prior probability to the object to be tested for:
AudioInstanceQ[Import@"ExampleData/rule30.wav", "drum" | "guitar", RecognitionPrior -> 1 / 20]Applications (2)
Find all recordings in the ExampleData collection that are recognized as a musical instrument:
exampleData = AssociationMap[ExampleData, ExampleData["Audio"]];instrumentSounds = Select[exampleData, AudioInstanceQ[#, "musical instrument"]&];Keys[instrumentSounds]Find other sounds that are similar to a recording:
a = ExampleData[{"Audio", "Bird"}];Compute an object identification using AudioIdentify:
obj = AudioIdentify[a]Find sounds with the same identification in the ExampleData collection:
examples = AssociationMap[ExampleData, ExampleData["Audio"]];sameSounds = Select[DeleteCases[examples, a], AudioInstanceQ[#, obj]&];Keys[sameSounds]Compute a list of more general objects using the broader sound property of Entity objects:
categories = obj["BroaderSounds"]Find sounds within broader categories:
broaderSounds = Select[DeleteCases[exampleData, a], AudioInstanceQ[#, Alternatives@@categories]&];Keys[similarSounds]Compute a larger list of related sounds using AudioIdentify:
categories = DeleteDuplicates@Flatten@Values[AudioIdentify[a, All, All, "BroaderSounds"]]Find similar sounds among the ExampleData collection:
similarSounds = Select[DeleteCases[exampleData, a], AudioInstanceQ[#, Alternatives@@categories]&];Keys[similarSounds]Properties & Relations (2)
AudioInstanceQ and AudioIdentify offer complementary functionality:
a = ExampleData[{"Audio", "Drums"}];Compute the most probable object identification:
obj = AudioIdentify[a]Pass the identification to AudioInstanceQ:
AudioInstanceQ[a, obj]Get the probability associated with the identification:
AudioIdentify[a, All, 1, "Probability"]p = First[Values[%]]The minimum acceptable probability corresponds to the confidence in the original identification:
AudioInstanceQ[a, obj, AcceptanceThreshold -> p + $MachineEpsilon]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:
AudioInstanceQ[Audio["ExampleData/rule30.wav"], "animal"]Specify a very low acceptable threshold:
AudioInstanceQ[Audio["ExampleData/rule30.wav"], "animal", AcceptanceThreshold -> .1]Test whether the recording is a guitar, assuming that it belongs to the category of animal sounds:
AudioInstanceQ[Audio["ExampleData/rule30.wav"], "guitar", "animal"]Specifying a very low acceptance threshold will not yield a match since a "guitar" sound is not in the "animal" category:
AudioInstanceQ[Audio["ExampleData/rule30.wav"], "guitar", "animal", AcceptanceThreshold -> .1]Related Guides
History
Text
Wolfram Research (2020), AudioInstanceQ, Wolfram Language function, https://reference.wolfram.com/language/ref/AudioInstanceQ.html.
CMS
Wolfram Language. 2020. "AudioInstanceQ." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/AudioInstanceQ.html.
APA
Wolfram Language. (2020). AudioInstanceQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/AudioInstanceQ.html
BibTeX
@misc{reference.wolfram_2026_audioinstanceq, author="Wolfram Research", title="{AudioInstanceQ}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/AudioInstanceQ.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_audioinstanceq, organization={Wolfram Research}, title={AudioInstanceQ}, year={2020}, url={https://reference.wolfram.com/language/ref/AudioInstanceQ.html}, note=[Accessed: 13-June-2026]}