Yumi soll mit ihrem alten Chat-Script wieder rumlabern können.
Dazu wird also unser vorhandenes Programm HalloYumi erweitert.
File->New->Chat Topic
Dort hab ich mein FIle "yumi_de" genannt. Eine Sprache konnte man nicht auswählen, es wird die Defaultsprache der App gewählt, hoffentlich ist das deutsch...
topic: ~yumi_de()
# Defining extra concepts out of words or group of words
#concept:(hello) [hello hi hey "good morning" greetings]
# Replying to speech
#u:(~hello) ~hello
hier kippe ich mal mein Sprach Script rein, dass noch aus 2.5 Zeiten stammt:
topic: ~yumi_de()
# Defining extra concepts out of words or group of words
#concept:(hello) [hello hi hey "good morning" greetings]
# Replying to speech
#u:(~hello) ~hello
u: ("Wer bist Du") \vct=135\ ["Ich heisse Yumi und meine Aufgabe ist es, Dir Deine Fragen zum Verlag zu beantworten. Manchmal kann ich Deine Fragen nicht gut verstehen, dann formuliere sie einfach noch einmal neu. Komm ruhig näher, dann verstehe ich Dich besser. Hab keine Angst. Ich beisse nicht. Naja, nicht oft."]
u: ("Was bist Du") \vct=135\ ["Ich bin ein Roboter und heisse Yumi. Ich bin hier, weil ich Dir gerne alle Fragen zum Carow Verlag beantworten möchte."]
Nunja, weiter gehts...
so sieht die onRobotFocusGained Funktion aus:
override fun onRobotFocusGained(qiContext: QiContext) {
// The robot focus is gained.
val say: Say = SayBuilder.with(qiContext) // Create the builder with the context.
.withText("\\vct=135\\Guten Tag, ich heiße Yumi und bin heute Dein persönlicher Quatschpartner.") // Set the text to say.
.build() // Build the say action.
// Execute the action.
say.run()
val topic: Topic = TopicBuilder.with(qiContext) // Create the builder using the QiContext.
.withResource(R.raw.yumi_de) // Set the topic resource.
.build() // Build the topic.
val qiChatbot: QiChatbot = QiChatbotBuilder.with(qiContext)
.withTopic(topic)
.build()
// Store the Chat action.
var chat: Chat? = null
// Create a new Chat action.
chat = ChatBuilder.with(qiContext)
.withChatbot(qiChatbot)
.build()
// Run the Chat action asynchronously.
val chatFuture: Future<Void> = chat.async().run()
}
Tja, funktioniert. Stand von 2.5 erreicht. Nun kann man sich dem QiChat-Protokoll im Detail zuwenden oder aber externe Dienste einbinden.
Kommentare