Skip to content

Commit

Permalink
feat: add overload to accept streams in the dubbing endpoint (#74)
Browse files Browse the repository at this point in the history
Allows files to be streamed directly. This gives more flexibility when
handling files that are privately hosted or not accessible via standard
file paths or Uris.
  • Loading branch information
austinbhale authored Jan 11, 2025
1 parent 5e47158 commit d803be8
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions ElevenLabs-DotNet/Dubbing/DubbingRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public DubbingRequest(
bool? dropBackgroundAudio = null,
bool? useProfanityFilter = null,
string projectName = null)
: this(targetLanguage, null, filePaths, sourceLanguage, numberOfSpeakers, watermark, startTime, endTime, highestResolution, dropBackgroundAudio, useProfanityFilter, projectName)
: this(targetLanguage, null, null, filePaths, sourceLanguage, numberOfSpeakers, watermark, startTime, endTime, highestResolution, dropBackgroundAudio, useProfanityFilter, projectName)
{
}

Expand All @@ -52,13 +52,30 @@ public DubbingRequest(
bool? dropBackgroundAudio = null,
bool? useProfanityFilter = null,
string projectName = null)
: this(targetLanguage, sourceUrl, null, sourceLanguage, numberOfSpeakers, watermark, startTime, endTime, highestResolution, dropBackgroundAudio, useProfanityFilter, projectName)
: this(targetLanguage, sourceUrl, null, null, sourceLanguage, numberOfSpeakers, watermark, startTime, endTime, highestResolution, dropBackgroundAudio, useProfanityFilter, projectName)
{
}

public DubbingRequest(
List<(string, string, Stream)> files,
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)
: this(targetLanguage, null, files, null, sourceLanguage, numberOfSpeakers, watermark, startTime, endTime, highestResolution, dropBackgroundAudio, useProfanityFilter, projectName)
{
}

private DubbingRequest(
string targetLanguage,
Uri sourceUrl = null,
List<(string, string, Stream)> files = null,
IEnumerable<string> filePaths = null,
string sourceLanguage = null,
int? numberOfSpeakers = null,
Expand All @@ -78,7 +95,7 @@ private DubbingRequest(
throw new ArgumentException("Either sourceUrl or filePaths must be provided.");
}

var files = new List<(string, string, Stream)>();
files ??= [];

if (filePaths != null)
{
Expand Down

0 comments on commit d803be8

Please sign in to comment.