-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added additional request properties for TextToSpeechRequest - `previous_text`, `next_text`, `previous_request_ids`, `next_request_ids`, `languageCode`, `withTimestamps` - Added support for transcription timestamps - Added support for language code in TextToSpeechRequest --------- Co-authored-by: Milan Mikuš <[email protected]> Co-authored-by: Milan Mikuš <[email protected]> Co-authored-by: Tom Kail <[email protected]> Co-authored-by: Tom Kail <[email protected]>
- Loading branch information
1 parent
41570cb
commit ae0b152
Showing
12 changed files
with
355 additions
and
81 deletions.
There are no files selected for viewing
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
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
42 changes: 42 additions & 0 deletions
42
ElevenLabs-DotNet/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,42 @@ | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
using System.Text.Json.Serialization; | ||
|
||
namespace ElevenLabs | ||
{ | ||
/// <summary> | ||
/// Represents timing information for a single character in the transcript | ||
/// </summary> | ||
public class TimestampedTranscriptCharacter | ||
{ | ||
public TimestampedTranscriptCharacter() { } | ||
|
||
internal TimestampedTranscriptCharacter(string character, double startTime, double endTime) | ||
{ | ||
Character = character; | ||
StartTime = startTime; | ||
EndTime = endTime; | ||
} | ||
|
||
/// <summary> | ||
/// The character being spoken | ||
/// </summary> | ||
[JsonInclude] | ||
[JsonPropertyName("character")] | ||
public string Character { get; private set; } | ||
|
||
/// <summary> | ||
/// The time in seconds when this character starts being spoken | ||
/// </summary> | ||
[JsonInclude] | ||
[JsonPropertyName("character_start_times_seconds")] | ||
public double StartTime { get; private set; } | ||
|
||
/// <summary> | ||
/// The time in seconds when this character finishes being spoken | ||
/// </summary> | ||
[JsonInclude] | ||
[JsonPropertyName("character_end_times_seconds")] | ||
public double EndTime { get; private set; } | ||
} | ||
} |
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
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,16 @@ | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
namespace ElevenLabs.Extensions | ||
{ | ||
public static class Extensions | ||
{ | ||
public static int GetSampleRate(this OutputFormat format) => format switch | ||
{ | ||
OutputFormat.PCM_16000 => 16000, | ||
OutputFormat.PCM_22050 => 22050, | ||
OutputFormat.PCM_24000 => 24000, | ||
OutputFormat.PCM_44100 => 44100, | ||
_ => 44100 | ||
}; | ||
} | ||
} |
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,37 @@ | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
using System.Text.Json.Serialization; | ||
|
||
namespace ElevenLabs.TextToSpeech | ||
{ | ||
internal sealed class Alignment | ||
{ | ||
[JsonInclude] | ||
[JsonPropertyName("characters")] | ||
public string[] Characters { get; private set; } | ||
|
||
[JsonInclude] | ||
[JsonPropertyName("character_start_times_seconds")] | ||
public double[] StartTimes { get; private set; } | ||
|
||
[JsonInclude] | ||
[JsonPropertyName("character_end_times_seconds")] | ||
public double[] EndTimes { get; private set; } | ||
|
||
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; | ||
} | ||
} | ||
} |
Oops, something went wrong.