-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathoption.go
More file actions
110 lines (92 loc) · 2.8 KB
/
Copy pathoption.go
File metadata and controls
110 lines (92 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package edgetts
import "github.com/lib-x/edgetts/internal/communicateOption"
type option struct {
Voice string
VoiceLangRegion string
Pitch string
Rate string
Volume string
HTTPProxy string
SOCKS5Proxy string
SOCKS5ProxyUser string
SOCKS5ProxyPass string
IgnoreSSLVerification bool
}
func (o *option) toInternalOption() *communicateOption.CommunicateOption {
return &communicateOption.CommunicateOption{
Voice: o.Voice,
VoiceLangRegion: o.VoiceLangRegion,
Pitch: o.Pitch,
Rate: o.Rate,
Volume: o.Volume,
HttpProxy: o.HTTPProxy,
Socket5Proxy: o.SOCKS5Proxy,
Socket5ProxyUser: o.SOCKS5ProxyUser,
Socket5ProxyPass: o.SOCKS5ProxyPass,
IgnoreSSL: o.IgnoreSSLVerification,
}
}
type Option func(option *option)
func WithVoice(voice string) Option {
return func(option *option) {
option.Voice = voice
}
}
func WithVoiceLangRegion(voiceLangRegion string) Option {
return func(option *option) {
option.VoiceLangRegion = voiceLangRegion
}
}
// WithPitch sets pitch, e.g. +50Hz or -50Hz.
func WithPitch(pitch string) Option {
return func(option *option) {
option.Pitch = pitch
}
}
// WithRate sets rate, e.g. -50% or +50%.
func WithRate(rate string) Option {
return func(option *option) {
option.Rate = rate
}
}
// WithVolume sets volume, e.g. -50% or +50%.
func WithVolume(volume string) Option {
return func(option *option) {
option.Volume = volume
}
}
func WithHttpProxy(proxy string) Option { return WithHTTPProxy(proxy) }
func WithHTTPProxy(proxy string) Option {
return WithHTTPProxyEx(proxy, false)
}
func WithHttpProxyEx(proxy string, ignoreSSLVerification bool) Option {
return WithHTTPProxyEx(proxy, ignoreSSLVerification)
}
func WithHTTPProxyEx(proxy string, ignoreSSLVerification bool) Option {
return func(option *option) {
option.HTTPProxy = proxy
option.IgnoreSSLVerification = ignoreSSLVerification
}
}
func WithSocket5Proxy(proxy, userName, password string) Option {
return WithSOCKS5Proxy(proxy, userName, password)
}
func WithSOCKS5Proxy(proxy, userName, password string) Option {
return WithSOCKS5ProxyEx(proxy, userName, password, false)
}
func WithSocket5ProxyEx(proxy, userName, password string, ignoreSSLVerification bool) Option {
return WithSOCKS5ProxyEx(proxy, userName, password, ignoreSSLVerification)
}
func WithSOCKS5ProxyEx(proxy, userName, password string, ignoreSSLVerification bool) Option {
return func(option *option) {
option.SOCKS5Proxy = proxy
option.SOCKS5ProxyUser = userName
option.SOCKS5ProxyPass = password
option.IgnoreSSLVerification = ignoreSSLVerification
}
}
func WithInsecureSkipVerify() Option {
return func(option *option) {
option.IgnoreSSLVerification = true
}
}