AiliaSpeech

class AiliaSpeech(envId: Int = -1, numThread: Int = 0, memoryMode: Int = 11, task: Int = AILIA_SPEECH_TASK_TRANSCRIBE, flags: Int = AILIA_SPEECH_FLAG_NONE)

Speech recognition for audio waveforms.

This class provides speech to text conversion (Whisper and SenseVoice), voice activity detection, speaker diarization and post processing such as translation via the ailia Speech native library.

Feed the audio waveform with pushInputData, notify the end of the input with finalizeInputData, then call transcribe while getBuffered returns 1 and get the results with getText. getComplete returns 1 when all of the input has been processed.

Parameters

envId

Environment id of the ailia execution. -1 (ENVIRONMENT_ID_AUTO) selects the environment automatically.

numThread

Number of threads. 0 (MULTITHREAD_AUTO) means the system's logical processor count.

memoryMode

Memory management mode of the ailia execution. The default value 11 reduces the memory consumption.

task

Task of the recognition, one of the AILIA_SPEECH_TASK_* constants.

flags

Flags of the recognition, one of the AILIA_SPEECH_FLAG_* constants.

Constructors

Link copied to clipboard
constructor(envId: Int = -1, numThread: Int = 0, memoryMode: Int = 11, task: Int = AILIA_SPEECH_TASK_TRANSCRIBE, flags: Int = AILIA_SPEECH_FLAG_NONE)

Creates an ailia Speech instance.

Types

Link copied to clipboard
object Companion

Constants of ailia Speech.

Functions

Link copied to clipboard
fun close()

Destroys the ailia Speech instance.

Link copied to clipboard

Notifies the end of the audio input.

Link copied to clipboard

Determines if enough audio data has been fed to perform the transcription.

Link copied to clipboard

Determines if all of the audio data has been processed.

Link copied to clipboard

Returns the details of the last error.

Link copied to clipboard

Returns the recognized text fragment.

Link copied to clipboard

Returns the number of the recognized text fragments.

Link copied to clipboard
fun openDiarization(segmentationPath: String, embeddingPath: String, diarizationType: Int): Int

Opens the speaker diarization model files.

Link copied to clipboard
fun openDictionary(dictionaryPath: String, dictionaryType: Int): Int

Opens a dictionary file for correcting the recognition results.

Link copied to clipboard
fun openModel(encoderPath: String, decoderPath: String, modelType: Int): Int

Opens the speech recognition model files.

Link copied to clipboard
fun openPostProcess(encoderPath: String, decoderPath: String, sourcePath: String, targetPath: String, prefix: String, postProcessType: Int): Int

Opens the post process model files for error correction or translation of the recognition results.

Link copied to clipboard
fun openVad(vadPath: String, vadType: Int): Int

Opens the voice activity detection (VAD) model file.

Link copied to clipboard

Performs the post process (error correction or translation) of the recognition results.

Link copied to clipboard
fun pushInputData(src: FloatArray, channels: Int, samples: Int, samplingRate: Int): Int

Pushes the audio waveform to the queue.

Link copied to clipboard

Resets the transcribe state to process a new audio input.

Link copied to clipboard
fun setConstraint(constraint: String, type: Int): Int

Sets the constraint of the recognition output.

Link copied to clipboard

Sets the callback for receiving intermediate recognition results.

Link copied to clipboard
fun setLanguage(language: String): Int

Sets the language of the speech recognition.

Link copied to clipboard
fun setPrompt(prompt: String): Int

Sets the prompt text given to the model.

Link copied to clipboard
fun setSilentThreshold(silentThreshold: Float, speechSec: Float, noSpeechSec: Float): Int

Sets the silent threshold of the voice activity detection.

Link copied to clipboard

Performs the speech recognition of the buffered audio data.