Instructions to use Sky-Kim/com.sky.sentis.audio2lipsync with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- unity-sentis
How to use Sky-Kim/com.sky.sentis.audio2lipsync with unity-sentis:
string modelName = "[Your model name here].sentis"; Model model = ModelLoader.Load(Application.streamingAssetsPath + "/" + modelName); IWorker engine = WorkerFactory.CreateWorker(BackendType.GPUCompute, model); // Please see provided C# file for more details
- Notebooks
- Google Colab
- Kaggle
Download Runtime/Audio2LipsyncModel.cs from Sky-Kim/com.sky.sentis.audio2lipsync: direct link, hf CLI and curl.
- Browser
- Download file 3.03 kB
-
https://huggingface.co/Sky-Kim/com.sky.sentis.audio2lipsync/resolve/main/Runtime/Audio2LipsyncModel.cs
- Command line
-
hf download hf://Sky-Kim/com.sky.sentis.audio2lipsync/Runtime/Audio2LipsyncModel.cs
-
curl -L -o Audio2LipsyncModel.cs https://huggingface.co/Sky-Kim/com.sky.sentis.audio2lipsync/resolve/main/Runtime/Audio2LipsyncModel.cs
3.03 kB
| using System.IO; | |
| using Unity.InferenceEngine; | |
| using UnityEngine; | |
| using UnityEngine.Networking; | |
| namespace Audio2Lipsync | |
| { | |
| /// <summary> | |
| /// Locates and loads the packaged model with no setup step: | |
| /// - Editor: straight from the package's Model~ folder (nothing is copied into Assets). | |
| /// - Player: from StreamingAssets/Audio2Lipsync/, where the package's build hook puts it for | |
| /// the duration of each build. | |
| /// </summary> | |
| public static class Audio2LipsyncModel | |
| { | |
| public const string FileName = "audio2lipsync.sentis"; | |
| public const string StreamingAssetsFolder = "Audio2Lipsync"; | |
| public static string StreamingAssetsPath => | |
| Path.Combine(Application.streamingAssetsPath, StreamingAssetsFolder, FileName); | |
| /// <summary>Model~/audio2lipsync.sentis inside the resolved package (editor only).</summary> | |
| public static string PackagedPath | |
| { | |
| get | |
| { | |
| var pkg = UnityEditor.PackageManager.PackageInfo.FindForAssembly(typeof(Audio2LipsyncModel).Assembly); | |
| return pkg == null ? null : Path.Combine(pkg.resolvedPath, "Model~", FileName); | |
| } | |
| } | |
| /// <summary> | |
| /// Where <see cref="LoadAsync"/> reads the model from: a model placed in | |
| /// StreamingAssets/Audio2Lipsync/ wins (override); otherwise, in the editor, the packaged one. | |
| /// </summary> | |
| public static string DefaultPath | |
| { | |
| get | |
| { | |
| if (!File.Exists(StreamingAssetsPath) && PackagedPath != null) return PackagedPath; | |
| return StreamingAssetsPath; | |
| } | |
| } | |
| /// <summary> | |
| /// Loads the default model. Android / WebGL keep StreamingAssets inside the package or on a | |
| /// server, so those are fetched with UnityWebRequest; everywhere else it is a plain file read. | |
| /// </summary> | |
| public static async Awaitable<Model> LoadAsync() | |
| { | |
| var path = DefaultPath; | |
| if (path.Contains("://")) | |
| { | |
| using var req = UnityWebRequest.Get(path); | |
| await req.SendWebRequest(); | |
| if (req.result != UnityWebRequest.Result.Success) | |
| throw new FileNotFoundException($"Audio2Lipsync model not loaded from {path}: {req.error}"); | |
| using var ms = new MemoryStream(req.downloadHandler.data); | |
| return ModelLoader.Load(ms); | |
| } | |
| if (!File.Exists(path)) | |
| throw new FileNotFoundException( | |
| $"Audio2Lipsync model not found: {path}. If the package came from git, install git-lfs and re-resolve it."); | |
| if (new FileInfo(path).Length < 1024 * 1024) | |
| throw new InvalidDataException($"{path} is a Git LFS pointer, not the model. Install git-lfs and re-resolve the package."); | |
| return ModelLoader.Load(path); | |
| } | |
| } | |
| } | |