|
int | GetEnvironmentId (bool is_gpu) |
| Get the environmen id. More...
|
|
string | GetEnvironmentName () |
| Get the environmen name. More...
|
|
bool | Create (int env_id, int flag) |
| Create a instance. More...
|
|
bool | OpenDictionary (string dict_path, int dict_type) |
|
bool | OpenModel (string encoder, string decoder1, string decoder2, string wave, string ssl, int model_type, int cleaner_type) |
|
virtual void | Close () |
| Destroys instance. More...
|
|
virtual void | Dispose () |
| Release resources. More...
|
|
string | G2P (string utf8, int g2p_type) |
| Get features. More...
|
|
bool | SetReference (AudioClip ref_audio, string ref_text) |
| Set reference audio. More...
|
|
bool | Inference (string feature) |
| Perform inference. More...
|
|
AudioClip | GetAudioClip () |
| Get audio clip. More...
|
|
|
virtual void | Dispose (bool disposing) |
|
◆ Close()
virtual void ailiaVoice.AiliaVoiceModel.Close |
( |
| ) |
|
|
inlinevirtual |
Destroys instance.
Destroys and initializes the instance.
198 if (net != IntPtr.Zero){
199 AiliaVoice.ailiaVoiceDestroy(net);
◆ Create()
bool ailiaVoice.AiliaVoiceModel.Create |
( |
int |
env_id, |
|
|
int |
flag |
|
) |
| |
|
inline |
Create a instance.
- Parameters
-
env_id | Environment ID of ailia |
flag | OR of flags (AiliaVoice.AILIA_VOICE_FLAG_*) |
- Returns
- If this function is successful, it returns true , or false otherwise.
104 AiliaVoice.AILIAVoiceApiCallback callback = AiliaVoice.GetCallback();
106 int memory_mode = Ailia.AILIA_MEMORY_REDUCE_CONSTANT | Ailia.AILIA_MEMORY_REDUCE_CONSTANT_WITH_INPUT_INITIALIZER | Ailia.AILIA_MEMORY_REUSE_INTERSTAGE;
107 int status = AiliaVoice.ailiaVoiceCreate(ref net, env_id, Ailia.AILIA_MULTITHREAD_AUTO, memory_mode, flag, callback, AiliaVoice.AILIA_VOICE_API_CALLBACK_VERSION);
110 Debug.Log(
"ailiaVoiceCreate failed " + status);
◆ Dispose() [1/2]
virtual void ailiaVoice.AiliaVoiceModel.Dispose |
( |
| ) |
|
|
inlinevirtual |
◆ Dispose() [2/2]
virtual void ailiaVoice.AiliaVoiceModel.Dispose |
( |
bool |
disposing | ) |
|
|
inlineprotectedvirtual |
◆ G2P()
string ailiaVoice.AiliaVoiceModel.G2P |
( |
string |
utf8, |
|
|
int |
g2p_type |
|
) |
| |
|
inline |
Get features.
- Parameters
-
utf8 | Input string |
g2p_type | G2P type |
- Returns
- If this function is successful, it returns string , or empty string otherwise.
248 byte[] text = System.Text.Encoding.UTF8.GetBytes(utf8+
"\u0000");
250 GCHandle handle = GCHandle.Alloc(text, GCHandleType.Pinned);
251 IntPtr input = handle.AddrOfPinnedObject();
252 int status = AiliaVoice.ailiaVoiceGraphemeToPhoneme(net, input, g2p_type);
256 Debug.Log(
"ailiaVoiceGraphemeToPhoneme faield " + status);
261 status = AiliaVoice.ailiaVoiceGetFeatureLength(net, ref count);
264 Debug.Log(
"ailiaVoiceGetFeatureLength faield " + status);
268 byte[] texts =
new byte [count];
269 handle = GCHandle.Alloc(texts, GCHandleType.Pinned);
270 IntPtr output = handle.AddrOfPinnedObject();
271 status = AiliaVoice.ailiaVoiceGetFeatures(net, output, count);
275 Debug.Log(
"ailiaVoiceGetFeatures faield " + status);
279 return System.Text.Encoding.UTF8.GetString(texts);
◆ GetAudioClip()
AudioClip ailiaVoice.AiliaVoiceModel.GetAudioClip |
( |
| ) |
|
|
inline |
Get audio clip.
- Returns
- If this function is successful, it returns AudioClip , or null otherwise.
387 AudioClip audioClip = AudioClip.Create(audio_clip_name, audio_data.Length, (
int)channels, (
int)sampling_rate,
false);
388 audioClip.SetData(audio_data, 0);
◆ GetEnvironmentId()
int ailiaVoice.AiliaVoiceModel.GetEnvironmentId |
( |
bool |
is_gpu | ) |
|
|
inline |
Get the environmen id.
- Parameters
-
- Returns
- env_id
45 int env_id = Ailia.AILIA_ENVIRONMENT_ID_AUTO;
48 Ailia.ailiaGetEnvironmentCount(ref count);
49 for (
int i = 0; i < count; i++){
50 IntPtr env_ptr = IntPtr.Zero;
51 Ailia.ailiaGetEnvironment(ref env_ptr, (uint)i, Ailia.AILIA_ENVIRONMENT_VERSION);
52 Ailia.AILIAEnvironment env = (Ailia.AILIAEnvironment)Marshal.PtrToStructure(env_ptr, typeof(Ailia.AILIAEnvironment));
54 if (env.backend == Ailia.AILIA_ENVIRONMENT_BACKEND_MPS || env.backend == Ailia.AILIA_ENVIRONMENT_BACKEND_CUDA || env.backend == Ailia.AILIA_ENVIRONMENT_BACKEND_VULKAN){
56 env_name = Marshal.PtrToStringAnsi(env.name);
◆ GetEnvironmentName()
string ailiaVoice.AiliaVoiceModel.GetEnvironmentName |
( |
| ) |
|
|
inline |
Get the environmen name.
- Returns
- env_name
◆ Inference()
bool ailiaVoice.AiliaVoiceModel.Inference |
( |
string |
feature | ) |
|
|
inline |
Perform inference.
- Parameters
-
feature | Input feature string |
- Returns
- If this function is successful, it returns true , or false otherwise.
337 byte[] text = System.Text.Encoding.UTF8.GetBytes(feature);
338 GCHandle handle = GCHandle.Alloc(text, GCHandleType.Pinned);
339 IntPtr input = handle.AddrOfPinnedObject();
340 int status = AiliaVoice.ailiaVoiceInference(net, input);
344 Debug.Log(
"ailiaVoiceInference faield " + status);
348 status = AiliaVoice.ailiaVoiceGetWaveInfo(net, ref samples, ref channels, ref sampling_rate);
351 Debug.Log(
"ailiaVoiceGetWaveInfo faield " + status);
356 uint count = samples * channels;
357 audio_data =
new float [count];
358 handle = GCHandle.Alloc(audio_data, GCHandleType.Pinned);
359 IntPtr output = handle.AddrOfPinnedObject();
360 status = AiliaVoice.ailiaVoiceGetWave(net, output, count *
sizeof(
float));
364 Debug.Log(
"ailiaVoiceGetWave faield " + status);
369 audio_clip_name = feature;
◆ OpenDictionary()
bool ailiaVoice.AiliaVoiceModel.OpenDictionary |
( |
string |
dict_path, |
|
|
int |
dict_type |
|
) |
| |
|
inline |
- Parameters
-
net | A network instance pointer |
dictionary_path | The path name to the dictionary folder |
dictionary_type | AILIA_VOICE_DICTIONARY_TYPE_* |
- Returns
- If this function is successful, it returns true , or false otherwise.
134 int status = AiliaVoice.ailiaVoiceOpenDictionaryFile(net, dict_path, dict_type);
137 Debug.Log(
"ailiaVoiceOpenDictionaryFile faield " + status);
◆ OpenModel()
bool ailiaVoice.AiliaVoiceModel.OpenModel |
( |
string |
encoder, |
|
|
string |
decoder1, |
|
|
string |
decoder2, |
|
|
string |
wave, |
|
|
string |
ssl, |
|
|
int |
model_type, |
|
|
int |
cleaner_type |
|
) |
| |
|
inline |
- Parameters
-
net | A network instance pointer |
encoder | The path name to the onnx file |
decoder1 | The path name to the onnx file |
decoder2 | The path name to the onnx file |
wave | The path name to the onnx file |
ssl | The path name to the onnx file |
model_type | AILIA_VOICE_MODEL_TYPE_* |
cleaner_type | AILIA_VOICE_CLEANER_TYPE_* |
- Returns
- If this function is successful, it returns true , or false otherwise.
170 AiliaLicense.CheckAndDownloadLicense();
172 int status = AiliaVoice.ailiaVoiceOpenModelFile(net, encoder, decoder1, decoder2, wave, ssl, model_type, cleaner_type);
175 Debug.Log(
"ailiaVoiceOpenModelFile faield " + status);
◆ SetReference()
bool ailiaVoice.AiliaVoiceModel.SetReference |
( |
AudioClip |
ref_audio, |
|
|
string |
ref_text |
|
) |
| |
|
inline |
Set reference audio.
- Parameters
-
ref_audio | Reference audio |
ref_text | Reference text |
- Returns
- If this function is successful, it returns AudioClip , or null otherwise.
299 float[] audio_data =
new float[ref_audio.samples * ref_audio.channels];
300 ref_audio.GetData(audio_data, 0);
302 GCHandle audio_handle = GCHandle.Alloc(audio_data, GCHandleType.Pinned);
303 IntPtr audio_input = audio_handle.AddrOfPinnedObject();
305 byte[] text = System.Text.Encoding.UTF8.GetBytes(ref_text);
306 GCHandle text_handle = GCHandle.Alloc(text, GCHandleType.Pinned);
307 IntPtr text_input = text_handle.AddrOfPinnedObject();
308 int status = AiliaVoice.ailiaVoiceSetReference(net, audio_input, (uint)(ref_audio.samples * ref_audio.channels * 4), (uint)(ref_audio.channels), (uint)(ref_audio.frequency), text_input);
314 Debug.Log(
"ailiaVoiceSetReference faield " + status);
The documentation for this class was generated from the following file: