MCPcopy Create free account
hub / github.com/LagrangeDev/LagrangeGo / NewStreamRecord

Function NewStreamRecord

message/elements.go:211–231  ·  view source on GitHub ↗
(r io.ReadSeeker, summary ...string)

Source from the content-addressed store, hash-verified

209}
210
211func 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
233func NewFileRecord(path string, summary ...string) (*VoiceElement, error) {
234 voice, err := os.Open(path)

Callers 2

NewRecordFunction · 0.85
NewFileRecordFunction · 0.85

Calls 2

DecodeFunction · 0.92

Tested by

no test coverage detected