tts

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2024 License: Apache-2.0 Imports: 19 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteFile added in v1.0.13

func WriteFile(filename string, content []byte) error

Types

type SpeechSynthesisListener

type SpeechSynthesisListener interface {
	OnMessage(*SpeechSynthesisResponse)
	OnComplete(*SpeechSynthesisResponse)
	OnCancel(*SpeechSynthesisResponse)
	OnFail(*SpeechSynthesisResponse, error)
}

SpeechSynthesisListener is the listener of

type SpeechSynthesisResponse

type SpeechSynthesisResponse struct {
	SessionID string
	Data      []byte
}

SpeechSynthesisResponse SpeechSynthesisResponse

type SpeechSynthesizer

type SpeechSynthesizer struct {
	AppID      int64
	Credential *common.Credential
	VoiceType  int64
	SampleRate int64
	Codec      string

	ProxyURL string
	// contains filtered or unexported fields
}

SpeechSynthesizer is the entry for TTS service

func NewSpeechSynthesizer

func NewSpeechSynthesizer(appID int64, credential *common.Credential, listener SpeechSynthesisListener) *SpeechSynthesizer

NewSpeechSynthesizer creates instance of SpeechSynthesizer

func (*SpeechSynthesizer) Cancel

func (synthesizer *SpeechSynthesizer) Cancel() error

Cancel Cancel

func (*SpeechSynthesizer) Synthesis

func (synthesizer *SpeechSynthesizer) Synthesis(text string) error

Synthesis Synthesis

func (*SpeechSynthesizer) Wait

func (synthesizer *SpeechSynthesizer) Wait() error

Wait Wait

type SpeechWsSynthesisListener added in v1.0.13

type SpeechWsSynthesisListener interface {
	OnSynthesisStart(*SpeechWsSynthesisResponse)
	OnSynthesisEnd(*SpeechWsSynthesisResponse)
	OnAudioResult(data []byte)
	OnTextResult(*SpeechWsSynthesisResponse)
	OnSynthesisFail(*SpeechWsSynthesisResponse, error)
}

SpeechWsSynthesisListener is the listener of

type SpeechWsSynthesisResponse added in v1.0.13

type SpeechWsSynthesisResponse struct {
	SessionId string             `json:"session_id"` //音频流唯一 id,由客户端在握手阶段生成并赋值在调用参数中
	RequestId string             `json:"request_id"` //音频流唯一 id,由服务端在握手阶段自动生成
	MessageId string             `json:"message_id"` //本 message 唯一 id
	Code      int                `json:"code"`       //状态码,0代表正常,非0值表示发生错误
	Message   string             `json:"message"`    //错误说明,发生错误时显示这个错误发生的具体原因,随着业务发展或体验优化,此文本可能会经常保持变更或更新
	Result    SynthesisSubtitles `json:"result"`     //最新语音合成文本结果
	Final     int                `json:"final"`      //该字段返回1时表示文本全部合成结束,客户端收到后需主动关闭 websocket 连接
}

SpeechWsSynthesisResponse response

func (*SpeechWsSynthesisResponse) ToString added in v1.0.13

func (s *SpeechWsSynthesisResponse) ToString() string

type SpeechWsSynthesizer added in v1.0.13

type SpeechWsSynthesizer struct {
	Credential *common.Credential

	AppID            int64   `json:"AppId"`
	Timestamp        int64   `json:"Timestamp"`
	Expired          int64   `json:"Expired"`
	SessionId        string  `json:"SessionId"`
	Text             string  `json:"Text"`
	ModelType        int64   `json:"ModelType"`
	VoiceType        int64   `json:"VoiceType"`
	SampleRate       int64   `json:"SampleRate"`
	Codec            string  `json:"Codec"`
	Speed            float64 `json:"Speed"`
	Volume           float64 `json:"Volume"`
	EnableSubtitle   bool    `json:"EnableSubtitle"`
	EmotionCategory  string  `json:"EmotionCategory"`
	EmotionIntensity int64   `json:"EmotionIntensity"`
	SegmentRate      int64   `json:"SegmentRate"`
	ExtParam         map[string]string

	ProxyURL string

	Debug     bool //是否debug
	DebugFunc func(message string)
	// contains filtered or unexported fields
}

SpeechWsSynthesizer is the entry for TTS websocket service

func NewSpeechWsSynthesizer added in v1.0.13

func NewSpeechWsSynthesizer(appID int64, credential *common.Credential, listener SpeechWsSynthesisListener) *SpeechWsSynthesizer

NewSpeechWsSynthesizer creates instance of SpeechWsSynthesizer

func (*SpeechWsSynthesizer) CloseConn added in v1.0.13

func (synthesizer *SpeechWsSynthesizer) CloseConn()

CloseConn close connection

func (*SpeechWsSynthesizer) Synthesis added in v1.0.13

func (synthesizer *SpeechWsSynthesizer) Synthesis() error

Synthesis Start connects to server and start a synthesizer session

func (*SpeechWsSynthesizer) Wait added in v1.0.13

func (synthesizer *SpeechWsSynthesizer) Wait() error

Wait Wait

type SynthesisSubtitle added in v1.0.13

type SynthesisSubtitle struct {
	Text       string
	Phoneme    string
	BeginTime  int64
	EndTime    int64
	BeginIndex int
	EndIndex   int
}

SynthesisSubtitle Subtitle

type SynthesisSubtitles added in v1.0.13

type SynthesisSubtitles struct {
	Subtitles []SynthesisSubtitle `json:"subtitles"`
}

SynthesisSubtitles subtitles

Jump to

Keyboard shortcuts

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