Skip to content

Commit

Permalink
com.rest.elevenlabs 3.2.5 (#62)
Browse files Browse the repository at this point in the history
- enabled VoiceClip to be Serializable
  • Loading branch information
StephenHodgson committed Jan 30, 2024
1 parent 53fd541 commit 5852e47
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 13 deletions.
48 changes: 36 additions & 12 deletions ElevenLabs/Packages/com.rest.elevenlabs/Runtime/Common/VoiceClip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,59 @@
namespace ElevenLabs
{
[Preserve]
public sealed class VoiceClip
[Serializable]
public sealed class VoiceClip : ISerializationCallbackReceiver
{
[Preserve]
internal VoiceClip(string id, string text, Voice voice, AudioClip audioClip, string cachedPath)
{
Id = id;
Text = text;
Voice = voice;
this.id = id;
this.text = text;
this.voice = voice;
TextHash = $"{id}{text}".GenerateGuid();
AudioClip = audioClip;
CachedPath = cachedPath;
textHash = TextHash.ToString();
this.audioClip = audioClip;
this.cachedPath = cachedPath;
}

[SerializeField]
private string id;

[Preserve]
public string Id { get; }
public string Id => id;

[SerializeField]
private string text;

[Preserve]
public string Text { get; }
public string Text => text;

[SerializeField]
private Voice voice;

[Preserve]
public Voice Voice { get; }
public Voice Voice => voice;

[SerializeField]
private string textHash;

[Preserve]
public Guid TextHash { get; }
public Guid TextHash { get; private set; }

[SerializeField]
private AudioClip audioClip;

[Preserve]
public AudioClip AudioClip { get; }
public AudioClip AudioClip => audioClip;

[SerializeField]
private string cachedPath;

[Preserve]
public string CachedPath { get; }
public string CachedPath => cachedPath;

public void OnBeforeSerialize() => textHash = TextHash.ToString();

public void OnAfterDeserialize() => TextHash = Guid.Parse(textHash);
}
}
2 changes: 1 addition & 1 deletion ElevenLabs/Packages/com.rest.elevenlabs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "ElevenLabs",
"description": "A non-official Eleven Labs voice synthesis RESTful client.",
"keywords": [],
"version": "3.2.4",
"version": "3.2.5",
"unity": "2021.3",
"documentationUrl": "https://github.com/RageAgainstThePixel/com.rest.elevenlabs#documentation",
"changelogUrl": "https://github.com/RageAgainstThePixel/com.rest.elevenlabs/releases",
Expand Down

0 comments on commit 5852e47

Please sign in to comment.