Skip to content

Formerly KrillinAI, VideoTranslation and Dubbing Tool for 120+ Languages. Open-source AI workspace for creators, powered by Codex. Video downloader, video translation, create videos, images, audios, and edits with Agents in one place. For your Social Media like YouTube, TikTok, Instagram, etc.

feat: add pipeline service adapter

wulien53a1bb6b59d5
diff --git a/internal/pipeline/service_adapter.go b/internal/pipeline/service_adapter.go
new file mode 100644
index 00000000..e14c6ebf
--- /dev/null
+++ b/internal/pipeline/service_adapter.go
@@ -0,0 +1,53 @@
+package pipeline
+
+import (
+ "context"
+ "krillin-ai/internal/service"
+ "krillin-ai/internal/types"
+)
+
+type StageService interface {
+ PrepareMedia(context.Context, *types.SubtitleTaskStepParam) error
+ GenerateSubtitlesFromAudio(context.Context, *types.SubtitleTaskStepParam) error
+ GenerateSpeechFromSRT(context.Context, *types.SubtitleTaskStepParam) error
+ FinalizeSubtitleResults(context.Context, *types.SubtitleTaskStepParam) error
+ DownloadYouTubeSubtitle(context.Context, *service.YoutubeSubtitleReq) (string, error)
+ ProcessYouTubeSubtitle(context.Context, *service.YoutubeSubtitleReq) (string, error)
+ RenderVideo(context.Context, service.RenderVideoRequest) (string, error)
+}
+
+type ServiceAdapter struct {
+ svc *service.Service
+}
+
+func NewServiceAdapter(svc *service.Service) *ServiceAdapter {
+ return &ServiceAdapter{svc: svc}
+}
+
+func (a *ServiceAdapter) PrepareMedia(ctx context.Context, p *types.SubtitleTaskStepParam) error {
+ return a.svc.PrepareMedia(ctx, p)
+}
+
+func (a *ServiceAdapter) GenerateSubtitlesFromAudio(ctx context.Context, p *types.SubtitleTaskStepParam) error {
+ return a.svc.GenerateSubtitlesFromAudio(ctx, p)
+}
+
+func (a *ServiceAdapter) GenerateSpeechFromSRT(ctx context.Context, p *types.SubtitleTaskStepParam) error {
+ return a.svc.GenerateSpeechFromSRT(ctx, p)
+}
+
+func (a *ServiceAdapter) FinalizeSubtitleResults(ctx context.Context, p *types.SubtitleTaskStepParam) error {
+ return a.svc.FinalizeSubtitleResults(ctx, p)
+}
+
+func (a *ServiceAdapter) DownloadYouTubeSubtitle(ctx context.Context, r *service.YoutubeSubtitleReq) (string, error) {
+ return a.svc.DownloadYouTubeSubtitle(ctx, r)
+}
+
+func (a *ServiceAdapter) ProcessYouTubeSubtitle(ctx context.Context, r *service.YoutubeSubtitleReq) (string, error) {
+ return a.svc.ProcessYouTubeSubtitle(ctx, r)
+}
+
+func (a *ServiceAdapter) RenderVideo(ctx context.Context, r service.RenderVideoRequest) (string, error) {
+ return a.svc.RenderVideo(ctx, r)
+}
diff --git a/internal/pipeline/service_adapter_test.go b/internal/pipeline/service_adapter_test.go
new file mode 100644
index 00000000..5d522352
--- /dev/null
+++ b/internal/pipeline/service_adapter_test.go
@@ -0,0 +1,14 @@
+package pipeline
+
+import (
+ "krillin-ai/internal/service"
+ "testing"
+)
+
+func TestNewServiceAdapterKeepsService(t *testing.T) {
+ svc := &service.Service{}
+ adapter := NewServiceAdapter(svc)
+ if adapter == nil {
+ t.Fatalf("NewServiceAdapter() returned nil")
+ }
+}