content

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package content provides content generation services including music, dubbing, and projects.

This package combines music composition, video dubbing, and Studio Projects for long-form content.

Example:

import (
    "github.com/plexusone/elevenlabs-go"
    "github.com/plexusone/elevenlabs-go/content"
)

client, _ := elevenlabs.NewClient()
stems, _ := client.Content().SeparateStems(ctx, &content.StemSeparationRequest{...})
projects, _ := client.Content().ListProjects(ctx)

Index

Constants

This section is empty.

Variables

View Source
var ErrMusicCompositionUnavailable = errors.New("content: music composition endpoints are temporarily unavailable due to API schema complexity; use SeparateStems or VideoToMusic instead")

ErrMusicCompositionUnavailable is returned when music composition endpoints are called but the underlying API client doesn't support them.

Functions

This section is empty.

Types

type Chapter

type Chapter struct {
	// ChapterID is the unique identifier.
	ChapterID string

	// Name is the chapter name.
	Name string

	// ConversionProgress is the conversion progress percentage.
	ConversionProgress float64

	// State is the current state.
	State string

	// LastConversionError is the last conversion error if any.
	LastConversionError string
}

Chapter represents a chapter within a project.

type CreateProjectRequest

type CreateProjectRequest struct {
	// Name is the project name (required).
	Name string

	// Description is an optional description.
	Description string

	// Author is an optional author name.
	Author string

	// Language is the two-letter language code (ISO 639-1).
	Language string

	// DefaultModelID is the model to use for TTS.
	DefaultModelID string

	// DefaultParagraphVoiceID is the default voice for paragraphs.
	DefaultParagraphVoiceID string

	// DefaultTitleVoiceID is the default voice for titles.
	DefaultTitleVoiceID string

	// FromURL is a URL to extract content from.
	FromURL string

	// ContentType is the content type (e.g., "Novel", "Short Story").
	ContentType string

	// Genres is a list of genres.
	Genres []string

	// QualityPreset is the output quality: "standard", "high", "ultra", "ultra lossless".
	QualityPreset string

	// AutoConvert automatically converts the project to audio.
	AutoConvert bool
}

CreateProjectRequest contains options for creating a project.

type DubbingProject

type DubbingProject struct {
	// DubbingID is the unique identifier.
	DubbingID string

	// Name is the project name.
	Name string

	// Status is the current status (dubbed, dubbing, failed, cloning).
	Status string

	// TargetLanguages are the target languages for dubbing.
	TargetLanguages []string

	// SourceLanguage is the source language.
	SourceLanguage string

	// Error contains any error message if the project failed.
	Error string

	// CreatedAt is when the project was created.
	CreatedAt time.Time
}

DubbingProject represents a dubbing project.

func (*DubbingProject) IsComplete

func (p *DubbingProject) IsComplete() bool

IsComplete checks if a dubbing project is complete.

func (*DubbingProject) IsFailed

func (p *DubbingProject) IsFailed() bool

IsFailed checks if a dubbing project has failed.

func (*DubbingProject) IsProcessing

func (p *DubbingProject) IsProcessing() bool

IsProcessing checks if a dubbing project is still processing.

type DubbingRequest

type DubbingRequest struct {
	// Name is the name of the dubbing project.
	Name string

	// SourceURL is the URL of the source media (alternative to file upload).
	SourceURL string

	// File is the source media file (alternative to SourceURL).
	File io.Reader

	// SourceLanguage is the source language code (ISO 639-1).
	SourceLanguage string

	// TargetLanguage is the target language code (ISO 639-1).
	TargetLanguage string

	// NumSpeakers is the number of speakers (0 for auto-detection).
	NumSpeakers int

	// Watermark enables watermark (for free tier).
	Watermark bool

	// StartTime is the start time in seconds for dubbing.
	StartTime int

	// EndTime is the end time in seconds for dubbing.
	EndTime int

	// HighestResolution requests highest resolution output.
	HighestResolution bool

	// DropBackgroundAudio removes background audio.
	DropBackgroundAudio bool
}

DubbingRequest contains options for creating a dubbing project.

type DubbingResponse

type DubbingResponse struct {
	// DubbingID is the ID of the created project.
	DubbingID string

	// ExpectedDurationSeconds is the expected duration.
	ExpectedDurationSeconds float64
}

DubbingResponse contains the result of creating a dubbing project.

type MusicRequest

type MusicRequest struct {
	// Prompt is a simple text description of the music to generate.
	Prompt string

	// DurationMs is the length of the song in milliseconds (3000-600000).
	DurationMs int

	// ForceInstrumental ensures the song has no vocals.
	ForceInstrumental bool

	// Seed for deterministic generation (optional).
	Seed int
}

