model

package
v0.0.0-...-852b98d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2018 License: Apache-2.0 Imports: 9 Imported by: 13

Documentation

Index

Constants

View Source
const (
	INENT_REQUEST         = "IntentRequest"
	LAUNCH_REQUEST        = "LaunchRequest"
	SESSION_ENDED_REQUEST = "SessionEndedRequest"

	AUDIO_PLAYER_PLAYBACK_STARTED                 = "AudioPlayer.PlaybackStarted"
	AUDIO_PLAYER_PLAYBACK_STOPPED                 = "AudioPlayer.PlaybackStopped"
	AUDIO_PLAYER_PLAYBACK_FINISHED                = "AudioPlayer.PlaybackFinished"
	AUDIO_PLAYER_PLAYBACK_NEARLY_FINISHED         = "AudioPlayer.PlaybackNearlyFinished"
	AUDIO_PLAYER_PROGRESS_REPORT_INTERVAL_ELAPSED = "AudioPlayer.ProgressReportIntervalElapsed"

	VIDEO_PLAYER_PLAYBACK_STARTED                 = "VideoPlayer.PlaybackStarted"
	VIDEO_PLAYER_PLAYBACK_STOPPED                 = "VideoPlayer.PlaybackStopped"
	VIDEO_PLAYER_PLAYBACK_FINISHED                = "VideoPlayer.PlaybackFinished"
	VIDEO_PLAYER_PLAYBACK_NEARLY_FINISHED         = "VideoPlayer.PlaybackNearlyFinished"
	VIDEO_PLAYER_PLAYBACK_SCHEDULED_STOP_REACHED  = "VideoPlayer.PlaybackScheduledStopReached"
	VIDEO_PLAYER_PROGRESS_REPORT_INTERVAL_ELAPSED = "VideoPlayer.ProgressReportIntervalElapsed"
)

Variables

This section is empty.

Functions

func GetSessionData

func GetSessionData(rawData string) data.Session

func NewRequest

func NewRequest(rawData string) interface{}

Types

type AudioPlayerEventRequest

type AudioPlayerEventRequest struct {
	Data data.AudioPlayerEventRequest
	EventRequest
}

func (*AudioPlayerEventRequest) GetOffsetInMilliseconds

func (this *AudioPlayerEventRequest) GetOffsetInMilliseconds() int32

type Dialog

type Dialog struct {
	Intents     []*Intent
	DialogState string
	// contains filtered or unexported fields
}

func NewDialog

func NewDialog(request data.IntentRequestBody) *Dialog

func (*Dialog) ConfirmIntent

func (this *Dialog) ConfirmIntent() *Dialog

对意图进行确认

func (*Dialog) ConfirmSlot

func (this *Dialog) ConfirmSlot(name string) *Dialog

对槽位进行confirm

func (*Dialog) Delegate

func (this *Dialog) Delegate() *Dialog

托管对话. 对话由DuerOS代为处理

func (*Dialog) ElicitSlot

func (this *Dialog) ElicitSlot(name string) *Dialog

询问槽位

func (*Dialog) GetDirective

func (this *Dialog) GetDirective() *data.DialogDirective

func (*Dialog) GetIntentConfirmationStatus

func (this *Dialog) GetIntentConfirmationStatus(index ...int) string

获取意图的确认状态

func (*Dialog) GetIntentName

func (this *Dialog) GetIntentName() (string, bool)

获取当前意图的名字

func (*Dialog) GetQuery

func (this *Dialog) GetQuery() (string, bool)

获取用户请求的原始query

func (*Dialog) GetSlotConfirmationStatus

func (this *Dialog) GetSlotConfirmationStatus(name string, index ...int) string

获取槽位的确认状态,默认取第一组槽位

func (*Dialog) GetSlotValue

func (this *Dialog) GetSlotValue(name string, index ...int) string

获取槽位的值,默认取第一组槽位

type EventRequest

type EventRequest struct {
	Data data.EventRequest
	Request
}

func (*EventRequest) GetName

func (this *EventRequest) GetName() string

func (*EventRequest) GetUrl

func (this *EventRequest) GetUrl() string

type Intent

type Intent struct {
	Name               string
	ConfirmationStatus string
	// contains filtered or unexported fields
}

func NewIntent

func NewIntent(intent data.Intent) *Intent

func (*Intent) GetData

func (this *Intent) GetData() data.Intent

func (*Intent) GetSlot

func (this *Intent) GetSlot(name string) *data.Slot

根据槽位名获取槽位

func (*Intent) GetSlotStatus

func (this *Intent) GetSlotStatus(name string) string

根据槽位名获取槽位对应的状态

func (*Intent) GetSlotValue

func (this *Intent) GetSlotValue(name string) string

根据槽位名获取槽位对应的值

func (*Intent) SetSlotValue

func (this *Intent) SetSlotValue(name string, value string) bool

设置槽位的值

type IntentRequest

type IntentRequest struct {
	Data   data.IntentRequest
	Dialog *Dialog
	Request
}

func (*IntentRequest) GetIntentName

func (this *IntentRequest) GetIntentName() (string, bool)

获取意图名

func (*IntentRequest) GetQuery

func (this *IntentRequest) GetQuery() string

获取用户请求query

func (*IntentRequest) IsDialogStateCompleted

func (this *IntentRequest) IsDialogStateCompleted() bool

槽位填充是否完成

type LaunchRequest

type LaunchRequest struct {
	Data data.LaunchRequest
	Request
}

type Request

type Request struct {
	Type   string
	Common data.RequestPart
}

