-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadvanced.go
60 lines (51 loc) · 1.31 KB
/
advanced.go
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
package tts
import (
"bytes"
"encoding/xml"
"log"
)
type convertAdvancedText struct {
XMLName xml.Name `xml:"ConvertAdvancedText"`
Account string `xml:"accountID"`
Password string `xml:"password"`
TTStext string `xml:"TTStext"`
TTSSpeaker string `xml:"TTSSpeaker"`
Volume string `xml:"volume"`
Speed string `xml:"speed"`
OutType string `xml:"outType"`
PitchLevel string `xml:"PitchLevel"`
PitchSign string `xml:"PitchSign"`
PitchScale string `xml:"PitchScale"`
}
func (c *convertAdvancedText) Marshal() []byte {
m, err := xml.Marshal(c)
if err != nil {
log.Fatalf("Fail to marshal: %v\n", c)
}
return m
}
func (c *convertAdvancedText) getAccount() string {
return c.Account
}
func (c *convertAdvancedText) getPassword() string {
return c.Password
}
func (c *convertAdvancedText) ParseResult(buf *bytes.Buffer) string {
r := &advancedTextResult{}
err := xml.Unmarshal(buf.Bytes(), r)
if err != nil {
log.Fatalf("Unmarshal error: %v\n", err)
}
s, err := matchConvertResult(r)
if err != nil {
log.Fatalf("Can't match result: %v\n", err)
}
return s
}
type advancedTextResult struct {
XMLName xml.Name `xml:"Envelope"`
CResult string `xml:"Body>ConvertAdvancedTextResponse>Result"`
}
func (r *advancedTextResult) Result() string {
return r.CResult
}