MusicRequest contains options for music generation.

type Project

type Project struct {
	// ProjectID is the unique identifier.
	ProjectID string

	// Name is the project name.
	Name string

	// Description is the project description.
	Description string

	// Author is the project author.
	Author string

	// Language is the two-letter language code (ISO 639-1).
	Language string

	// DefaultModelID is the default model for TTS.
	DefaultModelID string

	// DefaultParagraphVoiceID is the default voice for paragraphs.
	DefaultParagraphVoiceID string

	// DefaultTitleVoiceID is the default voice for titles.
	DefaultTitleVoiceID string

	// ContentType is the content type (e.g., "Novel", "Short Story").
	ContentType string

	// CoverImageURL is the cover image URL.
	CoverImageURL string

	// CreatedAt is the creation timestamp.
	CreatedAt time.Time

	// CanBeDownloaded indicates if the project can be downloaded.
	CanBeDownloaded bool

	// AccessLevel is the access level of the project.
	AccessLevel string
}

Project represents a Studio project.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service handles content generation including music, dubbing, and projects.

func New

func New(apiClient *api.Client) *Service

New creates a new content service.

func (*Service) ConvertProject

func (s *Service) ConvertProject(ctx context.Context, projectID string) error

ConvertProject initiates conversion of a project to audio.

func (*Service) CreateDubbing

func (s *Service) CreateDubbing(ctx context.Context, req *DubbingRequest) (*DubbingResponse, error)

CreateDubbing creates a dubbing project from a URL source.

func (*Service) CreateProject

func (s *Service) CreateProject(ctx context.Context, req *CreateProjectRequest) (*Project, error)

CreateProject creates a new project.

func (*Service) DeleteDubbing

func (s *Service) DeleteDubbing(ctx context.Context, dubbingID string) error

DeleteDubbing deletes a dubbing project by ID.

func (*Service) DeleteProject

func (s *Service) DeleteProject(ctx context.Context, projectID string) error

DeleteProject deletes a project.

func (*Service) GenerateMusic

func (s *Service) GenerateMusic(ctx context.Context, req *MusicRequest) (io.Reader, error)

GenerateMusic creates music from a text prompt.

NOTE: This method is temporarily unavailable due to API schema complexity.

func (*Service) GetDubbedFile

func (s *Service) GetDubbedFile(ctx context.Context, dubbingID, languageCode string) (io.Reader, error)

GetDubbedFile returns the dubbed audio/video file for a specific language.

func (*Service) GetDubbing

func (s *Service) GetDubbing(ctx context.Context, dubbingID string) (*DubbingProject, error)

GetDubbing returns a dubbing project metadata by ID.

func (*Service) ListChapters

func (s *Service) ListChapters(ctx context.Context, projectID string) ([]*Chapter, error)

ListChapters returns all chapters in a project.

func (*Service) ListProjects

func (s *Service) ListProjects(ctx context.Context) ([]*Project, error)

ListProjects returns all projects.

func (*Service) SeparateStems

func (s *Service) SeparateStems(ctx context.Context, req *StemSeparationRequest) (io.Reader, error)

SeparateStems separates a song into individual stems (vocals, instruments, etc.).

Example:

f, _ := os.Open("song.mp3")
stems, err := client.Content().SeparateStems(ctx, &content.StemSeparationRequest{
    File:     f,
    Filename: "song.mp3",
})
// Save the separated stems (returned as a zip file)
output, _ := os.Create("stems.zip")
io.Copy(output, stems)

func (*Service) VideoToMusic

func (s *Service) VideoToMusic(ctx context.Context, req *VideoToMusicRequest) (io.Reader, error)

VideoToMusic converts a video to music.

type StemSeparationRequest

type StemSeparationRequest struct {
	// File is the audio file to separate.
	File io.Reader

	// Filename is the name of the file.
	Filename string

	// StemVariation specifies which stem variation to use.
	// Options: "two_stems_v1" (vocals + music), "six_stems_v1" (vocals, drums, bass, other - default)
	StemVariation string
}

StemSeparationRequest contains options for stem separation.

type VideoFile

type VideoFile struct {
	// Name is the filename.
	Name string
	// File is the video content.
	File io.Reader
}

VideoFile represents a video file for VideoToMusic.

type VideoToMusicRequest

type VideoToMusicRequest struct {
	// Videos is one or more video files to convert.
	Videos []VideoFile

	// Description is an optional text description of the music.
	Description string

	// Tags are optional style tags (e.g., ["upbeat", "cinematic"]).
	Tags []string

	// ModelID specifies the model to use (optional).
	ModelID string
}

VideoToMusicRequest contains options for converting a video to music.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL