|
bool | IsError () |
| Check is error occured. More...
|
|
string | GetErrorDetail () |
| Get error detail. More...
|
|
int | GetEnvironmentId (bool is_gpu) |
| Get the environmen id. More...
|
|
string | GetEnvironmentName () |
| Get the environmen name. More...
|
|
bool | Open (string encoder_path, string decoder_path, int env_id, int memory_mode, int model_type, int task, int flag, string language) |
| Create a instance. More...
|
|
bool | OpenVad (string vad_path, int vad_type) |
| Open VAD file. More...
|
|
bool | OpenDictionary (string dictionary_path, int dictionary_type) |
| Open dictionary file. More...
|
|
bool | OpenPostProcess (string encoder_path, string decoder_path, string source_path, string target_path, string prefix, int type) |
| Open PostProcess file. More...
|
|
virtual void | Close () |
| Destroys instance. More...
|
|
virtual void | Dispose () |
| Release resources. More...
|
|
bool | SetPrompt (string prompt) |
| Set prompt. More...
|
|
bool | SetConstraint (string constraint, int constraint_type) |
| Set constraint. More...
|
|
bool | Transcribe (float[] waveData, uint frequency, uint channels, bool tail) |
| Perform speech recognition. More...
|
|
bool | IsProcessing () |
| Check is processing sub thread. More...
|
|
bool | IsTranscribing () |
| Check is running Speech2Text. More...
|
|
bool | IsCompleted () |
| Gets whether all audio processing is complete. More...
|
|
List< string > | GetResults () |
| Get results and clear of Speech2Text. More...
|
|
string | GetIntermediateText () |
| Get the intermediate result of Speech2Text. More...
|
|
bool | ResetTranscribeState () |
| Initialize the Speech2Text state. More...
|
|
|
virtual void | Dispose (bool disposing) |
|
◆ Close()
virtual void ailiaSpeech.AiliaSpeechModel.Close |
( |
| ) |
|
|
inlinevirtual |
Destroys instance.
Destroys and initializes the instance.
344 if (net != IntPtr.Zero){
345 AiliaSpeech.ailiaSpeechDestroy(net);
◆ Dispose() [1/2]
virtual void ailiaSpeech.AiliaSpeechModel.Dispose |
( |
| ) |
|
|
inlinevirtual |
◆ Dispose() [2/2]
virtual void ailiaSpeech.AiliaSpeechModel.Dispose |
( |
bool |
disposing | ) |
|
|
inlineprotectedvirtual |
◆ GetEnvironmentId()
int ailiaSpeech.AiliaSpeechModel.GetEnvironmentId |
( |
bool |
is_gpu | ) |
|
|
inline |
Get the environmen id.
- Parameters
-
- Returns
- env_id
99 int env_id = Ailia.AILIA_ENVIRONMENT_ID_AUTO;
102 Ailia.ailiaGetEnvironmentCount(ref count);
103 for (
int i = 0; i < count; i++){
104 IntPtr env_ptr = IntPtr.Zero;
105 Ailia.ailiaGetEnvironment(ref env_ptr, (uint)i, Ailia.AILIA_ENVIRONMENT_VERSION);
106 Ailia.AILIAEnvironment env = (Ailia.AILIAEnvironment)Marshal.PtrToStructure(env_ptr, typeof(Ailia.AILIAEnvironment));
108 if (env.backend == Ailia.AILIA_ENVIRONMENT_BACKEND_MPS || env.backend == Ailia.AILIA_ENVIRONMENT_BACKEND_CUDA || env.backend == Ailia.AILIA_ENVIRONMENT_BACKEND_VULKAN){
110 env_name = Marshal.PtrToStringAnsi(env.name);
◆ GetEnvironmentName()
string ailiaSpeech.AiliaSpeechModel.GetEnvironmentName |
( |
| ) |
|
|
inline |
Get the environmen name.
- Returns
- env_name
◆ GetErrorDetail()
string ailiaSpeech.AiliaSpeechModel.GetErrorDetail |
( |
| ) |
|
|
inline |
Get error detail.
- Returns
- The error detail string.
76 return m_error_detail;
◆ GetIntermediateText()
string ailiaSpeech.AiliaSpeechModel.GetIntermediateText |
( |
| ) |
|
|
inline |
Get the intermediate result of Speech2Text.
- Returns
- Transcribe results.
819 lock (m_intermediate_lock_async){
820 return m_intermediate_text;
◆ GetResults()
List<string> ailiaSpeech.AiliaSpeechModel.GetResults |
( |
| ) |
|
|
inline |
Get results and clear of Speech2Text.
- Returns
- Transcribe results.
801 List<string> results =
new List<string>(m_results);
◆ IntermediateCallback()
static int ailiaSpeech.AiliaSpeechModel.IntermediateCallback |
( |
IntPtr |
handle, |
|
|
IntPtr |
text |
|
) |
| |
|
inlinestatic |
498 lock (m_intermediate_lock_async){
500 string decoded_text = Marshal.PtrToStringAnsi(text);
501 m_intermediate_text = decoded_text;
505 if (Marshal.ReadInt32(handle) != 0){
◆ IsCompleted()
bool ailiaSpeech.AiliaSpeechModel.IsCompleted |
( |
| ) |
|
|
inline |
Gets whether all audio processing is complete.
- Returns
- If Speech2Text is complete, it returns true , or false otherwise.
◆ IsError()
bool ailiaSpeech.AiliaSpeechModel.IsError |
( |
| ) |
|
|
inline |
Check is error occured.
- Returns
- If error is occured, it returns true , or false otherwise.
◆ IsProcessing()
bool ailiaSpeech.AiliaSpeechModel.IsProcessing |
( |
| ) |
|
|
inline |
Check is processing sub thread.
- Returns
- If sub thread is processing, it returns true , or false otherwise.
◆ IsTranscribing()
bool ailiaSpeech.AiliaSpeechModel.IsTranscribing |
( |
| ) |
|
|
inline |
Check is running Speech2Text.
- Returns
- If Speech2Text is running, it returns true , or false otherwise.
◆ Open()
bool ailiaSpeech.AiliaSpeechModel.Open |
( |
string |
encoder_path, |
|
|
string |
decoder_path, |
|
|
int |
env_id, |
|
|
int |
memory_mode, |
|
|
int |
model_type, |
|
|
int |
task, |
|
|
int |
flag, |
|
|
string |
language |
|
) |
| |
|
inline |
Create a instance.
- Parameters
-
encoder_path | Encoder onnx file path |
decoder_path | Decoder onnx file path |
env_id | Runtime environment (Ailia.AILIA_ENVIRONMENT_ID_AUTO for automatic selection) |
memory_mode | Memory mode (Ailia.AILIA_MEMORY_REDUCE_CONSTANT | Ailia.AILIA_MEMORY_REDUCE_CONSTANT_WITH_INPUT_INITIALIZER | Ailia.AILIA_MEMORY_REUSE_INTERSTAGE etc) |
model_type | Model type (AiliaSpeech.AILIA_SPEECH_MODEL_TYPE_*) |
task | Task (AiliaSpeech.AILIA_SPEECH_TASK_*) |
flag | OR of flags (AiliaSpeech.AILIA_SPEECH_FLAG_*) |
language | Language (ja or en or etc. auto is automatic selection) |
- Returns
- If this function is successful, it returns true , or false otherwise.
166 AiliaLicense.CheckAndDownloadLicense();
172 AiliaSpeech.AILIASpeechApiCallback callback = AiliaSpeech.GetCallback();
174 int status = AiliaSpeech.ailiaSpeechCreate(ref net, env_id, Ailia.AILIA_MULTITHREAD_AUTO, memory_mode, task, flag, callback, AiliaSpeech.AILIA_SPEECH_API_CALLBACK_VERSION);
175 Check(status,
"ailiaSpeechCreate");
180 status = AiliaSpeech.ailiaSpeechOpenModelFile(net, encoder_path, decoder_path, model_type);
181 Check(status,
"ailiaSpeechOpenModelFile");
186 if (language !=
"auto"){
187 status = AiliaSpeech.ailiaSpeechSetLanguage(net, language);
188 Check(status,
"ailiaSpeechSetLanguage");
194 status = AiliaSpeech.ailiaSpeechSetSilentThreshold(net, THRESHOLD_VOLUME, SPEECH_SEC, NO_SPEECH_SEC);
195 Check(status,
"ailiaSpeechSetSilentThreshold");
202 status = AiliaSpeech.ailiaSpeechSetIntermediateCallback(net,
IntermediateCallback, m_interrupt_ptr);
203 Check(status,
"ailiaSpeechSetIntermediateCallback");
213 if ((flag & AiliaSpeech.AILIA_SPEECH_FLAG_LIVE) != 0){
◆ OpenDictionary()
bool ailiaSpeech.AiliaSpeechModel.OpenDictionary |
( |
string |
dictionary_path, |
|
|
int |
dictionary_type |
|
) |
| |
|
inline |
Open dictionary file.
- Parameters
-
dictionary_path | dictionary file path |
dictionary_type | dictionary type (AiliaSpeech.AILIA_SPEECH_DICTIONARY_TYPE_*) |
- Returns
- If this function is successful, it returns true , or false otherwise.
273 int status = AiliaSpeech.ailiaSpeechOpenDictionaryFile(net, dictionary_path, dictionary_type);
274 Check(status,
"ailiaSpeechOpenDictionaryFile");
◆ OpenPostProcess()
bool ailiaSpeech.AiliaSpeechModel.OpenPostProcess |
( |
string |
encoder_path, |
|
|
string |
decoder_path, |
|
|
string |
source_path, |
|
|
string |
target_path, |
|
|
string |
prefix, |
|
|
int |
type |
|
) |
| |
|
inline |
Open PostProcess file.
- Parameters
-
encoder_path | The path name to the onnx file |
decoder_path | The path name to the onnx file |
source_path | The path name to the tokenizer model file |
target_path | The path name to the tokenizer model file |
prefix | The prefix of T5 (UTF8), null for FuguMT |
post_process_type | AILIA_SPEECH_POST_PROCESS_TYPE_* |
- Returns
- If this function is successful, it returns true , or false otherwise.
310 status = AiliaSpeech.ailiaSpeechOpenPostProcessFile(net, encoder_path, decoder_path, source_path, target_path, IntPtr.Zero, type);
312 byte[] text = System.Text.Encoding.UTF8.GetBytes(prefix+
"\u0000");
313 GCHandle handle = GCHandle.Alloc(text, GCHandleType.Pinned);
314 IntPtr prefix_ptr = handle.AddrOfPinnedObject();
315 status = AiliaSpeech.ailiaSpeechOpenPostProcessFile(net, encoder_path, decoder_path, source_path, target_path, prefix_ptr, type);
318 Check(status,
"ailiaSpeechOpenPostProcessFile");
322 post_process_mode =
true;
◆ OpenVad()
bool ailiaSpeech.AiliaSpeechModel.OpenVad |
( |
string |
vad_path, |
|
|
int |
vad_type |
|
) |
| |
|
inline |
Open VAD file.
- Parameters
-
vad_path | VAD onnx file path |
vad_type | VAD type (AiliaSpeech.AILIA_SPEECH_VAD_TYPE_*) |
- Returns
- If this function is successful, it returns true , or false otherwise.
241 int status = AiliaSpeech.ailiaSpeechOpenVadFile(net, vad_path, vad_type);
242 Check(status,
"ailiaSpeechOpenVadFile");
246 status = AiliaSpeech.ailiaSpeechSetSilentThreshold(net, THRESHOLD_VAD, SPEECH_SEC, NO_SPEECH_SEC);
247 Check(status,
"ailiaSpeechSetSilentThreshold");
◆ ResetTranscribeState()
bool ailiaSpeech.AiliaSpeechModel.ResetTranscribeState |
( |
| ) |
|
|
inline |
Initialize the Speech2Text state.
- Returns
- If this function is successful, it returns true , or false otherwise.
836 int status = AiliaSpeech.ailiaSpeechResetTranscribeState(net);
◆ SetConstraint()
bool ailiaSpeech.AiliaSpeechModel.SetConstraint |
( |
string |
constraint, |
|
|
int |
constraint_type |
|
) |
| |
|
inline |
Set constraint.
- Parameters
-
constraint | The text of constraint (UTF8) |
constraint_type | AILIA_SPEECH_CONSTRAINT_* |
- Returns
- If this function is successful, it returns true , or false otherwise.
425 byte[] text = System.Text.Encoding.UTF8.GetBytes(constraint+
"\u0000");
426 GCHandle handle = GCHandle.Alloc(text, GCHandleType.Pinned);
427 IntPtr input = handle.AddrOfPinnedObject();
428 int status = AiliaSpeech.ailiaSpeechSetConstraint(net, input, constraint_type);
◆ SetPrompt()
bool ailiaSpeech.AiliaSpeechModel.SetPrompt |
( |
string |
prompt | ) |
|
|
inline |
Set prompt.
- Parameters
-
prompt | The text of prompt (UTF8) |
- Returns
- If this function is successful, it returns true , or false otherwise.
393 byte[] text = System.Text.Encoding.UTF8.GetBytes(prompt+
"\u0000");
394 GCHandle handle = GCHandle.Alloc(text, GCHandleType.Pinned);
395 IntPtr input = handle.AddrOfPinnedObject();
396 int status = AiliaSpeech.ailiaSpeechSetPrompt(net, input);
◆ Transcribe()
bool ailiaSpeech.AiliaSpeechModel.Transcribe |
( |
float[] |
waveData, |
|
|
uint |
frequency, |
|
|
uint |
channels, |
|
|
bool |
tail |
|
) |
| |
|
inline |
Perform speech recognition.
- Parameters
-
waveQueue | Input PCM |
frequency | Frequency of PCM |
channels | Number of channels of PCM |
tail | Is last input |
- Returns
- If this function is successful, it returns true , or false otherwise. @detail Run speech recognition. Non -blocked API. When the execution is completed, the IsTranscribed API returns True. Execution results can be obtained with the GetResults API. The result of execution can be obtained with the GetIntermediateText API.
718 if (waveData.Length == 0){
723 threadChannels = channels;
724 threadFrequency = frequency;
725 threadWaveQueue.Add(waveData);
726 threadComplete = tail;
The documentation for this class was generated from the following file: