edge_tts

package
v0.0.0-...-d7395f2 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EdgeWssEndpoint   = "wss://speech.platform.bing.com/consumer/speech/synthesize/" + "readaloud/edge/v1?trustedClientToken=" + trustedClientToken
	VoiceListEndpoint = "https://speech.platform.bing.com/consumer/speech/synthesize/readaloud/voices/list?trustedclienttoken=" + trustedClientToken
)
View Source
const (
	PathTurnStart     = "turn.start"
	PathTurnEnd       = "turn.end"
	PathAudioMetadata = "audio.metadata"
	PathResponse      = "response"
)
View Source
const (
	DefaultVoice  = "zh-CN-XiaoxiaoNeural"
	DefaultPitch  = "+0Hz"
	DefaultRate   = "+0%"
	DefaultVolume = "+0%"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Communicate

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

func NewCommunicate

func NewCommunicate() *Communicate

func (*Communicate) ReadStream

func (c *Communicate) ReadStream() (io.ReadCloser, error)

ReadStream write audio stream to io.ReadCloser

func (*Communicate) SetPitch

func (c *Communicate) SetPitch(pitch string) *Communicate

func (*Communicate) SetRate

func (c *Communicate) SetRate(rate string) *Communicate

func (*Communicate) SetText

func (c *Communicate) SetText(text string) *Communicate

func (*Communicate) SetVoice

func (c *Communicate) SetVoice(voice string) *Communicate

func (*Communicate) SetVolume

func (c *Communicate) SetVolume(volume string) *Communicate

type Prosody

type Prosody struct {
	// Contour represents changes in pitch. These changes are represented as an array of targets at specified time
	//positions in the speech output. Sets of parameter pairs define each target. For example:
	//
	//<prosody contour="(0%,+20Hz) (10%,-2st) (40%,+10Hz)">
	//
	//The first value in each set of parameters specifies the location of the pitch change as a percentage of the
	//duration of the text. The second value specifies the amount to raise or lower the pitch by using a relative
	//value or an enumeration value for pitch (see pitch).
	Contour string `xml:"contour,attr,omitempty"`
	//Indicates the baseline pitch for the text. Pitch changes can be applied at the sentence level. The pitch changes
	//should be within 0.5 to 1.5 times the original audio. You can express the pitch as:
	//An absolute value:
	//Expressed as a number followed by "Hz" (Hertz). For example, <prosody pitch="600Hz">some text</prosody>.
	//A relative value:
	//	As a relative number: Expressed as a number preceded by "+" or "-" and followed by "Hz" or "st" that specifies
	//	an amount to change the pitch. For example:
	//	<prosody pitch="+80Hz">some text</prosody> or <prosody pitch="-2st">some text</prosody>.
	//	The "st" indicates the change unit is semitone, which is half of a tone (a half step) on the standard diatonic scale.
	//As a percentage: Expressed as a number preceded by "+" (optionally) or "-" and followed by "%", indicating the
	//relative change. For example: <prosody pitch="50%">some text</prosody> or <prosody pitch="-50%">some text</prosody>.
	// A constant value:
	//	x-low
	//	low
	//	medium
	//	high
	//	x-high
	//	default
	Pitch string `xml:"pitch,attr"`
	// Indicates the speaking rate of the text. Speaking rate can be applied at the word or sentence level. The rate changes
	//should be within 0.5 to 2 times the original audio. You can express rate as:
	//A relative value:
	//	As a relative number: Expressed as a number that acts as a multiplier of the default. For example, a value of 1 results
	//	in no change in the original rate. A value of 0.5 results in a halving of the original rate. A value of 2 results in
	//	twice the original rate.
	//	As a percentage: Expressed as a number preceded by "+" (optionally) or "-" and followed by "%", indicating the relative
	//	change. For example:
	//	<prosody rate="50%">some text</prosody> or <prosody rate="-50%">some text</prosody>.
	//	A constant value:
	//	x-slow
	//	slow
	//	medium
	//	fast
	//	x-fast
	//	default
	Rate string `xml:"rate,attr"`
	// Indicates the volume level of the speaking voice. Volume changes can be applied at the sentence level. You can express
	//the volume as:
	// An absolute value: Expressed as a number in the range of 0.0 to 100.0, from quietest to loudest, such as 75.
	//The default value is 100.0.
	// A relative value:
	// As a relative number: Expressed as a number preceded by "+" or "-" that specifies an amount to change the volume.
	//Examples are +10 or -5.5.
	// As a percentage: Expressed as a number preceded by "+" (optionally) or "-" and followed by "%", indicating the
	//relative change. For example:
	//	<prosody volume="50%">some text</prosody> or <prosody volume="+3%">some text</prosody>.
	//
	//	A constant value:
	//	silent
	//	x-soft
	//	soft
	//	medium
	//	loud
	//	x-loud
	//	default
	Volume string `xml:"volume,attr"`
	Text   string `xml:",chardata"`
}

type Speak

type Speak struct {
	XMLName xml.Name `xml:"speak"`
	Version string   `xml:"version,attr"`
	Xmlns   string   `xml:"xmlns,attr"`
	Lang    string   `xml:"xml:lang,attr"`
	Voice   []Voice  `xml:"voice"`
}

type Voice

type Voice struct {
	Name    string  `xml:"name,attr"`
	Prosody Prosody `xml:"prosody"`
}

type VoiceItem

type VoiceItem struct {
	Name           string `json:"Name"`
	ShortName      string `json:"ShortName"`
	Gender         string `json:"Gender"`
	Locale         string `json:"Locale"`
	SuggestedCodec string `json:"SuggestedCodec"`
	FriendlyName   string `json:"FriendlyName"`
	Status         string `json:"Status"`
	VoiceTag       struct {
		ContentCategories  []string `json:"ContentCategories"`
		VoicePersonalities []string `json:"VoicePersonalities"`
	} `json:"VoiceTag"`
}

func VoiceList

func VoiceList() ([]VoiceItem, error)

Jump to

Keyboard shortcuts

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