generated from RageAgainstThePixel/upm-template
-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds streaming versions and refactors code (#102)
Adds streaming versions and refactors code significantly to avoid duplication
- Loading branch information
Showing
14 changed files
with
791 additions
and
275 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
ElevenLabs/Packages/com.rest.elevenlabs/Runtime/Common/TimestampedTranscriptCharacter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
using Newtonsoft.Json; | ||
using UnityEngine.Scripting; | ||
|
||
namespace ElevenLabs | ||
{ | ||
/// <summary> | ||
/// Represents timing information for a single character in the transcript | ||
/// </summary> | ||
[Preserve] | ||
public class TimestampedTranscriptCharacter | ||
{ | ||
[Preserve] | ||
[JsonConstructor] | ||
internal TimestampedTranscriptCharacter(string character, double startTime, double endTime) | ||
{ | ||
Character = character; | ||
StartTime = startTime; | ||
EndTime = endTime; | ||
} | ||
|
||
/// <summary> | ||
/// The character being spoken | ||
/// </summary> | ||
[Preserve] | ||
[JsonProperty("character")] | ||
public string Character { get; } | ||
|
||
/// <summary> | ||
/// The time in seconds when this character starts being spoken | ||
/// </summary> | ||
[Preserve] | ||
[JsonProperty("character_start_times_seconds")] | ||
public double StartTime { get; } | ||
|
||
/// <summary> | ||
/// The time in seconds when this character finishes being spoken | ||
/// </summary> | ||
[Preserve] | ||
[JsonProperty("character_end_times_seconds")] | ||
public double EndTime { get; } | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...enLabs/Packages/com.rest.elevenlabs/Runtime/Common/TimestampedTranscriptCharacter.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
ElevenLabs/Packages/com.rest.elevenlabs/Runtime/Common/TranscribedVoiceClip.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
using ElevenLabs.Voices; | ||
using System; | ||
using UnityEngine; | ||
using UnityEngine.Scripting; | ||
|
||
namespace ElevenLabs | ||
{ | ||
/// <summary> | ||
/// Represents timing information for a single character in the transcript | ||
/// </summary> | ||
[Preserve] | ||
[Serializable] | ||
public class TranscribedVoiceClip : VoiceClip | ||
{ | ||
[Preserve] | ||
internal TranscribedVoiceClip(TimestampedTranscriptCharacter[] timestampedTranscriptCharacters, string id, string text, Voice voice, AudioClip audioClip, string cachedPath) | ||
: base(id, text, voice, audioClip, cachedPath) | ||
{ | ||
TimestampedTranscriptCharacters = timestampedTranscriptCharacters; | ||
} | ||
|
||
[Preserve] | ||
public TimestampedTranscriptCharacter[] TimestampedTranscriptCharacters { get; } | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
ElevenLabs/Packages/com.rest.elevenlabs/Runtime/Common/TranscribedVoiceClip.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
ElevenLabs/Packages/com.rest.elevenlabs/Runtime/TextToSpeech/Alignment.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
using Newtonsoft.Json; | ||
using UnityEngine.Scripting; | ||
|
||
namespace ElevenLabs.TextToSpeech | ||
{ | ||
[Preserve] | ||
internal sealed class Alignment | ||
{ | ||
[Preserve] | ||
[JsonConstructor] | ||
internal Alignment( | ||
[JsonProperty("characters")] string[] characters, | ||
[JsonProperty("character_start_times_seconds")] double[] startTimes, | ||
[JsonProperty("character_end_times_seconds")] double[] endTimes) | ||
{ | ||
Characters = characters; | ||
StartTimes = startTimes; | ||
EndTimes = endTimes; | ||
} | ||
|
||
[Preserve] | ||
[JsonProperty("characters")] | ||
public string[] Characters { get; } | ||
|
||
[Preserve] | ||
[JsonProperty("character_start_times_seconds")] | ||
public double[] StartTimes { get; } | ||
|
||
[Preserve] | ||
[JsonProperty("character_end_times_seconds")] | ||
public double[] EndTimes { get; } | ||
|
||
[Preserve] | ||
public static implicit operator TimestampedTranscriptCharacter[](Alignment alignment) | ||
{ | ||
if (alignment == null) { return null; } | ||
var characters = alignment.Characters; | ||
var startTimes = alignment.StartTimes; | ||
var endTimes = alignment.EndTimes; | ||
var timestampedTranscriptCharacters = new TimestampedTranscriptCharacter[characters.Length]; | ||
|
||
for (var i = 0; i < characters.Length; i++) | ||
{ | ||
timestampedTranscriptCharacters[i] = new TimestampedTranscriptCharacter(characters[i], startTimes[i], endTimes[i]); | ||
} | ||
|
||
return timestampedTranscriptCharacters; | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
ElevenLabs/Packages/com.rest.elevenlabs/Runtime/TextToSpeech/Alignment.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.