func (*Request) GetAccessToken

func (this *Request) GetAccessToken() string

获取access token

func (*Request) GetAudioPlayerContext

func (this *Request) GetAudioPlayerContext() data.AudioPlayerContext

获取音频播放上下文

func (*Request) GetBotId

func (this *Request) GetBotId() string

获取技能id

func (*Request) GetDeviceId

func (this *Request) GetDeviceId() string

获取设备id

func (*Request) GetRequestId

func (this *Request) GetRequestId() string

获取请求id

func (*Request) GetSupportedInterfaces

func (this *Request) GetSupportedInterfaces() map[string]interface{}

获取设备支持的接口类型

func (*Request) GetTimestamp

func (this *Request) GetTimestamp() int

获取请求的时间戳

func (*Request) GetUserId

func (this *Request) GetUserId() string

获取用户id

func (*Request) GetVideoPlayerContext

func (this *Request) GetVideoPlayerContext() data.VideoPlayerContext

获取视频播放上下文

func (*Request) IsSupportAudio

func (this *Request) IsSupportAudio() bool

检查是否支持音频播放

func (*Request) IsSupportDisplay

func (this *Request) IsSupportDisplay() bool

检查是否支持展现

func (*Request) IsSupportVideo

func (this *Request) IsSupportVideo() bool

检查是否支持视频播放

func (*Request) VerifyBotID

func (this *Request) VerifyBotID(myBotID string) bool

验证技能id合法性

func (*Request) VerifyTimestamp

func (this *Request) VerifyTimestamp() bool

验证请求时间戳合法性

type Response

type Response struct {
	// contains filtered or unexported fields
}

func NewResponse

func NewResponse(session *Session, request interface{}) *Response

func (*Response) Ask

func (this *Response) Ask(speech string) *Response

*

  • 询问用户时,返回的speech.
  • 此时设备的麦克风会进入收音状态,比如设备灯光亮起
  • TIP: 一般技能要完成一项任务,还缺少一些信息,主动发起对用户的询问的时候使用

func (*Response) AskSlot

func (this *Response) AskSlot(speech string, slot string) *Response

func (*Response) Build

func (this *Response) Build() string

func (*Response) CloseMicrophone

func (this *Response) CloseMicrophone() *Response

*

  • 保持会话.
  • 关闭麦克风

func (*Response) Command

func (this *Response) Command(directive interface{}) *Response

*

  • 返回指令. 比如,返回音频播放指令,使设备开始播放音频
  • TIP: 可以同时返回多个指令,设备按返回顺序执行这些指令,指令协议参考TODO

func (*Response) DisplayCard

func (this *Response) DisplayCard(card interface{}) *Response

*

  • 返回卡片.
  • 针对有屏幕的设备,比如: 电视、show,可以呈现更多丰富的信息给用户
  • 卡片协议参考:TODO

func (*Response) GetData

func (this *Response) GetData() map[string]interface{}

func (*Response) HoldOn

func (this *Response) HoldOn() *Response

*

  • 保持会话.
  • 此时设备的麦克风会自动开启监听用户说话

func (*Response) Reprompt

func (this *Response) Reprompt(speech string) *Response

*

  • 回复用户,返回的speech

func (*Response) Tell

func (this *Response) Tell(speech string) *Response

*

  • 回复用户,返回的speech

type SSMLTextBuilder

type SSMLTextBuilder struct {
	// contains filtered or unexported fields
}

func NewSSMLTextBuilder

func NewSSMLTextBuilder() *SSMLTextBuilder

func (*SSMLTextBuilder) AppendAudio

func (this *SSMLTextBuilder) AppendAudio(src string) *SSMLTextBuilder

func (*SSMLTextBuilder) AppendBackground

func (this *SSMLTextBuilder) AppendBackground(text string, src string, repeat bool) *SSMLTextBuilder

func (*SSMLTextBuilder) AppendPlainSpeech

func (this *SSMLTextBuilder) AppendPlainSpeech(text string) *SSMLTextBuilder

func (*SSMLTextBuilder) AppendSilence

func (this *SSMLTextBuilder) AppendSilence(time int) *SSMLTextBuilder

func (*SSMLTextBuilder) AppendSubstitution

func (this *SSMLTextBuilder) AppendSubstitution(text, alias string) *SSMLTextBuilder

func (*SSMLTextBuilder) ApplyBackground

func (this *SSMLTextBuilder) ApplyBackground(src string, repeat bool) *SSMLTextBuilder

func (*SSMLTextBuilder) Build

func (this *SSMLTextBuilder) Build() string

type Session

type Session struct {
	// contains filtered or unexported fields
}

func NewSession

func NewSession(data data.Session) *Session

func (*Session) GetAttribute

func (this *Session) GetAttribute(key string) string

获取session中对应字段的值

func (*Session) GetData

func (this *Session) GetData() data.Session

func (*Session) GetId

func (this *Session) GetId() string

获取session id

func (*Session) IsNew

func (this *Session) IsNew() bool

当前session是否是新的

func (*Session) SetAttribute

func (this *Session) SetAttribute(key, value string)

设置session中对应字段的值

type SessionEndedRequest

type SessionEndedRequest struct {
	Data data.SessionEndedRequest
	Request
}

type VideoPlayerEventRequest

type VideoPlayerEventRequest struct {
	Data data.VideoPlayerEventRequest
	EventRequest
}

func (*VideoPlayerEventRequest) GetOffsetInMilliseconds

func (this *VideoPlayerEventRequest) GetOffsetInMilliseconds() int32

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL