| Known Direct Subclasses |
The base class of MediaPipe audio tasks.
Public Constructors
|
BaseAudioTaskApi(TaskRunner runner, RunningMode runningMode, String audioStreamName, String sampleRateStreamName)
Constructor to initialize a
BaseAudioTaskApi. |
Public Methods
| void |
close()
Closes and cleans up the MediaPipe audio task.
|
| AudioRecord |
createAudioRecord()
Creates an
AudioRecord instance to record audio stream that has mono
channel at sample rate at sample rate 16kHz, the sample rate required for models like Yamnet. |
| AudioRecord |
createAudioRecord(int numChannels, int sampleRate, int requiredInputBufferSize)
Creates an
AudioRecord instance to record audio stream. |
Inherited Methods
Public Constructors
public BaseAudioTaskApi (TaskRunner runner, RunningMode runningMode, String audioStreamName, String sampleRateStreamName)
Constructor to initialize a BaseAudioTaskApi.
Parameters
| runner | a TaskRunner. |
|---|---|
| runningMode | a mediapipe audio task RunningMode. |
| audioStreamName | the name of the input audio stream. |
| sampleRateStreamName | the name of the audio sample rate stream. |
Public Methods
public void close ()
Closes and cleans up the MediaPipe audio task.
public AudioRecord createAudioRecord ()
Creates an AudioRecord instance to record audio stream that has mono
channel at sample rate at sample rate 16kHz, the sample rate required for models like Yamnet.
The returned AudioRecord instance is initialized and client needs to call AudioRecord.startRecordingnull method to start recording.
Returns
- an
AudioRecordinstance inAudioRecord.STATE_INITIALIZED
Throws
| IllegalArgumentException | if the model required channel count is unsupported |
|---|---|
| IllegalStateException | if AudioRecord instance failed to initialize |
public AudioRecord createAudioRecord (int numChannels, int sampleRate, int requiredInputBufferSize)
Creates an AudioRecord instance to record audio stream. The returned
AudioRecord instance is initialized and client needs to call AudioRecord.startRecordingnull method to start recording.
Note that MediaPipe Audio tasks will up/down sample automatically to fit the sample rate required by the model. The default sample rate of the MediaPipe pretrained audio model, Yamnet, is 16kHz.
Parameters
| numChannels | the number of audio channels. |
|---|---|
| sampleRate | the audio sample rate. |
| requiredInputBufferSize | the required input buffer size in number of float elements. |
Returns
- an
AudioRecordinstance inAudioRecord.STATE_INITIALIZED
Throws
| IllegalArgumentException | if the model required channel count is unsupported |
|---|---|
| IllegalStateException | if AudioRecord instance failed to initialize |