### Clone and Run ailia Models Example Source: https://github.com/ailia-ai/ailia-sdk/blob/master/en/setup/python/windows.html Clone the ailia-models repository, install its requirements, and run a sample object detection application. This verifies the SDK integration with a practical example. ```bash git clone https://github.com/ailia-ai/ailia-models.git cd ailia-models pip3 install -r requirements.txt cd object_detection/yolox python yolox.py -v 0 ``` -------------------------------- ### Install ailia SDK Source: https://github.com/ailia-ai/ailia-sdk/blob/master/en/setup/python/linux.html Install the ailia SDK Python package using pip. ```bash pip3 install ailia ``` -------------------------------- ### Verify Vulkan Installation with vulkaninfo Source: https://github.com/ailia-ai/ailia-sdk/blob/master/en/setup/vulkan/index.html Install and use the 'vulkaninfo' tool to verify your Vulkan installation on Linux. This command provides detailed information about the Vulkan setup. ```bash sudo apt install vulkan-tools vulkaninfo --summary ``` -------------------------------- ### Install Git on Ubuntu/Debian Source: https://github.com/ailia-ai/ailia-sdk/blob/master/en/setup/python/linux.html Install the git version control system using the apt package manager. ```bash sudo apt install git ``` -------------------------------- ### ailia_tokenizer sample output example Source: https://github.com/ailia-ai/ailia-sdk/blob/master/tokenizer/cpp/en/setup.html Example output demonstrating the tokenization of Japanese text. ```text Tokenizer type 0 Input Text : ハードウェア ソフトウェア Tokens : 15927 44165 20745 28571 12817 220 42668 17320 7588 20745 28571 12817 Output Text : ハードウェア ソフトウェア ``` -------------------------------- ### Basic LLM Usage Example Source: https://github.com/ailia-ai/ailia-sdk/blob/master/llm/cpp/en/api.html A C++ example demonstrating the fundamental steps to initialize, load a model, set a prompt, generate text, and clean up the Ailia LLM instance. ```APIDOC ## Basic LLM Usage Example ### Description This example demonstrates the core workflow of using the Ailia LLM library, from creation to destruction, including model loading and text generation. ### Code ```cpp #include "ailia_llm.h" int main(int argc, char *argv[]){ struct AILIALLM* llm; unsigned int n_ctx = 512; ailiaLLMCreate(&llm); ailiaLLMOpenModelFileA(llm, "../models/gemma-2-2b-it-Q4_K_M.gguf", n_ctx); std::vector messages; AILIALLMChatMessage message; message.role = "system"; message.content = "語尾に「くま」をつけて回答してください。"; messages.push_back(message); message.role = "user"; message.content = "こんにちは。"; messages.push_back(message); ailiaLLMSetPrompt(llm, &messages[0], messages.size()); std::string text = ""; while(true) { unsigned int done = 0; int status = ailiaLLMGenerate(llm, &done); if (done == 1 || status != AILIA_LLM_STATUS_SUCCESS){ break; } unsigned int size = 0; ailiaLLMGetDeltaTextSize(llm, &size); std::vector delta(size); ailiaLLMGetDeltaText(llm, &delta[0], delta.size()); text = text + std::string(&delta[0]); } ailiaLLMDestroy(llm); return 0; } ``` ``` -------------------------------- ### Run YOLOX Object Detection Example Source: https://github.com/ailia-ai/ailia-sdk/blob/master/en/setup/python/linux.html Navigate to the YOLOX object detection directory within ailia-models and run the example script. ```bash cd object_detection/yolox python3 yolox.py -v 0 ``` -------------------------------- ### Voice Synthesis Example Snippet Source: https://github.com/ailia-ai/ailia-sdk/blob/master/voice/cpp/en/api.html Example of a voice synthesis workflow, including error checking after getting wave data, printing wave information, writing to a WAV file, and cleaning up resources. ```c if (status != AILIA_STATUS_SUCCESS){ printf("ailiaVoiceGetWave error %d\n", status); return -1; } printf("Wave samples : %d\nWave channles : %d\nWave sampling rate : %d\n", samples, channels, sampling_rate); write_wave_file("output.wav", buf, sampling_rate); [ailiaVoiceDestroy](ailia__voice_8h.html#ae80dc9a146c34216c0b89a6011b03290)(net); return 0; } ``` -------------------------------- ### Install ailia Unity Package Source: https://github.com/ailia-ai/ailia-sdk/blob/master/en/sdk/index.html Install the ailia Unity package via the Package Manager using a Git URL. ```bash https://github.com/ailia-ai/ailia-sdk-unity.git https://github.com/ailia-ai/ailia-audio-unity.git ``` -------------------------------- ### CLIP Tokenizer Example Source: https://github.com/ailia-ai/ailia-sdk/blob/master/tokenizer/cpp/en/feature.html Example of using CLIPTokenizer. SOT and EOT tokens are included. Padding to 77 symbols may be necessary. ```python from transformers import CLIPTokenizer tokenizer = CLIPTokenizer.from_pretrained("openai/clip-vit-large-patch14") inputs = tokenizer(sents) ``` ```python from simple_tokenizer import SimpleTokenizer as _Tokenizer _tokenizer = _Tokenizer() sot_token = _tokenizer.encoder["<|startoftext|>"] eot_token = _tokenizer.encoder["<|endoftext|>"] all_tokens = [[sot_token] + _tokenizer.encode(text) + [eot_token] for text in texts] ``` -------------------------------- ### Basic Usage Example Source: https://github.com/ailia-ai/ailia-sdk/blob/master/tokenizer/cpp/en/api.html This example demonstrates the fundamental usage of the Ailia Tokenizer, including creating an instance, encoding a UTF8 string, and decoding tokens back into text. ```APIDOC ## Basic Usage Example This is an example of using ailia Tokenizer. By creating an instance and giving a UTF8 string as an argument, a token can be obtained. ```c #include #include #include #include #include "ailia_tokenizer.h" int main(int argc, char *argv[]){ int32_t type = AILIA_TOKENIZER_TYPE_WHISPER; printf("Tokenizer type %d\n", type); AILIATokenizer *net; ailiaTokenizerCreate(&net, type, AILIA_TOKENIZER_FLAG_NONE); const char * text = u8"ハードウェア ソフトウェア"; printf("Input Text : %s\n", text); ailiaTokenizerEncode(net, text); unsigned int count; ailiaTokenizerGetTokenCount(net, &count); std::vector tokens(count); ailiaTokenizerGetTokens(net, &tokens[0], count); ailiaTokenizerDecode(net, &tokens[0], count); printf("Tokens : "); for (int i = 0; i < count; i++){ printf("%d ", tokens[i]); } printf("\n"); unsigned int len; ailiaTokenizerGetTextLength(net, &len); std::vector out_text(len); char * p_text = &out_text[0]; ailiaTokenizerGetText(net, p_text, len); printf("Output Text : %s\n", p_text); return 0; } ``` ``` -------------------------------- ### Install ailia Speech Python Package Source: https://github.com/ailia-ai/ailia-sdk/blob/master/en/speech/index.html Install the ailia Speech Python package and the librosa audio loader. Ensure Python and git are set up. ```bash pip3 install ailia_speech librosa ``` -------------------------------- ### Install Vulkan Loader on Linux (Ubuntu) Source: https://github.com/ailia-ai/ailia-sdk/blob/master/en/setup/vulkan/index.html Install the Vulkan loader library on Ubuntu systems. This is a prerequisite for using Vulkan on Linux. ```bash sudo apt install libvulkan1 ``` -------------------------------- ### Run ailia Tokenizer Flutter Sample Source: https://github.com/ailia-ai/ailia-sdk/blob/master/en/tokenizer/index.html Clone the ailia-tokenizer-flutter repository and run the example app to test tokenization. The example encodes text using a SentencePiece model from assets. ```bash git clone https://github.com/ailia-ai/ailia-tokenizer-flutter.git cd ailia-tokenizer-flutter/example flutter pub get flutter run ``` -------------------------------- ### Example CUDA Environment Output Source: https://github.com/ailia-ai/ailia-sdk/blob/master/en/setup/cuda/index.html Example output showing CUDA detection in the environment list. This confirms that the ailia SDK can utilize the GPU via the CUDA backend. ```text env[2]=Environment(id=2, type='GPU', name='cuDNN-NVIDIA GeForce RTX 3080 (8.6, FP32)', backend='CUDA', props=[]) ``` -------------------------------- ### Install ailia LLM Python Package Source: https://github.com/ailia-ai/ailia-sdk/blob/master/en/llm/index.html Install the ailia LLM Python package using pip. Ensure Python and git are set up. ```bash pip3 install ailia_llm ``` -------------------------------- ### Install ailia Tokenizer Python Package Source: https://github.com/ailia-ai/ailia-sdk/blob/master/en/tokenizer/index.html Install the ailia Tokenizer Python package using pip. Ensure Python and git are set up. ```bash pip3 install ailia_tokenizer ``` -------------------------------- ### Build and Run C++ Sample Source: https://github.com/ailia-ai/ailia-sdk/blob/master/en/sdk/index.html Fetch a license, install dependencies (CMake and OpenCV), build with CMake, and run a sample. Xcode and Android NDK starter projects are also available. ```bash # Fetch a one-month evaluation license cd ailia python3 download_license.py cd .. # macOS brew install cmake opencv # Linux: apt install cmake libopencv-dev # Windows: install CMake and Visual Studio, # then set OpenCV_DIR to your OpenCV build path cmake . cmake --build . cd object_detection/yolox ./yolox.sh # use yolox.bat on Windows ``` -------------------------------- ### Build Sample on Linux Source: https://github.com/ailia-ai/ailia-sdk/blob/master/voice/cpp/en/setup.html Compile the sample application using g++ and set the library path. ```bash export LD_LIBRARY_PATH=./ g++ -o ailia_voice_sample ailia_voice_sample.cpp wave_writer.cpp wave_reader.cpp libailia_voice.so libailia.so libailia_audio.so ``` -------------------------------- ### ailiaAudioGetNonSilentPos Source: https://github.com/ailia-ai/ailia-sdk/blob/master/sdk/cpp/en/ailia__audio_8h_source.html Get the start position and length of non-silent segments. ```APIDOC ## ailiaAudioGetNonSilentPos ### Description Get the start position and length of non-silent segments. ### Signature ```c int AILIA_API ailiaAudioGetNonSilentPos(int* dst_start_pos, int* dst_length, const void* src, int sample_n, int win_n, int hop_n, float thr_db) ``` ### Parameters * `dst_start_pos` - Pointer to store the start position of the non-silent segment. * `dst_length` - Pointer to store the length of the non-silent segment. * `src` - Pointer to the source audio signal. * `sample_n` - Number of samples in the audio signal. * `win_n` - Window length. * `hop_n` - Hop length. * `thr_db` - Threshold in dB to determine silence. ``` -------------------------------- ### Get Character Start Positions - ailiaTokenizerFFI Source: https://github.com/ailia-ai/ailia-sdk/blob/master/tokenizer/flutter/en/ailia_tokenizer/ailiaTokenizerFFI/ailiaTokenizerGetCharStarts.html This function retrieves the character start positions for tokens. It is valid only for AILIA_TOKENIZER_TYPE_ROBERTA and AILIA_TOKENIZER_TYPE_BERT. Ensure ailiaTokenizerEncode() has been called prior to using this method. The character start positions are returned in UTF-32 units. ```dart int ailiaTokenizerGetCharStarts( ffi.Pointer net, ffi.Pointer char_starts, int count, ) { return _ailiaTokenizerGetCharStarts( net, char_starts, count, ); } ``` -------------------------------- ### Build and Run C++ GPT-SoVITS v2 Pro Sample Source: https://github.com/ailia-ai/ailia-sdk/blob/master/en/voice/index.html Fetch an evaluation license, install build tools like CMake and OpenCV, build the project, and run the GPT-SoVITS v2 Pro sample. The script downloads models and dictionary files. ```bash # Fetch a one-month evaluation license cd ailia python3 download_license.py cd .. # macOS brew install cmake # Linux: apt install cmake # Windows: install CMake and Visual Studio cmake -DWITH_OPENCV=OFF . cmake --build . cd audio_processing/gpt-sovits-v2-pro ./gpt-sovits-v2-pro.sh # use gpt-sovits-v2-pro.bat on Windows ``` -------------------------------- ### Run ailia_tracker Sample Source: https://github.com/ailia-ai/ailia-sdk/blob/master/tracker/cpp/en/setup.html Execute the compiled ailia_tracker sample application. Replace