Skip to content

Commit

Permalink
Alter handling of start/endtime to be simpler and limit to minutes + …
Browse files Browse the repository at this point in the history
…seconds.
  • Loading branch information
Layoric committed Oct 9, 2024
1 parent 999a409 commit 3f0a1c5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
13 changes: 13 additions & 0 deletions AiServer.ServiceInterface/Generation/ComfyProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,19 @@ private ComfyClient GetClient(MediaProvider provider)
// Last check for null seed
request.Seed ??= Random.Shared.Next();
var comfyWorkflowReq = request.ConvertTo<ComfyWorkflowRequest>();
// Ensure task type is set
comfyWorkflowReq.TaskType = request.TaskType switch
{
AiTaskType.TextToImage => ComfyTaskType.TextToImage,
AiTaskType.ImageToImage => ComfyTaskType.ImageToImage,
AiTaskType.ImageUpscale => ComfyTaskType.ImageUpscale,
AiTaskType.ImageWithMask => ComfyTaskType.ImageWithMask,
AiTaskType.ImageToText => ComfyTaskType.ImageToText,
AiTaskType.TextToAudio => ComfyTaskType.TextToAudio,
AiTaskType.TextToSpeech => ComfyTaskType.TextToSpeech,
AiTaskType.SpeechToText => ComfyTaskType.SpeechToText,
_ => throw new ArgumentOutOfRangeException()
};
comfyWorkflowReq =
comfyWorkflowReq.ApplyModelDefaults(AppConfig.Instance, modelSettings.ConvertTo<ComfyApiModelSettings>());
var response = await comfyClient.PromptGenerationAsync(comfyWorkflowReq, token, waitResult: true);
Expand Down
4 changes: 2 additions & 2 deletions AiServer.ServiceInterface/VideoServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ public async Task<object> Any(TrimVideo request)

private void ValidateTimeFormat(string time, string fieldName)
{
if (!Regex.IsMatch(time, @"^\d{2}:\d{2}$"))
if (!Regex.IsMatch(time, @"^(\d{1,3}):([0-5]\d)$"))
{
throw new ArgumentException($"Invalid {fieldName} format. Expected format: mm:ss");
throw new ArgumentException($"Invalid {fieldName} format. Expected format: m:ss, mm:ss, or mmm:ss");
}
}

Expand Down
8 changes: 4 additions & 4 deletions AiServer.ServiceModel/MediaTransforms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,13 @@ public class CropVideo : IMediaTransform, IReturn<MediaTransformResponse>
[ValidateApiKey]
public class TrimVideo : IMediaTransform, IReturn<MediaTransformResponse>
{
[ApiMember(Description = "The start time of the trimmed video (format: HH:MM:SS)")]
[Description("The start time of the trimmed video (format: HH:MM:SS)")]
[ApiMember(Description = "The start time of the trimmed video (format: MM:SS)")]
[Description("The start time of the trimmed video (format: MM:SS)")]
[Required]
public string StartTime { get; set; }

[ApiMember(Description = "The end time of the trimmed video (format: HH:MM:SS)")]
[Description("The end time of the trimmed video (format: HH:MM:SS)")]
[ApiMember(Description = "The end time of the trimmed video (format: MM:SS)")]
[Description("The end time of the trimmed video (format: MM:SS)")]
public string? EndTime { get; set; }

[Required]
Expand Down

0 comments on commit 3f0a1c5

Please sign in to comment.