From 12fabf3a720625ecef6008e9d086f649607d7490 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 7 Nov 2024 08:35:42 +0100 Subject: [PATCH] ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.434.0 (#15) Co-authored-by: speakeasybot --- .speakeasy/gen.lock | 50 +- .speakeasy/gen.yaml | 3 +- .speakeasy/workflow.lock | 12 +- README.md | 7 - RELEASES.md | 12 +- codeSamples.yaml | 61 +++ docs/models/components/audioresponse.md | 10 + docs/models/components/bodygenaudiototext.md | 9 +- .../components/livevideotovideoparams.md | 11 + .../components/livevideotovideoresponse.md | 11 + docs/models/components/mediaurl.md | 10 + docs/models/components/params.md | 9 + docs/models/components/texttospeechparams.md | 10 + .../operations/genlivevideotovideoresponse.md | 9 + .../operations/gentexttospeechresponse.md | 9 + generate.go | 472 ++++++++++++++++++ livepeer.go | 6 +- models/components/audioresponse.go | 16 + models/components/bodygenaudiototext.go | 9 + models/components/livevideotovideoparams.go | 61 +++ models/components/livevideotovideoresponse.go | 25 + models/components/mediaurl.go | 16 + models/components/texttospeechparams.go | 48 ++ models/operations/genlivevideotovideo.go | 27 + models/operations/gentexttospeech.go | 27 + 25 files changed, 910 insertions(+), 30 deletions(-) create mode 100644 docs/models/components/audioresponse.md create mode 100644 docs/models/components/livevideotovideoparams.md create mode 100644 docs/models/components/livevideotovideoresponse.md create mode 100644 docs/models/components/mediaurl.md create mode 100644 docs/models/components/params.md create mode 100644 docs/models/components/texttospeechparams.md create mode 100644 docs/models/operations/genlivevideotovideoresponse.md create mode 100644 docs/models/operations/gentexttospeechresponse.md create mode 100644 models/components/audioresponse.go create mode 100644 models/components/livevideotovideoparams.go create mode 100644 models/components/livevideotovideoresponse.go create mode 100644 models/components/mediaurl.go create mode 100644 models/components/texttospeechparams.go create mode 100644 models/operations/genlivevideotovideo.go create mode 100644 models/operations/gentexttospeech.go diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index d2fa8c2..39d4988 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,21 +1,21 @@ lockVersion: 2.0.0 id: 98621ff3-f200-4a5c-9c69-bc1fe845e39c management: - docChecksum: a140881cbcff74961991f5dfff13f0a0 + docChecksum: c22f8c1b01f75ba608165e53e64fb450 docVersion: 0.0.0 - speakeasyVersion: 1.421.2 - generationVersion: 2.438.15 - releaseVersion: 0.4.3 - configChecksum: c6fd68f564c3f98964f8fd3bc391d9d4 + speakeasyVersion: 1.434.0 + generationVersion: 2.452.0 + releaseVersion: 0.5.0 + configChecksum: 650e15e081d1eb4ab47980ef37b6a151 repoURL: https://github.com/livepeer/livepeer-ai-go.git installationURL: https://github.com/livepeer/livepeer-ai-go features: go: additionalDependencies: 0.1.0 constsAndDefaults: 0.1.6 - core: 3.5.13 + core: 3.5.15 defaultEnabledRetries: 0.2.0 - envVarSecurityUsage: 0.3.1 + envVarSecurityUsage: 0.3.2 globalSecurity: 2.82.10 globalSecurityCallbacks: 0.1.0 globalSecurityFlattening: 0.1.0 @@ -25,11 +25,13 @@ features: responseFormat: 0.1.2 retries: 2.83.0 sdkHooks: 0.1.0 - unions: 2.85.9 + tests: 0.6.0 + unions: 2.85.10 uploadStreams: 0.1.0 generatedFiles: - .gitattributes - /models/components/apierror.go + - /models/components/audioresponse.go - /models/components/bodygenaudiototext.go - /models/components/bodygenimagetoimage.go - /models/components/bodygenimagetotext.go @@ -41,21 +43,27 @@ generatedFiles: - /models/components/httpmetadata.go - /models/components/imageresponse.go - /models/components/imagetotextresponse.go + - /models/components/livevideotovideoparams.go + - /models/components/livevideotovideoresponse.go - /models/components/llmresponse.go - /models/components/masksresponse.go - /models/components/media.go + - /models/components/mediaurl.go - /models/components/security.go - /models/components/textresponse.go - /models/components/texttoimageparams.go + - /models/components/texttospeechparams.go - /models/components/validationerror.go - /models/components/videoresponse.go - /models/operations/genaudiototext.go - /models/operations/genimagetoimage.go - /models/operations/genimagetotext.go - /models/operations/genimagetovideo.go + - /models/operations/genlivevideotovideo.go - /models/operations/genllm.go - /models/operations/gensegmentanything2.go - /models/operations/gentexttoimage.go + - /models/operations/gentexttospeech.go - /models/operations/genupscale.go - /models/sdkerrors/httperror.go - /models/sdkerrors/httpvalidationerror.go @@ -63,6 +71,7 @@ generatedFiles: - USAGE.md - docs/models/components/apierror.md - docs/models/components/audio.md + - docs/models/components/audioresponse.md - docs/models/components/bodygenaudiototext.md - docs/models/components/bodygenimagetoimage.md - docs/models/components/bodygenimagetotext.md @@ -79,22 +88,29 @@ generatedFiles: - docs/models/components/image.md - docs/models/components/imageresponse.md - docs/models/components/imagetotextresponse.md + - docs/models/components/livevideotovideoparams.md + - docs/models/components/livevideotovideoresponse.md - docs/models/components/llmresponse.md - docs/models/components/loc.md - docs/models/components/masksresponse.md - docs/models/components/media.md + - docs/models/components/mediaurl.md + - docs/models/components/params.md - docs/models/components/security.md - docs/models/components/textresponse.md - docs/models/components/texttoimageparams.md + - docs/models/components/texttospeechparams.md - docs/models/components/validationerror.md - docs/models/components/videoresponse.md - docs/models/operations/genaudiototextresponse.md - docs/models/operations/genimagetoimageresponse.md - docs/models/operations/genimagetotextresponse.md - docs/models/operations/genimagetovideoresponse.md + - docs/models/operations/genlivevideotovideoresponse.md - docs/models/operations/genllmresponse.md - docs/models/operations/gensegmentanything2response.md - docs/models/operations/gentexttoimageresponse.md + - docs/models/operations/gentexttospeechresponse.md - docs/models/operations/genupscaleresponse.md - docs/models/sdkerrors/httperror.md - docs/models/sdkerrors/httpvalidationerror.md @@ -261,3 +277,21 @@ examples: "400": application/json: {"detail": {"msg": ""}} "422": {} + genLiveVideoToVideo: + speakeasy-default-gen-live-video-to-video: + requestBody: + application/json: {"subscribe_url": "https://soulful-lava.org/", "publish_url": "https://vain-tabletop.biz"} + responses: + "200": + application/json: {"subscribe_url": "https://vain-kiss.name", "publish_url": "https://frail-duffel.com"} + "400": + application/json: {"detail": {"msg": ""}} + "422": {} + genTextToSpeech: + speakeasy-default-gen-text-to-speech: + responses: + "200": + application/json: {"audio": {"url": "https://accurate-parsnip.net/"}} + "400": + application/json: {"detail": {"msg": ""}} + "422": {} diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index b108573..85a3b6d 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -11,8 +11,9 @@ generation: requestResponseComponentNamesFeb2024: true auth: oAuth2ClientCredentialsEnabled: true + oAuth2PasswordEnabled: false go: - version: 0.4.3 + version: 0.5.0 additionalDependencies: {} allowUnknownFieldsInWeakUnions: false clientServerStatusCodesAsErrors: true diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 04fb85a..545c641 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,9 +1,9 @@ -speakeasyVersion: 1.421.2 +speakeasyVersion: 1.434.0 sources: livepeerai-OAS: sourceNamespace: livepeerai-oas - sourceRevisionDigest: sha256:42e3e9a25622d367c70f1f200afa559ec6a2c4d9b65014dd76da56f8e1beb487 - sourceBlobDigest: sha256:ad0b2e92bea306b60b1929309669cb1c3ca574325bb0ab4a2e44949fc8249a9f + sourceRevisionDigest: sha256:68a61825188a0a0d306025e6f6f18a573e5510932bdb5c8cdf64e2a3b0e97589 + sourceBlobDigest: sha256:c56907fa67feba848782a2720c447e2d442b420d4c1feae871ac97b3476e2c08 tags: - latest - main @@ -16,10 +16,10 @@ targets: livepeerai-go: source: livepeerai-OAS sourceNamespace: livepeerai-oas - sourceRevisionDigest: sha256:42e3e9a25622d367c70f1f200afa559ec6a2c4d9b65014dd76da56f8e1beb487 - sourceBlobDigest: sha256:ad0b2e92bea306b60b1929309669cb1c3ca574325bb0ab4a2e44949fc8249a9f + sourceRevisionDigest: sha256:68a61825188a0a0d306025e6f6f18a573e5510932bdb5c8cdf64e2a3b0e97589 + sourceBlobDigest: sha256:c56907fa67feba848782a2720c447e2d442b420d4c1feae871ac97b3476e2c08 codeSamplesNamespace: code-samples-go-livepeerai-go - codeSamplesRevisionDigest: sha256:36bfad51481a38664404f8053d44846222f0d7fa53c6f1462a5bd1a1e284bd08 + codeSamplesRevisionDigest: sha256:6f6f16aaab8d191a327c8fb379b53670198d7231a4c711afec0eb42edaa85cdb workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/README.md b/README.md index 88ac5cd..7e9046d 100644 --- a/README.md +++ b/README.md @@ -308,12 +308,6 @@ func main() { ``` - -## Special Types - - - - ## Summary @@ -331,7 +325,6 @@ Livepeer AI Runner: An application to run AI pipelines * [Server Selection](#server-selection) * [Custom HTTP Client](#custom-http-client) * [Authentication](#authentication) -* [Special Types](#special-types) diff --git a/RELEASES.md b/RELEASES.md index 254638e..af7e7e4 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -88,4 +88,14 @@ Based on: ### Generated - [go v0.4.3] . ### Releases -- [Go v0.4.3] https://github.com/livepeer/livepeer-ai-go/releases/tag/v0.4.3 - . \ No newline at end of file +- [Go v0.4.3] https://github.com/livepeer/livepeer-ai-go/releases/tag/v0.4.3 - . + +## 2024-11-07 00:25:54 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.434.0 (2.452.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [go v0.5.0] . +### Releases +- [Go v0.5.0] https://github.com/livepeer/livepeer-ai-go/releases/tag/v0.5.0 - . \ No newline at end of file diff --git a/codeSamples.yaml b/codeSamples.yaml index 61e7f01..6030280 100644 --- a/codeSamples.yaml +++ b/codeSamples.yaml @@ -164,6 +164,38 @@ actions: // handle response } } + - target: $["paths"]["/live-video-to-video"]["post"] + update: + x-codeSamples: + - lang: go + label: genLiveVideoToVideo + source: |- + package main + + import( + livepeeraigo "github.com/livepeer/livepeer-ai-go" + "context" + "github.com/livepeer/livepeer-ai-go/models/components" + "log" + ) + + func main() { + s := livepeeraigo.New( + livepeeraigo.WithSecurity(""), + ) + + ctx := context.Background() + res, err := s.Generate.LiveVideoToVideo(ctx, components.LiveVideoToVideoParams{ + SubscribeURL: "https://soulful-lava.org/", + PublishURL: "https://vain-tabletop.biz", + }) + if err != nil { + log.Fatal(err) + } + if res.LiveVideoToVideoResponse != nil { + // handle response + } + } - target: $["paths"]["/llm"]["post"] update: x-codeSamples: @@ -266,6 +298,35 @@ actions: // handle response } } + - target: $["paths"]["/text-to-speech"]["post"] + update: + x-codeSamples: + - lang: go + label: genTextToSpeech + source: |- + package main + + import( + livepeeraigo "github.com/livepeer/livepeer-ai-go" + "context" + "github.com/livepeer/livepeer-ai-go/models/components" + "log" + ) + + func main() { + s := livepeeraigo.New( + livepeeraigo.WithSecurity(""), + ) + + ctx := context.Background() + res, err := s.Generate.TextToSpeech(ctx, components.TextToSpeechParams{}) + if err != nil { + log.Fatal(err) + } + if res.AudioResponse != nil { + // handle response + } + } - target: $["paths"]["/upscale"]["post"] update: x-codeSamples: diff --git a/docs/models/components/audioresponse.md b/docs/models/components/audioresponse.md new file mode 100644 index 0000000..904a6bd --- /dev/null +++ b/docs/models/components/audioresponse.md @@ -0,0 +1,10 @@ +# AudioResponse + +Response model for audio generation. + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | +| `Audio` | [components.MediaURL](../../models/components/mediaurl.md) | :heavy_check_mark: | The generated audio. | \ No newline at end of file diff --git a/docs/models/components/bodygenaudiototext.md b/docs/models/components/bodygenaudiototext.md index 493921c..67dd27c 100644 --- a/docs/models/components/bodygenaudiototext.md +++ b/docs/models/components/bodygenaudiototext.md @@ -3,7 +3,8 @@ ## Fields -| Field | Type | Required | Description | -| ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- | -| `Audio` | [components.Audio](../../models/components/audio.md) | :heavy_check_mark: | Uploaded audio file to be transcribed. | -| `ModelID` | **string* | :heavy_minus_sign: | Hugging Face model ID used for transcription. | \ No newline at end of file +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `Audio` | [components.Audio](../../models/components/audio.md) | :heavy_check_mark: | Uploaded audio file to be transcribed. | +| `ModelID` | **string* | :heavy_minus_sign: | Hugging Face model ID used for transcription. | +| `ReturnTimestamps` | **string* | :heavy_minus_sign: | Return timestamps for the transcribed text. Supported values: 'sentence', 'word', or a string boolean ('true' or 'false'). Default is 'true' ('sentence'). 'false' means no timestamps. 'word' means word-based timestamps. | \ No newline at end of file diff --git a/docs/models/components/livevideotovideoparams.md b/docs/models/components/livevideotovideoparams.md new file mode 100644 index 0000000..6f0d90c --- /dev/null +++ b/docs/models/components/livevideotovideoparams.md @@ -0,0 +1,11 @@ +# LiveVideoToVideoParams + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | +| `SubscribeURL` | *string* | :heavy_check_mark: | Source URL of the incoming stream to subscribe to. | +| `PublishURL` | *string* | :heavy_check_mark: | Destination URL of the outgoing stream to publish. | +| `ModelID` | **string* | :heavy_minus_sign: | Hugging Face model ID used for image generation. | +| `Params` | [*components.Params](../../models/components/params.md) | :heavy_minus_sign: | Initial parameters for the model. | \ No newline at end of file diff --git a/docs/models/components/livevideotovideoresponse.md b/docs/models/components/livevideotovideoresponse.md new file mode 100644 index 0000000..c46fd5e --- /dev/null +++ b/docs/models/components/livevideotovideoresponse.md @@ -0,0 +1,11 @@ +# LiveVideoToVideoResponse + +Response model for live video-to-video generation. + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- | +| `SubscribeURL` | *string* | :heavy_check_mark: | Source URL of the incoming stream to subscribe to | +| `PublishURL` | *string* | :heavy_check_mark: | Destination URL of the outgoing stream to publish to | \ No newline at end of file diff --git a/docs/models/components/mediaurl.md b/docs/models/components/mediaurl.md new file mode 100644 index 0000000..a85c4ca --- /dev/null +++ b/docs/models/components/mediaurl.md @@ -0,0 +1,10 @@ +# MediaURL + +A URL from which media can be accessed. + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | +| `URL` | *string* | :heavy_check_mark: | The URL where the media can be accessed. | \ No newline at end of file diff --git a/docs/models/components/params.md b/docs/models/components/params.md new file mode 100644 index 0000000..08bb9f1 --- /dev/null +++ b/docs/models/components/params.md @@ -0,0 +1,9 @@ +# Params + +Initial parameters for the model. + + +## Fields + +| Field | Type | Required | Description | +| ----------- | ----------- | ----------- | ----------- | \ No newline at end of file diff --git a/docs/models/components/texttospeechparams.md b/docs/models/components/texttospeechparams.md new file mode 100644 index 0000000..861e49b --- /dev/null +++ b/docs/models/components/texttospeechparams.md @@ -0,0 +1,10 @@ +# TextToSpeechParams + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | +| `ModelID` | **string* | :heavy_minus_sign: | Hugging Face model ID used for text to speech generation. | +| `Text` | **string* | :heavy_minus_sign: | Text input for speech generation. | +| `Description` | **string* | :heavy_minus_sign: | Description of speaker to steer text to speech generation. | \ No newline at end of file diff --git a/docs/models/operations/genlivevideotovideoresponse.md b/docs/models/operations/genlivevideotovideoresponse.md new file mode 100644 index 0000000..5c629f8 --- /dev/null +++ b/docs/models/operations/genlivevideotovideoresponse.md @@ -0,0 +1,9 @@ +# GenLiveVideoToVideoResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `LiveVideoToVideoResponse` | [*components.LiveVideoToVideoResponse](../../models/components/livevideotovideoresponse.md) | :heavy_minus_sign: | Successful Response | \ No newline at end of file diff --git a/docs/models/operations/gentexttospeechresponse.md b/docs/models/operations/gentexttospeechresponse.md new file mode 100644 index 0000000..6c1cf66 --- /dev/null +++ b/docs/models/operations/gentexttospeechresponse.md @@ -0,0 +1,9 @@ +# GenTextToSpeechResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------- | --------------------------------------------------------------------- | --------------------------------------------------------------------- | --------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `AudioResponse` | [*components.AudioResponse](../../models/components/audioresponse.md) | :heavy_minus_sign: | Successful Response | \ No newline at end of file diff --git a/generate.go b/generate.go index 146812c..42c630f 100644 --- a/generate.go +++ b/generate.go @@ -1919,3 +1919,475 @@ func (s *Generate) ImageToText(ctx context.Context, request components.BodyGenIm return res, nil } + +// LiveVideoToVideo - Video To Video +// Apply video-like transformations to a provided image. +func (s *Generate) LiveVideoToVideo(ctx context.Context, request components.LiveVideoToVideoParams, opts ...operations.Option) (*operations.GenLiveVideoToVideoResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "genLiveVideoToVideo", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := url.JoinPath(baseURL, "/live-video-to-video") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"400", "401", "422", "4XX", "500", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.GenLiveVideoToVideoResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.LiveVideoToVideoResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.LiveVideoToVideoResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 500: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.HTTPError + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 422: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.HTTPValidationError + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + fallthrough + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// TextToSpeech - Text To Speech +// Generate a text-to-speech audio file based on the provided text input and speaker description. +func (s *Generate) TextToSpeech(ctx context.Context, request components.TextToSpeechParams, opts ...operations.Option) (*operations.GenTextToSpeechResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "genTextToSpeech", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := url.JoinPath(baseURL, "/text-to-speech") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"400", "401", "422", "4XX", "500", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.GenTextToSpeechResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.AudioResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.AudioResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 500: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.HTTPError + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 422: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.HTTPValidationError + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + fallthrough + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} diff --git a/livepeer.go b/livepeer.go index 50a6141..7360e47 100644 --- a/livepeer.go +++ b/livepeer.go @@ -151,9 +151,9 @@ func New(opts ...SDKOption) *Livepeer { sdkConfiguration: sdkConfiguration{ Language: "go", OpenAPIDocVersion: "0.0.0", - SDKVersion: "0.4.3", - GenVersion: "2.438.15", - UserAgent: "speakeasy-sdk/go 0.4.3 2.438.15 0.0.0 github.com/livepeer/livepeer-ai-go", + SDKVersion: "0.5.0", + GenVersion: "2.452.0", + UserAgent: "speakeasy-sdk/go 0.5.0 2.452.0 0.0.0 github.com/livepeer/livepeer-ai-go", Hooks: hooks.New(), }, } diff --git a/models/components/audioresponse.go b/models/components/audioresponse.go new file mode 100644 index 0000000..ecb89f9 --- /dev/null +++ b/models/components/audioresponse.go @@ -0,0 +1,16 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +// AudioResponse - Response model for audio generation. +type AudioResponse struct { + // The generated audio. + Audio MediaURL `json:"audio"` +} + +func (o *AudioResponse) GetAudio() MediaURL { + if o == nil { + return MediaURL{} + } + return o.Audio +} diff --git a/models/components/bodygenaudiototext.go b/models/components/bodygenaudiototext.go index 1057387..601cdff 100644 --- a/models/components/bodygenaudiototext.go +++ b/models/components/bodygenaudiototext.go @@ -31,6 +31,8 @@ type BodyGenAudioToText struct { Audio Audio `multipartForm:"file"` // Hugging Face model ID used for transcription. ModelID *string `default:"" multipartForm:"name=model_id"` + // Return timestamps for the transcribed text. Supported values: 'sentence', 'word', or a string boolean ('true' or 'false'). Default is 'true' ('sentence'). 'false' means no timestamps. 'word' means word-based timestamps. + ReturnTimestamps *string `default:"true" multipartForm:"name=return_timestamps"` } func (b BodyGenAudioToText) MarshalJSON() ([]byte, error) { @@ -57,3 +59,10 @@ func (o *BodyGenAudioToText) GetModelID() *string { } return o.ModelID } + +func (o *BodyGenAudioToText) GetReturnTimestamps() *string { + if o == nil { + return nil + } + return o.ReturnTimestamps +} diff --git a/models/components/livevideotovideoparams.go b/models/components/livevideotovideoparams.go new file mode 100644 index 0000000..58e823d --- /dev/null +++ b/models/components/livevideotovideoparams.go @@ -0,0 +1,61 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/livepeer/livepeer-ai-go/internal/utils" +) + +// Params - Initial parameters for the model. +type Params struct { +} + +type LiveVideoToVideoParams struct { + // Source URL of the incoming stream to subscribe to. + SubscribeURL string `json:"subscribe_url"` + // Destination URL of the outgoing stream to publish. + PublishURL string `json:"publish_url"` + // Hugging Face model ID used for image generation. + ModelID *string `default:"" json:"model_id"` + // Initial parameters for the model. + Params *Params `json:"params,omitempty"` +} + +func (l LiveVideoToVideoParams) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(l, "", false) +} + +func (l *LiveVideoToVideoParams) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &l, "", false, false); err != nil { + return err + } + return nil +} + +func (o *LiveVideoToVideoParams) GetSubscribeURL() string { + if o == nil { + return "" + } + return o.SubscribeURL +} + +func (o *LiveVideoToVideoParams) GetPublishURL() string { + if o == nil { + return "" + } + return o.PublishURL +} + +func (o *LiveVideoToVideoParams) GetModelID() *string { + if o == nil { + return nil + } + return o.ModelID +} + +func (o *LiveVideoToVideoParams) GetParams() *Params { + if o == nil { + return nil + } + return o.Params +} diff --git a/models/components/livevideotovideoresponse.go b/models/components/livevideotovideoresponse.go new file mode 100644 index 0000000..d47f26c --- /dev/null +++ b/models/components/livevideotovideoresponse.go @@ -0,0 +1,25 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +// LiveVideoToVideoResponse - Response model for live video-to-video generation. +type LiveVideoToVideoResponse struct { + // Source URL of the incoming stream to subscribe to + SubscribeURL string `json:"subscribe_url"` + // Destination URL of the outgoing stream to publish to + PublishURL string `json:"publish_url"` +} + +func (o *LiveVideoToVideoResponse) GetSubscribeURL() string { + if o == nil { + return "" + } + return o.SubscribeURL +} + +func (o *LiveVideoToVideoResponse) GetPublishURL() string { + if o == nil { + return "" + } + return o.PublishURL +} diff --git a/models/components/mediaurl.go b/models/components/mediaurl.go new file mode 100644 index 0000000..6755932 --- /dev/null +++ b/models/components/mediaurl.go @@ -0,0 +1,16 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +// MediaURL - A URL from which media can be accessed. +type MediaURL struct { + // The URL where the media can be accessed. + URL string `json:"url"` +} + +func (o *MediaURL) GetURL() string { + if o == nil { + return "" + } + return o.URL +} diff --git a/models/components/texttospeechparams.go b/models/components/texttospeechparams.go new file mode 100644 index 0000000..f401d7d --- /dev/null +++ b/models/components/texttospeechparams.go @@ -0,0 +1,48 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/livepeer/livepeer-ai-go/internal/utils" +) + +type TextToSpeechParams struct { + // Hugging Face model ID used for text to speech generation. + ModelID *string `default:"" json:"model_id"` + // Text input for speech generation. + Text *string `default:"" json:"text"` + // Description of speaker to steer text to speech generation. + Description *string `default:"A male speaker delivers a slightly expressive and animated speech with a moderate speed and pitch." json:"description"` +} + +func (t TextToSpeechParams) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(t, "", false) +} + +func (t *TextToSpeechParams) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &t, "", false, false); err != nil { + return err + } + return nil +} + +func (o *TextToSpeechParams) GetModelID() *string { + if o == nil { + return nil + } + return o.ModelID +} + +func (o *TextToSpeechParams) GetText() *string { + if o == nil { + return nil + } + return o.Text +} + +func (o *TextToSpeechParams) GetDescription() *string { + if o == nil { + return nil + } + return o.Description +} diff --git a/models/operations/genlivevideotovideo.go b/models/operations/genlivevideotovideo.go new file mode 100644 index 0000000..6bb8204 --- /dev/null +++ b/models/operations/genlivevideotovideo.go @@ -0,0 +1,27 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/livepeer/livepeer-ai-go/models/components" +) + +type GenLiveVideoToVideoResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Successful Response + LiveVideoToVideoResponse *components.LiveVideoToVideoResponse +} + +func (o *GenLiveVideoToVideoResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *GenLiveVideoToVideoResponse) GetLiveVideoToVideoResponse() *components.LiveVideoToVideoResponse { + if o == nil { + return nil + } + return o.LiveVideoToVideoResponse +} diff --git a/models/operations/gentexttospeech.go b/models/operations/gentexttospeech.go new file mode 100644 index 0000000..2d1e9e7 --- /dev/null +++ b/models/operations/gentexttospeech.go @@ -0,0 +1,27 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/livepeer/livepeer-ai-go/models/components" +) + +type GenTextToSpeechResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Successful Response + AudioResponse *components.AudioResponse +} + +func (o *GenTextToSpeechResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *GenTextToSpeechResponse) GetAudioResponse() *components.AudioResponse { + if o == nil { + return nil + } + return o.AudioResponse +}