Class AudioConfig
- java.lang.Object
-
- com.microsoft.cognitiveservices.speech.audio.AudioConfig
-
- All Implemented Interfaces:
AutoCloseable
public final class AudioConfig extends Object implements 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Explicitly frees any external resource attached to the objectstatic AudioConfigfromDefaultMicrophoneInput()Creates an AudioConfig object representing the default microphone on the system.static AudioConfigfromDefaultMicrophoneInput(AudioProcessingOptions audioProcessingOptions)Creates an AudioConfig object representing the default microphone on the system.static AudioConfigfromDefaultSpeakerOutput()Creates an AudioConfig object representing the default speaker on the system.static AudioConfigfromMicrophoneInput(String deviceName)Creates an AudioConfig object representing a specific microphone on the system.static AudioConfigfromMicrophoneInput(String deviceName, AudioProcessingOptions audioProcessingOptions)Creates an AudioConfig object representing a specific microphone on the system.static AudioConfigfromSpeakerOutput(String deviceName)Creates an AudioConfig object representing a specific speaker on the system.static AudioConfigfromStreamInput(AudioInputStream audioStream)Creates an AudioConfig object representing the specified stream.static AudioConfigfromStreamInput(AudioInputStream audioStream, AudioProcessingOptions audioProcessingOptions)Creates an AudioConfig object representing the specified stream.static AudioConfigfromStreamInput(PullAudioInputStreamCallback callback)Creates an AudioConfig object representing the specified stream.static AudioConfigfromStreamInput(PullAudioInputStreamCallback callback, AudioProcessingOptions audioProcessingOptions)Creates an AudioConfig object representing the specified stream.static AudioConfigfromStreamOutput(AudioOutputStream audioStream)Creates an AudioConfig object representing the specified stream.static AudioConfigfromWavFileInput(String fileName)Creates an AudioConfig object representing the specified file.static AudioConfigfromWavFileInput(String fileName, AudioProcessingOptions audioProcessingOptions)Creates an AudioConfig object representing the specified file.static AudioConfigfromWavFileOutput(String fileName)Creates an AudioConfig object representing the specified file.AudioProcessingOptionsgetAudioProcessingOptions()Returns an AudioProcessingOptions object which contains the parameters used for audio processing.SafeHandlegetImpl()Returns the audio input configuration.voidsetProperty(PropertyId id, String value)Sets the property by propertyId.voidsetProperty(String name, String value)Sets a named property as value.
-
-
-
Method Detail
-
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.
-
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.
-
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.
-
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.
-
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.
-
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.
-
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.
-
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.
-
getAudioProcessingOptions
public AudioProcessingOptions getAudioProcessingOptions()
Returns an AudioProcessingOptions object which contains the parameters used for audio processing.- Returns:
- The audio processing options.
-
close
public void close()
Explicitly frees any external resource attached to the object- Specified by:
closein interfaceAutoCloseable
-
setProperty
public void setProperty(String name, String value)
Sets a named property as value.- Parameters:
name- the name of the property.value- the value.
-
setProperty
public void setProperty(PropertyId id, String value)
Sets the property by propertyId.- Parameters:
id- PropertyId of the property.value- The value.
-
getImpl
public SafeHandle getImpl()
Returns the audio input configuration.- Returns:
- The implementation of the config.
-
-