AudioConfig Class

Represents audio input or output configuration. Audio input can be from a microphone, file, or input stream. Audio output can be to a speaker, audio file output in WAV format, or output stream.

Generates an audio configuration for the various recognizers. Only one argument can be passed at a time.

Inheritance
builtins.object
AudioConfig

Constructor

AudioConfig(use_default_microphone: bool = False, filename: str | None = None, stream: AudioInputStream | None = None, device_name: str | None = None)

Parameters

Name Description
use_default_microphone

Specifies to use the default system microphone for audio input.

Default value: False
device_name

Specifies the id of the audio device to use. Please refer to this page on how to retrieve platform-specific microphone names. This functionality was added in version 1.3.0.

Default value: None
filename

Specifies an audio input file.

Default value: None
stream

Creates an AudioConfig object representing the specified stream.

Default value: None

Methods

get_property

Get a property by id.

get_property_by_name

Get a property by name.

set_properties

Set multiple properties by id.

set_properties_by_name

Set multiple properties by name.

set_property

Set a property by id.

set_property_by_name

Set a property by name.

get_property

Get a property by id.

get_property(property_id: PropertyId) -> str

Parameters

Name Description
property_id
Required

The id of the property to be retrieved.

Returns

Type Description

The value of the property.

get_property_by_name

Get a property by name.

get_property_by_name(property_name: str) -> str

Parameters

Name Description
property_name
Required

The name of the property to be retrieved.

Returns

Type Description

The value of the property.

set_properties

Set multiple properties by id.

set_properties(properties: Dict[PropertyId, str])

Parameters

Name Description
properties
Required

A dict mapping property ids to the values to be set.

set_properties_by_name

Set multiple properties by name.

set_properties_by_name(properties: Dict[str, str])

Parameters

Name Description
properties
Required

A dict mapping property ids to the values to be set.

set_property

Set a property by id.

set_property(property_id: PropertyId, value: str)

Parameters

Name Description
property_id
Required

The id of the property to be set.

value
Required

The value to be set for the property.

set_property_by_name

Set a property by name.

set_property_by_name(property_name: str, value: str)

Parameters

Name Description
property_name
Required

The name of the property to be set.

value
Required

The value to be set for the property.