Audio-to-Audio
unity-sentis
ONNX
unity
sentis
inference-engine
on-device
lipsync
facial-animation
arkit
blendshapes
audio2face
Instructions to use Sky-Kim/com.sky.sentis.audio2face 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.audio2face 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/A2FModel.cs from Sky-Kim/com.sky.sentis.audio2face: direct link, hf CLI and curl.
- Browser
- Download file 2.92 kB
-
https://huggingface.co/Sky-Kim/com.sky.sentis.audio2face/resolve/main/Runtime/A2FModel.cs
- Command line
-
hf download hf://Sky-Kim/com.sky.sentis.audio2face/Runtime/A2FModel.cs
-
curl -L -o A2FModel.cs https://huggingface.co/Sky-Kim/com.sky.sentis.audio2face/resolve/main/Runtime/A2FModel.cs
2.92 kB
| using System.IO; | |
| using Unity.InferenceEngine; | |
| using UnityEngine; | |
| using UnityEngine.Networking; | |
| namespace Audio2Face | |
| { | |
| /// <summary> | |
| /// Finds and loads the network with no setup step (same scheme as com.sky.sentis.neurosync): | |
| /// - Editor: the ONNX in the package's Models folder, imported as a ModelAsset. | |
| /// - Player: StreamingAssets/Audio2Face/audio2face3d_v3.sentis, written there by the package's build hook for the | |
| /// duration of each build (Float16 weights by default, see A2FBuildSettings). | |
| /// A .sentis you place in StreamingAssets/Audio2Face/ yourself wins in both. | |
| /// </summary> | |
| public static class A2FModel | |
| { | |
| public const string PackageName = "com.sky.sentis.audio2face"; | |
| public const string StreamingAssetsFolder = "Audio2Face"; | |
| public const string BaseName = "audio2face3d_v3"; | |
| public static string StreamingAssetsPath => SentisPath(BaseName); | |
| public static string PackagedOnnxAssetPath => OnnxAssetPath(BaseName); | |
| static string SentisPath(string baseName) => Path.Combine(Application.streamingAssetsPath, StreamingAssetsFolder, baseName + ".sentis"); | |
| static string OnnxAssetPath(string baseName) => $"Packages/{PackageName}/Models/{baseName}.onnx"; | |
| public static ModelAsset PackagedModelAsset => UnityEditor.AssetDatabase.LoadAssetAtPath<ModelAsset>(PackagedOnnxAssetPath); | |
| /// <summary>The Audio2Face-3D network.</summary> | |
| public static Awaitable<Model> LoadAsync() => LoadAsync(BaseName); | |
| static async Awaitable<Model> LoadAsync(string baseName) | |
| { | |
| var path = SentisPath(baseName); | |
| if (!File.Exists(path)) | |
| { | |
| var onnx = OnnxAssetPath(baseName); | |
| var asset = UnityEditor.AssetDatabase.LoadAssetAtPath<ModelAsset>(onnx); | |
| if (asset == null) | |
| throw new FileNotFoundException( | |
| $"Audio2Face model not found: {onnx}. If the package came from git, install git-lfs and re-resolve it."); | |
| return ModelLoader.Load(asset); | |
| } | |
| if (path.Contains("://")) | |
| { | |
| // Android / WebGL keep StreamingAssets inside the app package or on a server. | |
| using var req = UnityWebRequest.Get(path); | |
| await req.SendWebRequest(); | |
| if (req.result != UnityWebRequest.Result.Success) | |
| throw new FileNotFoundException($"Audio2Face 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($"Audio2Face model not found: {path}"); | |
| return ModelLoader.Load(path); | |
| } | |
| } | |
| } | |