Documentation
¶
Index ¶
- Constants
- Variables
- func AdjustClockSkew(skewSeconds float64)
- func GenerateSecMSGec() string
- func GetUnixTimestamp() float64
- func HandleClientResponseError(resp *http.Response) error
- func MergeMap(m1, m2 map[string]string) map[string]string
- func ParseRFC2616Date(date string) (float64, error)
- func ValidateStringParam(paramName, paramValue, pattern string) (string, error)
- type Communicate
- type CommunicateOption
- type Voice
- type VoiceTag
Constants ¶
const ( TRUSTED_CLIENT_TOKEN = "6A5AA1D4EAFF4E9FB37E23D68491D6F4" WSS_URL = "wss://speech.platform.bing.com/consumer/speech/synthesize/readaloud/edge/v1?TrustedClientToken=" + TRUSTED_CLIENT_TOKEN VOICE_LIST_URL = "https://speech.platform.bing.com/consumer/speech/synthesize/readaloud/voices/list?trustedclienttoken=" + TRUSTED_CLIENT_TOKEN )
edge tts 相关接口
const CHROMIUM_FULL_VERSION = "134.0.3124.66"
const (
PackageVersion = "0.0.1" // edge-tts-go 包版本
)
Variables ¶
var ( CHROMIUM_MAJOR_VERSION = strings.SplitN(CHROMIUM_FULL_VERSION, ".", 2)[0] SEC_MS_GEC_VERSION = fmt.Sprintf("1-%s", CHROMIUM_FULL_VERSION) BASE_HEADERS = map[string]string{ "User-Agent": fmt.Sprintf("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s.0.0.0 Safari/537.36 Edg/%s.0.0.0", CHROMIUM_MAJOR_VERSION, CHROMIUM_MAJOR_VERSION), "Accept-Encoding": "gzip, deflate, br", "Accept-Language": "en-US,en;q=0.9", } WSS_HEADERS = MergeMap(map[string]string{ "Pragma": "no-cache", "Cache-Control": "no-cache", "Origin": "chrome-extension://jdiccldimpdaibmpdkjnbmckianbfold", }, BASE_HEADERS) VOICE_HEADERS = MergeMap(map[string]string{ "Authority": "speech.platform.bing.com", "Sec-CH-UA": fmt.Sprintf(`" Not;A Brand";v="99", "Microsoft Edge";v="%s", "Chromium";v="%s"`, CHROMIUM_MAJOR_VERSION, CHROMIUM_MAJOR_VERSION), "Sec-CH-UA-Mobile": "?0", "Accept": "*/*", "Sec-Fetch-Site": "none", "Sec-Fetch-Mode": "cors", "Sec-Fetch-Dest": "empty", }, BASE_HEADERS) )
var NoAudioReceived = errors.New("no audio received from the server")
NoAudioReceived error when no audio is received from the server
var UnexpectedResponse = errors.New("unexpected response received from the server")
UnexpectedResponse error for unexpected server responses
This hasn't happened yet, but it's possible that the server will change its response format in the future.
var UnknownResponse = errors.New("unknown response received from the server")
UnknownResponse error for unknown server responses
var WebSocketError = errors.New("WebSocket error occurred")
WebSocketError error for WebSocket errors
Functions ¶
func HandleClientResponseError ¶
HandleClientResponseError 处理客户端响应错误
func ParseRFC2616Date ¶
ParseRFC2616Date 解析RFC 2616日期字符串
func ValidateStringParam ¶
ValidateStringParam validates the given string parameter based on type and pattern.
Types ¶
type Communicate ¶
type Communicate struct {
// contains filtered or unexported fields
}
Communicate is a struct representing communication with the service.
func NewCommunicate ¶
func NewCommunicate(text string, options ...CommunicateOption) (*Communicate, error)
NewCommunicate initializes the Communicate struct.
func (*Communicate) Stream ¶
func (c *Communicate) Stream() ([]byte, error)
type CommunicateOption ¶
type CommunicateOption func(*Communicate) error
func SetPitch ¶
func SetPitch(pitch string) CommunicateOption
SetPitch sets the pitch for communication.
func SetProxy ¶
func SetProxy(proxy string) CommunicateOption
SetProxy sets the proxy for communication.
func SetReceiveTimeout ¶
func SetReceiveTimeout(receiveTimeout int) CommunicateOption
SetReceiveTimeout sets the receive timeout for communication.
func SetVoice ¶
func SetVoice(voice string) CommunicateOption
SetVoice sets the voice for communication.
func SetVolume ¶
func SetVolume(volume string) CommunicateOption
SetVolume sets the volume for communication.
type Voice ¶
type Voice 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 VoiceTag `json:"VoiceTag"` }