(r io.ReadSeeker, summary ...string)
| 209 | } |
| 210 | |
| 211 | func NewStreamRecord(r io.ReadSeeker, summary ...string) *VoiceElement { |
| 212 | md5, sha1, length := crypto.ComputeMd5AndSha1AndLength(r) |
| 213 | return &VoiceElement{ |
| 214 | Size: uint32(length), |
| 215 | Summary: func() string { |
| 216 | if len(summary) != 0 { |
| 217 | return summary[0] |
| 218 | } |
| 219 | return "" |
| 220 | }(), |
| 221 | Stream: r, |
| 222 | Md5: md5, |
| 223 | Sha1: sha1, |
| 224 | Duration: func() uint32 { |
| 225 | if info, err := audio.Decode(r); err == nil { |
| 226 | return uint32(info.Time) |
| 227 | } |
| 228 | return uint32(length) |
| 229 | }(), |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | func NewFileRecord(path string, summary ...string) (*VoiceElement, error) { |
| 234 | voice, err := os.Open(path) |
no test coverage detected