Skip to content

Commit 4600769

Browse files
com.rest.elevenlabs 3.3.1 (#96)
- Fix DubbingRequest.DropBackgroundAudio flag not properly being set - Added DubbingRequest.UseProfanityFilter flag - Added previous text input parameter to TextToSpeechRequest --------- Co-authored-by: Benjamin van der Wolf <34794758+Bvanderwolf@users.noreply.github.com>
1 parent 5060287 commit 4600769

File tree

5 files changed

+54
-9
lines changed

5 files changed

+54
-9
lines changed

Runtime/Dubbing/DubbingEndpoint.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,16 @@ public async Task<DubbingProjectMetadata> DubAsync(DubbingRequest request, int?
9797
{
9898
payload.AddField("highest_resolution", request.HighestResolution.Value.ToString());
9999
}
100+
101+
if (request.DropBackgroundAudio.HasValue)
102+
{
103+
payload.AddField("drop_background_audio", request.DropBackgroundAudio.ToString().ToLower());
104+
}
105+
106+
if (request.UseProfanityFilter.HasValue)
107+
{
108+
payload.AddField("use_profanity_filter", request.UseProfanityFilter.ToString().ToLower());
109+
}
100110
}
101111
finally
102112
{

Runtime/Dubbing/DubbingRequest.cs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ public DubbingRequest(
2121
int? endTime = null,
2222
bool? highestResolution = null,
2323
bool? dropBackgroundAudio = null,
24+
bool? useProfanityFilter = null,
2425
string projectName = null)
25-
: this(new[] { filePath }, targetLanguage, sourceLanguage, numberOfSpeakers, watermark, startTime, endTime, highestResolution, dropBackgroundAudio, projectName)
26+
: this(new[] { filePath }, targetLanguage, sourceLanguage, numberOfSpeakers, watermark, startTime, endTime, highestResolution, dropBackgroundAudio, useProfanityFilter, projectName)
2627
{
2728
}
2829

@@ -36,8 +37,9 @@ public DubbingRequest(
3637
int? endTime = null,
3738
bool? highestResolution = null,
3839
bool? dropBackgroundAudio = null,
40+
bool? useProfanityFilter = null,
3941
string projectName = null)
40-
: this(targetLanguage, null, filePaths, sourceLanguage, numberOfSpeakers, watermark, startTime, endTime, highestResolution, dropBackgroundAudio, projectName)
42+
: this(targetLanguage, null, filePaths, sourceLanguage, numberOfSpeakers, watermark, startTime, endTime, highestResolution, dropBackgroundAudio, useProfanityFilter, projectName)
4143
{
4244
}
4345

@@ -51,17 +53,29 @@ public DubbingRequest(
5153
int? endTime = null,
5254
bool? highestResolution = null,
5355
bool? dropBackgroundAudio = null,
56+
bool? useProfanityFilter = null,
5457
string projectName = null)
55-
: this(targetLanguage, sourceUrl, null, sourceLanguage, numberOfSpeakers, watermark, startTime, endTime, highestResolution, dropBackgroundAudio, projectName)
58+
: this(targetLanguage, sourceUrl, null, sourceLanguage, numberOfSpeakers, watermark, startTime, endTime, highestResolution, dropBackgroundAudio, useProfanityFilter, projectName)
5659
{
5760
}
5861

59-
public DubbingRequest(AudioClip audioClip, string targetLanguage, string sourceLanguage = null, int? numberOfSpeakers = null, bool? watermark = null, int? startTime = null, int? endTime = null, bool? highestResolution = null, bool? dropBackgroundAudio = null, string projectName = null)
60-
: this(new[] { audioClip }, targetLanguage, sourceLanguage, numberOfSpeakers, watermark, startTime, endTime, highestResolution, dropBackgroundAudio, projectName)
62+
public DubbingRequest(AudioClip audioClip, string targetLanguage, string sourceLanguage = null, int? numberOfSpeakers = null, bool? watermark = null, int? startTime = null, int? endTime = null, bool? highestResolution = null, bool? dropBackgroundAudio = null, bool? useProfanityFilter = null, string projectName = null)
63+
: this(new[] { audioClip }, targetLanguage, sourceLanguage, numberOfSpeakers, watermark, startTime, endTime, highestResolution, dropBackgroundAudio, useProfanityFilter, projectName)
6164
{
6265
}
6366

64-
public DubbingRequest(IEnumerable<AudioClip> audioClips, string targetLanguage, string sourceLanguage = null, int? numberOfSpeakers = null, bool? watermark = null, int? startTime = null, int? endTime = null, bool? highestResolution = null, bool? dropBackgroundAudio = null, string projectName = null)
67+
public DubbingRequest(
68+
IEnumerable<AudioClip> audioClips,
69+
string targetLanguage,
70+
string sourceLanguage = null,
71+
int? numberOfSpeakers = null,
72+
bool? watermark = null,
73+
int? startTime = null,
74+
int? endTime = null,
75+
bool? highestResolution = null,
76+
bool? dropBackgroundAudio = null,
77+
bool? useProfanityFilter = null,
78+
string projectName = null)
6579
{
6680
if (audioClips == null)
6781
{
@@ -88,6 +102,7 @@ public DubbingRequest(IEnumerable<AudioClip> audioClips, string targetLanguage,
88102
EndTime = endTime;
89103
HighestResolution = highestResolution;
90104
DropBackgroundAudio = dropBackgroundAudio;
105+
UseProfanityFilter = useProfanityFilter;
91106
ProjectName = projectName;
92107
var files = new List<(string, string, Stream)>(clips.Count);
93108
files.AddRange((from audioClip in clips let stream = new MemoryStream(audioClip.EncodeToWav()) select (audioClip.name, "audio/wav", stream)).Select(value => ((string, string, Stream))value));
@@ -105,6 +120,7 @@ private DubbingRequest(
105120
int? endTime = null,
106121
bool? highestResolution = null,
107122
bool? dropBackgroundAudio = null,
123+
bool? useProfanityFilter = null,
108124
string projectName = null)
109125
{
110126
if (string.IsNullOrWhiteSpace(targetLanguage))
@@ -167,6 +183,7 @@ private DubbingRequest(
167183
EndTime = endTime;
168184
HighestResolution = highestResolution;
169185
DropBackgroundAudio = dropBackgroundAudio;
186+
UseProfanityFilter = useProfanityFilter;
170187
ProjectName = projectName;
171188
}
172189

@@ -229,6 +246,11 @@ private DubbingRequest(
229246
/// </summary>
230247
public bool? DropBackgroundAudio { get; }
231248

249+
/// <summary>
250+
/// [BETA] Whether transcripts should have profanities censored with the words '[censored]'.
251+
/// </summary>
252+
public bool? UseProfanityFilter { get; }
253+
232254
/// <summary>
233255
/// Name of the dubbing project.
234256
/// </summary>

Runtime/TextToSpeech/TextToSpeechRequest.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ namespace ElevenLabs.TextToSpeech
1313
public sealed class TextToSpeechRequest
1414
{
1515
[Preserve]
16-
public TextToSpeechRequest(Voice voice, string text, Encoding encoding = null, VoiceSettings voiceSettings = null, OutputFormat outputFormat = OutputFormat.MP3_44100_128, int? optimizeStreamingLatency = null, Model model = null)
16+
public TextToSpeechRequest(
17+
Voice voice,
18+
string text,
19+
Encoding encoding = null,
20+
VoiceSettings voiceSettings = null,
21+
OutputFormat outputFormat = OutputFormat.MP3_44100_128,
22+
int? optimizeStreamingLatency = null,
23+
Model model = null,
24+
string previousText = null)
1725
{
1826
if (string.IsNullOrWhiteSpace(text))
1927
{
@@ -40,6 +48,7 @@ public TextToSpeechRequest(Voice voice, string text, Encoding encoding = null, V
4048
Model = model ?? Models.Model.MultiLingualV2;
4149
Voice = voice;
4250
VoiceSettings = voiceSettings ?? voice.Settings ?? throw new ArgumentNullException(nameof(voiceSettings));
51+
PreviousText = previousText;
4352
OutputFormat = outputFormat;
4453
OptimizeStreamingLatency = optimizeStreamingLatency;
4554
}
@@ -60,6 +69,10 @@ public TextToSpeechRequest(Voice voice, string text, Encoding encoding = null, V
6069
[JsonProperty("voice_settings")]
6170
public VoiceSettings VoiceSettings { get; internal set; }
6271

72+
[Preserve]
73+
[JsonProperty("previous_text")]
74+
public string PreviousText { get; }
75+
6376
[Preserve]
6477
[JsonIgnore]
6578
public OutputFormat OutputFormat { get; }

Tests/Test_Fixture_08_Dubbing.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public async Task Test_02_Dubbing_Url()
6868
{
6969
Assert.NotNull(ElevenLabsClient.DubbingEndpoint);
7070

71-
var request = new DubbingRequest(new Uri("https://youtu.be/Zo5-rhYOlNk"), "ja", "en", 1, true);
71+
var request = new DubbingRequest(new Uri("https://youtu.be/Zo5-rhYOlNk"), "ja", "en", 1, watermark: true, dropBackgroundAudio: true);
7272
var metadata = await ElevenLabsClient.DubbingEndpoint.DubAsync(request, progress: new Progress<DubbingProjectMetadata>(metadata =>
7373
{
7474
switch (metadata.Status)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "ElevenLabs",
44
"description": "A non-official Eleven Labs voice synthesis RESTful client.",
55
"keywords": [],
6-
"version": "3.3.0",
6+
"version": "3.3.1",
77
"unity": "2021.3",
88
"documentationUrl": "https://github.com/RageAgainstThePixel/com.rest.elevenlabs#documentation",
99
"changelogUrl": "https://github.com/RageAgainstThePixel/com.rest.elevenlabs/releases",

0 commit comments

Comments
 (0)