|
virtual void | Dispose (bool disposing) |
|
◆ Close()
virtual void ailiaSpeech.AiliaSpeechTranslateModel.Close |
( |
| ) |
|
|
inlinevirtual |
Destroys instance.
Destroys and initializes the instance.
204 if (net != IntPtr.Zero){
205 AiliaSpeech.ailiaSpeechDestroy(net);
◆ Dispose() [1/2]
virtual void ailiaSpeech.AiliaSpeechTranslateModel.Dispose |
( |
| ) |
|
|
inlinevirtual |
◆ Dispose() [2/2]
virtual void ailiaSpeech.AiliaSpeechTranslateModel.Dispose |
( |
bool |
disposing | ) |
|
|
inlineprotectedvirtual |
◆ GetEnvironmentId()
int ailiaSpeech.AiliaSpeechTranslateModel.GetEnvironmentId |
( |
bool |
is_gpu | ) |
|
|
inline |
Get the environmen id.
- Parameters
-
- Returns
- env_id
92 int env_id = Ailia.AILIA_ENVIRONMENT_ID_AUTO;
95 Ailia.ailiaGetEnvironmentCount(ref count);
96 for (
int i = 0; i < count; i++){
97 IntPtr env_ptr = IntPtr.Zero;
98 Ailia.ailiaGetEnvironment(ref env_ptr, (uint)i, Ailia.AILIA_ENVIRONMENT_VERSION);
99 Ailia.AILIAEnvironment env = (Ailia.AILIAEnvironment)Marshal.PtrToStructure(env_ptr, typeof(Ailia.AILIAEnvironment));
101 if (env.backend == Ailia.AILIA_ENVIRONMENT_BACKEND_MPS || env.backend == Ailia.AILIA_ENVIRONMENT_BACKEND_CUDA || env.backend == Ailia.AILIA_ENVIRONMENT_BACKEND_VULKAN){
103 env_name = Marshal.PtrToStringAnsi(env.name);
◆ GetEnvironmentName()
string ailiaSpeech.AiliaSpeechTranslateModel.GetEnvironmentName |
( |
| ) |
|
|
inline |
Get the environmen name.
- Returns
- env_name
◆ GetErrorDetail()
string ailiaSpeech.AiliaSpeechTranslateModel.GetErrorDetail |
( |
| ) |
|
|
inline |
Get error detail.
- Returns
- The error detail string.
69 return m_error_detail;
◆ IsError()
bool ailiaSpeech.AiliaSpeechTranslateModel.IsError |
( |
| ) |
|
|
inline |
Check is error occured.
- Returns
- If error is occured, it returns true , or false otherwise.
◆ Open()
bool ailiaSpeech.AiliaSpeechTranslateModel.Open |
( |
string |
encoder_path, |
|
|
string |
decoder_path, |
|
|
string |
source_path, |
|
|
string |
target_path, |
|
|
int |
type, |
|
|
int |
env_id, |
|
|
int |
memory_mode |
|
) |
| |
|
inline |
Create a instance.
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 |
post_process_type | AILIA_SPEECH_POST_PROCESS_TYPE_* |
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) |
- Returns
- If this function is successful, it returns true , or false otherwise.
158 AiliaLicense.CheckAndDownloadLicense();
164 AiliaSpeech.AILIASpeechApiCallback callback = AiliaSpeech.GetCallback();
166 int task = AiliaSpeech.AILIA_SPEECH_TASK_TRANSCRIBE;
167 int flag = AiliaSpeech.AILIA_SPEECH_FLAG_NONE;
169 int status = AiliaSpeech.ailiaSpeechCreate(ref net, env_id, Ailia.AILIA_MULTITHREAD_AUTO, memory_mode, task, flag, callback, AiliaSpeech.AILIA_SPEECH_API_CALLBACK_VERSION);
170 Check(status,
"ailiaSpeechCreate");
176 status = AiliaSpeech.ailiaSpeechOpenPostProcessFile(net, encoder_path, decoder_path, source_path, target_path, IntPtr.Zero, type);
177 Check(status,
"ailiaSpeechOpenPostProcessFile");
◆ Translate()
string ailiaSpeech.AiliaSpeechTranslateModel.Translate |
( |
string |
input_text | ) |
|
|
inline |
Perform speech recognition.
- Parameters
-
- Returns
- If this function is successful, it returns translated string , or null otherwise. @detail Run translate. Blocked API.
258 AiliaSpeech.AILIASpeechText text =
new AiliaSpeech.AILIASpeechText();
260 byte[] input_text_byte = System.Text.Encoding.UTF8.GetBytes(input_text+
"\u0000");
261 GCHandle input_text_handle = GCHandle.Alloc(input_text_byte, GCHandleType.Pinned);
262 IntPtr input_text_ptr = input_text_handle.AddrOfPinnedObject();
264 byte[] language_text_byte = System.Text.Encoding.UTF8.GetBytes(
"None\u0000");
265 GCHandle language_handle = GCHandle.Alloc(language_text_byte, GCHandleType.Pinned);
266 IntPtr language_text_ptr = language_handle.AddrOfPinnedObject();
268 text.text = input_text_ptr;
269 text.time_stamp_begin = 0.0f;
270 text.time_stamp_end = 0.0f;
271 text.confidence = 0.0f;
273 text.language = language_text_ptr;
276 int status = AiliaSpeech.ailiaSpeechSetText(net, text, AiliaSpeech.AILIA_SPEECH_TEXT_VERSION, idx);
278 Check(status,
"ailiaSpeechSetText");
282 status = AiliaSpeech.ailiaSpeechPostProcess(net);
284 Check(status,
"ailiaSpeechPostProcess");
288 status = AiliaSpeech.ailiaSpeechGetText(net, text, AiliaSpeech.AILIA_SPEECH_TEXT_VERSION, idx);
290 Check(status,
"ailiaSpeechGetText");
294 input_text_handle.Free();
295 language_handle.Free();
297 return Marshal.PtrToStringAnsi(text.text);
The documentation for this class was generated from the following file: