texttospeech

package
v0.0.113 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package texttospeech provides functionality for synthesizing text into audio streams.

Index

Constants

This section is empty.

Variables

View Source
var DefaultOpenAIOptions = OpenAIOptions{
	Model:          openai.TTSModel1,
	Voice:          openai.VoiceAlloy,
	ResponseFormat: openai.SpeechResponseFormatMp3,
	Speed:          1.0,
}

DefaultOpenAIOptions provides default values for OpenAIOptions.

Functions

func NewAudioStream

func NewAudioStream(rc io.ReadCloser, format schema.OutputFormat) schema.AudioStream

NewAudioStream creates a new instance of the audioStream.

Types

type AmazonPolly

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

AmazonPolly is a transformer that uses the Amazon Polly Text-to-Speech API to synthesize speech from text.

func NewAmazonPolly

func NewAmazonPolly(client AmazonPollyClient, optFns ...func(o *AmazonPollyOptions)) *AmazonPolly

NewAmazonPolly creates a new instance of the Amazon Polly transformer.

func (*AmazonPolly) SynthesizeSpeech

func (t2s *AmazonPolly) SynthesizeSpeech(ctx context.Context, text string) (schema.AudioStream, error)

SynthesizeSpeech uses the Amazon Polly Text-to-Speech API to transform text into an audio stream.

type AmazonPollyClient

type AmazonPollyClient interface {
	SynthesizeSpeech(ctx context.Context, params *polly.SynthesizeSpeechInput, optFns ...func(*polly.Options)) (*polly.SynthesizeSpeechOutput, error)
}

AmazonPollyClient is an interface for the Amazon Polly Text-to-Speech API client.

type AmazonPollyOptions

type AmazonPollyOptions struct {
	VoiceID         types.VoiceId
	Engine          types.Engine
	OutputFormat    types.OutputFormat
	LanguageCode    types.LanguageCode
	LexiconNames    []string
	SampleRate      string
	SpeechMarkTypes []types.SpeechMarkType
	TextType        types.TextType
}

AmazonPollyOptions contains options for configuring the Amazon Polly transformer.

type OpenAI

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

OpenAI is a transformer that uses the OpenAI Text-to-Speech API to synthesize speech from text.

func NewOpenAI

func NewOpenAI(apiKey string, optFns ...func(o *OpenAIOptions)) *OpenAI

NewOpenAI creates a new instance of the OpenAI transformer.

func NewOpenAIFromClient

func NewOpenAIFromClient(client OpenAIClient, optFns ...func(o *OpenAIOptions)) *OpenAI

NewOpenAI creates a new instance of the OpenAI transformer.

func (*OpenAI) SynthesizeSpeech

func (t2s *OpenAI) SynthesizeSpeech(ctx context.Context, text string) (schema.AudioStream, error)

SynthesizeSpeech uses the OpenAI Text-to-Speech API to transform text into an audio stream.

type OpenAIClient

type OpenAIClient interface {
	CreateSpeech(ctx context.Context, request openai.CreateSpeechRequest) (response openai.RawResponse, err error)
}

OpenAIClient is an interface for the OpenAI Text-to-Speech API client.

type OpenAIOptions

type OpenAIOptions struct {
	Model          openai.SpeechModel
	Voice          openai.SpeechVoice
	ResponseFormat openai.SpeechResponseFormat
	Speed          float64
}

OpenAIOptions contains options for configuring the OpenAI transformer.

Jump to

Keyboard shortcuts

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