mirror of
https://github.com/taigrr/elevenlabs.git
synced 2026-04-02 03:08:57 -07:00
refactor model names
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* ElevenLabs API Documentation
|
||||
*
|
||||
@@ -11,12 +10,14 @@ package swagger
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"fmt"
|
||||
|
||||
"github.com/antihax/optional"
|
||||
"github.com/taigrr/elevenlabs/types"
|
||||
)
|
||||
|
||||
// Linger please
|
||||
@@ -24,7 +25,6 @@ var (
|
||||
_ context.Context
|
||||
)
|
||||
|
||||
type HistoryApiService service
|
||||
/*
|
||||
HistoryApiService Delete History Item
|
||||
Delete a history item by its ID
|
||||
@@ -35,10 +35,6 @@ Delete a history item by its ID
|
||||
@return Object
|
||||
*/
|
||||
|
||||
type HistoryApiDeleteHistoryItemV1HistoryHistoryItemIdDeleteOpts struct {
|
||||
XiApiKey optional.String
|
||||
}
|
||||
|
||||
func (a *HistoryApiService) DeleteHistoryItemV1HistoryHistoryItemIdDelete(ctx context.Context, historyItemId string, localVarOptionals *HistoryApiDeleteHistoryItemV1HistoryHistoryItemIdDeleteOpts) (Object, *http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Delete")
|
||||
@@ -94,7 +90,7 @@ func (a *HistoryApiService) DeleteHistoryItemV1HistoryHistoryItemIdDelete(ctx co
|
||||
|
||||
if localVarHttpResponse.StatusCode < 300 {
|
||||
// If we succeed, return the data, otherwise pass on to decode error.
|
||||
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||||
if err == nil {
|
||||
return localVarReturnValue, localVarHttpResponse, err
|
||||
}
|
||||
@@ -107,7 +103,7 @@ func (a *HistoryApiService) DeleteHistoryItemV1HistoryHistoryItemIdDelete(ctx co
|
||||
}
|
||||
if localVarHttpResponse.StatusCode == 200 {
|
||||
var v Object
|
||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
newErr.error = err.Error()
|
||||
return localVarReturnValue, localVarHttpResponse, newErr
|
||||
@@ -117,7 +113,7 @@ func (a *HistoryApiService) DeleteHistoryItemV1HistoryHistoryItemIdDelete(ctx co
|
||||
}
|
||||
if localVarHttpResponse.StatusCode == 422 {
|
||||
var v HttpValidationError
|
||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
newErr.error = err.Error()
|
||||
return localVarReturnValue, localVarHttpResponse, newErr
|
||||
@@ -130,6 +126,7 @@ func (a *HistoryApiService) DeleteHistoryItemV1HistoryHistoryItemIdDelete(ctx co
|
||||
|
||||
return localVarReturnValue, localVarHttpResponse, nil
|
||||
}
|
||||
|
||||
/*
|
||||
HistoryApiService Delete History Items
|
||||
Delete a number of history items by their IDs.
|
||||
@@ -200,7 +197,7 @@ func (a *HistoryApiService) DeleteHistoryItemsV1HistoryDeletePost(ctx context.Co
|
||||
|
||||
if localVarHttpResponse.StatusCode < 300 {
|
||||
// If we succeed, return the data, otherwise pass on to decode error.
|
||||
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||||
if err == nil {
|
||||
return localVarReturnValue, localVarHttpResponse, err
|
||||
}
|
||||
@@ -213,7 +210,7 @@ func (a *HistoryApiService) DeleteHistoryItemsV1HistoryDeletePost(ctx context.Co
|
||||
}
|
||||
if localVarHttpResponse.StatusCode == 200 {
|
||||
var v Object
|
||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
newErr.error = err.Error()
|
||||
return localVarReturnValue, localVarHttpResponse, newErr
|
||||
@@ -223,7 +220,7 @@ func (a *HistoryApiService) DeleteHistoryItemsV1HistoryDeletePost(ctx context.Co
|
||||
}
|
||||
if localVarHttpResponse.StatusCode == 422 {
|
||||
var v HttpValidationError
|
||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
newErr.error = err.Error()
|
||||
return localVarReturnValue, localVarHttpResponse, newErr
|
||||
@@ -236,6 +233,7 @@ func (a *HistoryApiService) DeleteHistoryItemsV1HistoryDeletePost(ctx context.Co
|
||||
|
||||
return localVarReturnValue, localVarHttpResponse, nil
|
||||
}
|
||||
|
||||
/*
|
||||
HistoryApiService Download History Items
|
||||
Download one or more history items. If one history item ID is provided, we will return a single audio file. If more than one history item IDs are provided, we will provide the history items packed into a .zip file.
|
||||
@@ -256,7 +254,6 @@ func (a *HistoryApiService) DownloadHistoryItemsV1HistoryDownloadPost(ctx contex
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
@@ -304,7 +301,6 @@ func (a *HistoryApiService) DownloadHistoryItemsV1HistoryDownloadPost(ctx contex
|
||||
return localVarHttpResponse, err
|
||||
}
|
||||
|
||||
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
newErr := GenericSwaggerError{
|
||||
body: localVarBody,
|
||||
@@ -312,7 +308,7 @@ func (a *HistoryApiService) DownloadHistoryItemsV1HistoryDownloadPost(ctx contex
|
||||
}
|
||||
if localVarHttpResponse.StatusCode == 422 {
|
||||
var v HttpValidationError
|
||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
newErr.error = err.Error()
|
||||
return localVarHttpResponse, newErr
|
||||
@@ -325,6 +321,7 @@ func (a *HistoryApiService) DownloadHistoryItemsV1HistoryDownloadPost(ctx contex
|
||||
|
||||
return localVarHttpResponse, nil
|
||||
}
|
||||
|
||||
/*
|
||||
HistoryApiService Get Audio From History Item
|
||||
Returns the audio of an history item.
|
||||
@@ -345,7 +342,6 @@ func (a *HistoryApiService) GetAudioFromHistoryItemV1HistoryHistoryItemIdAudioGe
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
@@ -392,7 +388,6 @@ func (a *HistoryApiService) GetAudioFromHistoryItemV1HistoryHistoryItemIdAudioGe
|
||||
return localVarHttpResponse, err
|
||||
}
|
||||
|
||||
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
newErr := GenericSwaggerError{
|
||||
body: localVarBody,
|
||||
@@ -400,7 +395,7 @@ func (a *HistoryApiService) GetAudioFromHistoryItemV1HistoryHistoryItemIdAudioGe
|
||||
}
|
||||
if localVarHttpResponse.StatusCode == 422 {
|
||||
var v HttpValidationError
|
||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
newErr.error = err.Error()
|
||||
return localVarHttpResponse, newErr
|
||||
@@ -413,6 +408,7 @@ func (a *HistoryApiService) GetAudioFromHistoryItemV1HistoryHistoryItemIdAudioGe
|
||||
|
||||
return localVarHttpResponse, nil
|
||||
}
|
||||
|
||||
/*
|
||||
HistoryApiService Get Generated Items
|
||||
Returns metadata about all your generated audio.
|
||||
@@ -426,13 +422,13 @@ type HistoryApiGetGeneratedItemsV1HistoryGetOpts struct {
|
||||
XiApiKey optional.String
|
||||
}
|
||||
|
||||
func (a *HistoryApiService) GetGeneratedItemsV1HistoryGet(ctx context.Context, localVarOptionals *HistoryApiGetGeneratedItemsV1HistoryGetOpts) (GetHistoryResponseModel, *http.Response, error) {
|
||||
func GetGeneratedItemsV1HistoryGet(ctx context.Context, localVarOptionals *HistoryApiGetGeneratedItemsV1HistoryGetOpts) (types.GetHistoryResponseModel, *http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Get")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
localVarReturnValue GetHistoryResponseModel
|
||||
localVarReturnValue types.GetHistoryResponseModel
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
@@ -480,7 +476,7 @@ func (a *HistoryApiService) GetGeneratedItemsV1HistoryGet(ctx context.Context, l
|
||||
|
||||
if localVarHttpResponse.StatusCode < 300 {
|
||||
// If we succeed, return the data, otherwise pass on to decode error.
|
||||
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||||
if err == nil {
|
||||
return localVarReturnValue, localVarHttpResponse, err
|
||||
}
|
||||
@@ -493,7 +489,7 @@ func (a *HistoryApiService) GetGeneratedItemsV1HistoryGet(ctx context.Context, l
|
||||
}
|
||||
if localVarHttpResponse.StatusCode == 200 {
|
||||
var v GetHistoryResponseModel
|
||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
newErr.error = err.Error()
|
||||
return localVarReturnValue, localVarHttpResponse, newErr
|
||||
@@ -503,7 +499,7 @@ func (a *HistoryApiService) GetGeneratedItemsV1HistoryGet(ctx context.Context, l
|
||||
}
|
||||
if localVarHttpResponse.StatusCode == 422 {
|
||||
var v HttpValidationError
|
||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"));
|
||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
newErr.error = err.Error()
|
||||
return localVarReturnValue, localVarHttpResponse, newErr
|
||||
|
||||
9
client/client.go
Normal file
9
client/client.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package client
|
||||
|
||||
type Client struct {
|
||||
apiKey string
|
||||
}
|
||||
|
||||
func New(apiKey string) Client {
|
||||
return Client{apiKey: apiKey}
|
||||
}
|
||||
@@ -2,65 +2,31 @@ package types
|
||||
|
||||
import "os"
|
||||
|
||||
type AddVoiceResponseModel struct {
|
||||
VoiceId string `json:"voice_id"`
|
||||
}
|
||||
|
||||
// Voice settings overriding stored setttings for the given voice. They are applied only on the given TTS request.
|
||||
type AllOfBodyTextToSpeechV1TextToSpeechVoiceIdPostVoiceSettings struct {
|
||||
Stability float64 `json:"stability"`
|
||||
SimilarityBoost float64 `json:"similarity_boost"`
|
||||
}
|
||||
|
||||
// Voice settings overriding stored setttings for the given voice. They are applied only on the given TTS request.
|
||||
type AllOfBodyTextToSpeechV1TextToSpeechVoiceIdStreamPostVoiceSettings struct {
|
||||
Stability float64 `json:"stability"`
|
||||
SimilarityBoost float64 `json:"similarity_boost"`
|
||||
type AddVoiceResponse struct {
|
||||
VoiceID string `json:"voice_id"`
|
||||
}
|
||||
|
||||
type AnyOfValidationErrorLocItems struct{}
|
||||
|
||||
type BodyAddVoiceV1VoicesAddPost struct {
|
||||
// The name that identifies this voice. This will be displayed in the dropdown of the website.
|
||||
Name string `json:"name"`
|
||||
// One or more audio files to clone the voice from
|
||||
Files []*os.File `json:"files"`
|
||||
// How would you describe the voice?
|
||||
Description string `json:"description,omitempty"`
|
||||
// Serialized labels dictionary for the voice.
|
||||
Labels string `json:"labels,omitempty"`
|
||||
type HistoryPost struct {
|
||||
HistoryItemIds []string `json:"history_item_ids"`
|
||||
}
|
||||
type Voice struct {
|
||||
Name string `json:"name"` // The name that identifies this voice. This will be displayed in the dropdown of the website.
|
||||
Files []*os.File `json:"files,omitempty"` // Audio files to add to the voice
|
||||
Description string `json:"description,omitempty"` // How would you describe the voice?
|
||||
Labels string `json:"labels,omitempty"` // Serialized labels dictionary for the voice.
|
||||
}
|
||||
type TTS struct {
|
||||
Text string `json:"text"` // The text that will get converted into speech. Currently only English text is supported.
|
||||
VoiceSettings SynthesisOptions `json:"voice_settings,omitempty"` // Voice settings are applied only on the given TTS request.
|
||||
}
|
||||
|
||||
type BodyDeleteHistoryItemsV1HistoryDeletePost struct {
|
||||
// A list of history items to remove, you can get IDs of history items and other metadata using the GET https://api.elevenlabs.io/v1/history endpoint.
|
||||
HistoryItemIds []string `json:"history_item_ids"`
|
||||
}
|
||||
type BodyDownloadHistoryItemsV1HistoryDownloadPost struct {
|
||||
// A list of history items to download, you can get IDs of history items and other metadata using the GET https://api.elevenlabs.io/v1/history endpoint.
|
||||
HistoryItemIds []string `json:"history_item_ids"`
|
||||
}
|
||||
type BodyEditVoiceV1VoicesVoiceIdEditPost struct {
|
||||
// The name that identifies this voice. This will be displayed in the dropdown of the website.
|
||||
Name string `json:"name"`
|
||||
// Audio files to add to the voice
|
||||
Files []*os.File `json:"files,omitempty"`
|
||||
// How would you describe the voice?
|
||||
Description string `json:"description,omitempty"`
|
||||
// Serialized labels dictionary for the voice.
|
||||
Labels string `json:"labels,omitempty"`
|
||||
}
|
||||
type BodyTextToSpeechV1TextToSpeechVoiceIdPost struct {
|
||||
// The text that will get converted into speech. Currently only English text is supported.
|
||||
Text string `json:"text"`
|
||||
// Voice settings overriding stored setttings for the given voice. They are applied only on the given TTS request.
|
||||
VoiceSettings *AllOfBodyTextToSpeechV1TextToSpeechVoiceIdPostVoiceSettings `json:"voice_settings,omitempty"`
|
||||
}
|
||||
type BodyTextToSpeechV1TextToSpeechVoiceIdStreamPost struct {
|
||||
// The text that will get converted into speech. Currently only English text is supported.
|
||||
Text string `json:"text"`
|
||||
// Voice settings overriding stored setttings for the given voice. They are applied only on the given TTS request.
|
||||
VoiceSettings *AllOfBodyTextToSpeechV1TextToSpeechVoiceIdStreamPostVoiceSettings `json:"voice_settings,omitempty"`
|
||||
type SynthesisOptions struct {
|
||||
Stability float64 `json:"stability"`
|
||||
SimilarityBoost float64 `json:"similarity_boost"`
|
||||
}
|
||||
|
||||
type ExtendedSubscriptionResponseModel struct {
|
||||
Tier string `json:"tier"`
|
||||
CharacterCount int32 `json:"character_count"`
|
||||
@@ -77,7 +43,7 @@ type ExtendedSubscriptionResponseModel struct {
|
||||
CanUseDelayedPaymentMethods bool `json:"can_use_delayed_payment_methods"`
|
||||
Currency string `json:"currency"`
|
||||
Status string `json:"status"`
|
||||
NextInvoice *InvoiceResponseModel `json:"next_invoice"`
|
||||
NextInvoice InvoiceResponseModel `json:"next_invoice"`
|
||||
}
|
||||
type FeedbackResponseModel struct {
|
||||
ThumbsUp bool `json:"thumbs_up"`
|
||||
@@ -90,7 +56,7 @@ type FeedbackResponseModel struct {
|
||||
ReviewStatus string `json:"review_status,omitempty"`
|
||||
}
|
||||
type FineTuningResponseModel struct {
|
||||
ModelId string `json:"model_id"`
|
||||
ModelID string `json:"model_id"`
|
||||
IsAllowedToFineTune bool `json:"is_allowed_to_fine_tune"`
|
||||
FineTuningRequested bool `json:"fine_tuning_requested"`
|
||||
FinetuningState string `json:"finetuning_state"`
|
||||
@@ -122,7 +88,7 @@ type HistoryItemResponseModel struct {
|
||||
type HttpValidationError struct {
|
||||
Detail []ValidationError `json:"detail,omitempty"`
|
||||
}
|
||||
type InvoiceResponseModel struct {
|
||||
type Invoice struct {
|
||||
AmountDueCents int32 `json:"amount_due_cents"`
|
||||
NextPaymentAttemptUnix int32 `json:"next_payment_attempt_unix"`
|
||||
}
|
||||
@@ -137,7 +103,7 @@ type RecordingResponseModel struct {
|
||||
UploadDateUnix int32 `json:"upload_date_unix"`
|
||||
Transcription string `json:"transcription"`
|
||||
}
|
||||
type SampleResponseModel struct {
|
||||
type Sample struct {
|
||||
SampleId string `json:"sample_id"`
|
||||
FileName string `json:"file_name"`
|
||||
MimeType string `json:"mime_type"`
|
||||
@@ -145,12 +111,7 @@ type SampleResponseModel struct {
|
||||
Hash string `json:"hash"`
|
||||
}
|
||||
|
||||
// The settings for a specific voice.
|
||||
type Settings struct {
|
||||
Stability float64 `json:"stability"`
|
||||
SimilarityBoost float64 `json:"similarity_boost"`
|
||||
}
|
||||
type SubscriptionResponseModel struct {
|
||||
type Subscription struct {
|
||||
Tier string `json:"tier"`
|
||||
CharacterCount int32 `json:"character_count"`
|
||||
CharacterLimit int32 `json:"character_limit"`
|
||||
@@ -173,9 +134,9 @@ type TtsModelResponseModel struct {
|
||||
SupportedLanguage []LanguageResponseModel `json:"supported_language"`
|
||||
}
|
||||
type UserResponseModel struct {
|
||||
Subscription *SubscriptionResponseModel `json:"subscription"`
|
||||
Subscription Subscription `json:"subscription"`
|
||||
IsNewUser bool `json:"is_new_user"`
|
||||
XiApiKey string `json:"xi_api_key"`
|
||||
XiAPIKey string `json:"xi_api_key"`
|
||||
}
|
||||
type ValidationError struct {
|
||||
Loc []AnyOfValidationErrorLocItems `json:"loc"`
|
||||
@@ -193,16 +154,12 @@ type VerificationAttemptResponseModel struct {
|
||||
type VoiceResponseModel struct {
|
||||
VoiceId string `json:"voice_id"`
|
||||
Name string `json:"name"`
|
||||
Samples []SampleResponseModel `json:"samples"`
|
||||
Samples []Sample `json:"samples"`
|
||||
Category string `json:"category"`
|
||||
FineTuning *FineTuningResponseModel `json:"fine_tuning"`
|
||||
FineTuning FineTuningResponseModel `json:"fine_tuning"`
|
||||
Labels map[string]string `json:"labels"`
|
||||
Description string `json:"description"`
|
||||
PreviewUrl string `json:"preview_url"`
|
||||
AvailableForTiers []string `json:"available_for_tiers"`
|
||||
Settings *VoiceSettingsResponseModel `json:"settings"`
|
||||
}
|
||||
type VoiceSettingsResponseModel struct {
|
||||
Stability float64 `json:"stability"`
|
||||
SimilarityBoost float64 `json:"similarity_boost"`
|
||||
Settings SynthesisOptions `json:"settings"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user