다음을 통해 공유


AudioConfig Class

  • java.lang.Object
    • com.microsoft.cognitiveservices.speech.audio.AudioConfig

Implements

java.lang.AutoCloseable

public final class AudioConfig
implements java.lang.AutoCloseable

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. Note: close() must be called in order to release underlying resources held by the object. Updated in version 1.7.0

Method Summary

Modifier and Type Method and Description
void close()

Explicitly frees any external resource attached to the object

static AudioConfig fromDefaultMicrophoneInput()

Creates an AudioConfig object representing the default microphone on the system.

static AudioConfig fromDefaultMicrophoneInput(AudioProcessingOptions audioProcessingOptions)

Creates an AudioConfig object representing the default microphone on the system.

static AudioConfig fromDefaultSpeakerOutput()

Creates an AudioConfig object representing the default speaker on the system.

static AudioConfig fromMicrophoneInput(String deviceName)

Creates an AudioConfig object representing a specific microphone on the system.

static AudioConfig fromMicrophoneInput(String deviceName, AudioProcessingOptions audioProcessingOptions)

Creates an AudioConfig object representing a specific microphone on the system.

static AudioConfig fromSpeakerOutput(String deviceName)

Creates an AudioConfig object representing a specific speaker on the system.

static AudioConfig fromStreamInput(AudioInputStream audioStream)

Creates an AudioConfig object representing the specified stream.

static AudioConfig fromStreamInput(AudioInputStream audioStream, AudioProcessingOptions audioProcessingOptions)

Creates an AudioConfig object representing the specified stream.

static AudioConfig fromStreamInput(PullAudioInputStreamCallback callback)

Creates an AudioConfig object representing the specified stream.

static AudioConfig fromStreamInput(PullAudioInputStreamCallback callback, AudioProcessingOptions audioProcessingOptions)

Creates an AudioConfig object representing the specified stream.

static AudioConfig fromStreamOutput(AudioOutputStream audioStream)

Creates an AudioConfig object representing the specified stream.

static AudioConfig fromWavFileInput(String fileName)

Creates an AudioConfig object representing the specified file.

static AudioConfig fromWavFileInput(String fileName, AudioProcessingOptions audioProcessingOptions)

Creates an AudioConfig object representing the specified file.

static AudioConfig fromWavFileOutput(String fileName)

Creates an AudioConfig object representing the specified file.

AudioProcessingOptions getAudioProcessingOptions()

Returns an AudioProcessingOptions object which contains the parameters used for audio processing.

SafeHandle getImpl()

Returns the audio input configuration.

void setProperty(PropertyId id, String value)

Sets the property by propertyId.

void setProperty(String name, String value)

Sets a named property as value.

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Method Details

close

public void close()

Explicitly frees any external resource attached to the object

fromDefaultMicrophoneInput

public static AudioConfig fromDefaultMicrophoneInput()

Creates an AudioConfig object representing the default microphone on the system.

Returns:

The audio input configuration being created.

fromDefaultMicrophoneInput

public static AudioConfig fromDefaultMicrophoneInput(AudioProcessingOptions audioProcessingOptions)

Creates an AudioConfig object representing the default microphone on the system.

Parameters:

audioProcessingOptions - Specifies the audio processing options.

Returns:

The audio input configuration being created.

fromDefaultSpeakerOutput

public static AudioConfig fromDefaultSpeakerOutput()

Creates an AudioConfig object representing the default speaker on the system. Added in version 1.7.0

Returns:

The audio output configuration being created.

fromMicrophoneInput

public static AudioConfig fromMicrophoneInput(String deviceName)

Creates an AudioConfig object representing a specific microphone on the system.

Parameters:

deviceName - Specifies the platform-specific id of the audio input device. Please refer to the the online documentation about how to retrieve that id on different platforms. This functionality was added in version 1.3.0.

Returns:

The audio input configuration being created.

fromMicrophoneInput

public static AudioConfig fromMicrophoneInput(String deviceName, AudioProcessingOptions audioProcessingOptions)

Creates an AudioConfig object representing a specific microphone on the system.

Parameters:

deviceName - Specifies the platform-specific id of the audio input device. Please refer to the the online documentation about how to retrieve that id on different platforms.
audioProcessingOptions - Specifies the audio processing options.

Returns:

The audio input configuration being created.

fromSpeakerOutput

public static AudioConfig fromSpeakerOutput(String deviceName)

Creates an AudioConfig object representing a specific speaker on the system.

Parameters:

deviceName - Specifies the platform-specific id of the audio output device. Added in version 1.17.0

Returns:

The audio output configuration being created.

fromStreamInput

public static AudioConfig fromStreamInput(AudioInputStream audioStream)

Creates an AudioConfig object representing the specified stream.

Parameters:

audioStream - Specifies the custom audio input stream.

Returns:

The audio input configuration being created.

fromStreamInput

public static AudioConfig fromStreamInput(AudioInputStream audioStream, AudioProcessingOptions audioProcessingOptions)

Creates an AudioConfig object representing the specified stream.

Parameters:

audioStream - Specifies the custom audio input stream.
audioProcessingOptions - Specifies the audio processing options.

Returns:

The audio input configuration being created.

fromStreamInput

public static AudioConfig fromStreamInput(PullAudioInputStreamCallback callback)

Creates an AudioConfig object representing the specified stream.

Parameters:

callback - Specifies the pull audio input stream callback.

Returns:

The audio input configuration being created.

fromStreamInput

public static AudioConfig fromStreamInput(PullAudioInputStreamCallback callback, AudioProcessingOptions audioProcessingOptions)

Creates an AudioConfig object representing the specified stream.

Parameters:

callback - Specifies the pull audio input stream callback.
audioProcessingOptions - Specifies the audio processing options.

Returns:

The audio input configuration being created.

fromStreamOutput

public static AudioConfig fromStreamOutput(AudioOutputStream audioStream)

Creates an AudioConfig object representing the specified stream. Added in version 1.7.0

Parameters:

audioStream - Specifies the custom audio output stream.

Returns:

The audio output configuration being created.

fromWavFileInput

public static AudioConfig fromWavFileInput(String fileName)

Creates an AudioConfig object representing the specified file.

Parameters:

fileName - Specifies the audio input file.

Returns:

The audio input configuration being created.

fromWavFileInput

public static AudioConfig fromWavFileInput(String fileName, AudioProcessingOptions audioProcessingOptions)

Creates an AudioConfig object representing the specified file.

Parameters:

fileName - Specifies the audio input file.
audioProcessingOptions - Specifies the audio processing options.

Returns:

The audio input configuration being created.

fromWavFileOutput

public static AudioConfig fromWavFileOutput(String fileName)

Creates an AudioConfig object representing the specified file. Added in version 1.7.0

Parameters:

fileName - Specifies the audio output file. The parent directory must already exist.

Returns:

The audio output configuration being created.

getAudioProcessingOptions

public AudioProcessingOptions getAudioProcessingOptions()

Returns an AudioProcessingOptions object which contains the parameters used for audio processing.

Returns:

The audio processing options.

getImpl

public SafeHandle getImpl()

Returns the audio input configuration.

Returns:

The implementation of the config.

setProperty

public void setProperty(PropertyId id, String value)

Sets the property by propertyId.

Parameters:

id - PropertyId of the property.
value - The value.

setProperty

public void setProperty(String name, String value)

Sets a named property as value.

Parameters:

name - the name of the property.
value - the value.

Applies to