Nao机器人语音对话

C:\ProgramFiles\AldebaranRobotics\ChoregrapheSuite2.1\share\doc\getting_started\helloworld_choregraphe_dialog.html

http://doc.aldebaran.com/2-1/naoqi/audio/dialog/dialog-syntax_full.html#delimiter-rule

首先根据这里建立一个工程,然后添加Set language和Dialog模块。


接着双击左上角添加到工程的对话配置文件,这里以中文文件为例子*_mnc.top

输入以下内容

concept:(欢迎语) ^rand[hi hello "你好" "很高兴见到你" "哇" "哇塞"]
u:(~欢迎语) ~欢迎语

u:([hi 你好{Nao} 机器人 科科]) 你好,我的 [主人 老板]
u:(你叫什么名字) 大家都叫我科科!
u:(我的名字叫 _*) 很高兴见到你 $1 $name=$1
u:(我的名字叫 _[小熊 石头]) 很高兴见到你 $1 $name=$1

u:(我好饿) 那你想吃什么呢,$name
u:(我想吃 _*) 你现在想吃 $1 吗,$name $food=$1
u:(我点了什么) ^first["你刚刚点了 $food" "我忘记了"]

u:(给我讲个故事) %故事 好的,要听新故事吗?
u:([!不要 给我讲个新故事 要 好的]) 好的,我会给你讲个新故事!
u:([不要给我讲个新故事 不 不要]) 好的,我会给你讲三个和尚!
u:([Shit Fuck]) 不能讲脏话

proposal: %天气 今天的天气?

因为Nao的语音是离线的,关于对话需要有一定的规则。

NAOqi APIs—Audio—ALDialog

file:///C:/Program%20Files/Aldebaran%20Robotics/Choregraphe%20Suite%202.1/share/doc/naoqi/audio/dialog/aldialog.html#aldialog

file:///C:/Program%20Files/Aldebaran%20Robotics/Choregraphe%20Suite%202.1/share/doc/naoqi/audio/dialog/dialog.html#rule

u( )为用户说的话,写在括号里。方括号[ ]里的为可替代词汇,{ }里 的为可省略词汇。

Concept

A Concept is a list of words and/or phrases that refer to one idea.
For example, a list of countries, a list of names, synonyms of a word.

They can be used both in Human input or Robot output.

There are two types of Concepts:

TypeScopeAt run time ...May contain ...
Staticglobalcannot be modifiedChoice: [ ], Optional part: { }, concepts (static and dynamic), functions (^rand, ^first), Variable: $ and Conditions: == > <> <.
Dynamiclocal to a Topicmust be modifieda list of words or phrases between a single Choice: [ ].

Examples

concept:(want) ^rand {"i'd * like" "i want {"a lot"}"}
dynamic:want
python:
setConcept("want","enu", ["i'd like" "i want" "i want a lot"]

Syntax

concept:(欢迎语) ^rand[hi hello "你好" "很高兴见到你" 哇 哇塞]
u:(~欢迎语) ~欢迎语

file:///C:/Program%20Files/Aldebaran%20Robotics/Choregraphe%20Suite%202.1/share/doc/naoqi/audio/dialog/dialog-syntax_full.html#input-storing

u:(我的名字叫 _[石头 小熊]) 很高兴见到你 $1 $name=$1 ^nextProposal

proposal: 今天的天气不错哦。
   u1:(是的) 我很高兴。
   u1:(不) 我不开心。

proposal: 今天你玩的开心吗?
    u1:([{很}开心 我{很}高兴 呵呵 哈哈]) 欢迎下次再来玩。
    u1:([{不}开心 我{不}高兴]) 我不开心。 ^nextProposal

proposal: 那我给你讲个故事? 

=========================


topic: ~Hello()
language: mnc


#file:///C:/Program%20Files/Aldebaran%20Robotics/Choregraphe%20Suite%202.1/share/doc/naoqi/audio/alanimatedspeech.html#tags

#$my_event=my_value is equivalent to ^pCall(ALMemory.raiseEvent("my_event", "my_value")).


concept:(欢迎语) ^rand[hi hello "嗨" "哈喽" "你好" "很高兴见到你" "哇" "哇塞"]
concept:(repeat) [再说一遍 重复{一次} 你说什么 什么 "你可以再说一遍吗" "我没听清"]
concept:(bye) [bye {拜}拜 goodbye "bye bye" {下次}再见 "再会"]

u:([~欢迎语 "科科" "机器人"]) ~欢迎语

#u:([hi 你好{Nao} 机器人 科科]) "你好 ^start(SitOnPod/Emotions/Neutral/Hello_1) 我的[主人 老板] ^wait(SitOnPod/Emotions/Neutral/Hello_1)"

u:([hi Nao 你好{Nao} 机器人 科科]) 你好, ^pCall(ALMotion.wakeUp()) ^start(animations/Stand/Gestures/Hey_1) 见到你好开心!^wait(animations/Stand/Gestures/Hey_1)

#u:(e:LeftBumperPressed "动动这只脚") 好,我动动这只脚
u:(e:LeftBumperPressed) 好,我动动这只脚
#u:(e:RightBumperPressed "抬抬这只脚") 好,我抬抬这只脚
u:(e:RightBumperPressed) 好,我抬抬这只脚


#################################################################
u:(你叫什么{名字}) 大家都叫我科科!很高兴见到你
#u:^private(我的名字叫 !*) 很高兴见到你 $1 $name=$1 ^nextProposal
u:(我的名字叫 _*) 很高兴见到你 $1 $name=$1 ^gotoRandom(对话)
u:(我{的名字}叫 _[林* 郑* 吴* 陈* 蔡* 黄* 苏* 赵* 李* 周* 张* 王* 老师 张老师 小朋友 鄢武 保来]) 很高兴见到你 $1 $name=$1 ^gotoRandom(对话)

proposal: %对话 今天的天气不错啊。
    u1:(是的) 我很高兴。^gotoRandom(对话)
    u1:(不) 我不开心。^gotoRandom(对话)

proposal: %对话 今天你玩的开心吗?
    u1:([{很}开心 我{很}高兴 呵呵 哈哈]) 欢迎下次再来玩。^gotoRandom(对话)
    u1:([{不}开心 我{不}高兴]) 我会做的更好的,下次再来看我哦。 ^gotoRandom(对话)

proposal: %对话 那我给你表演个节目好吗?
    u1:([好 可以 行 好的 嗯]) 让我想想 ^start(Stand/Waiting/ScratchHead_1) ^wait(Stand/Waiting/ScratchHead_1) ^start(Stand/Waiting/KnockEye_1) ^gotoRandom(对话)
    u1:([不 {我}不想{看} 不行 不好 {我}不要 下次吧 不可以]) ^gotoRandom(对话)
    u1:(~repeat) 好的,我再问你一遍. ^sameProposal

#################################################################
u:(我可以摸摸你吗) 当然可以。

u:([起立 站起来]) 好的,我要站起来了 $wakeup=1
u:([休息 蹲下]) 好的,我要休息了 $rest=1

#################################################################
u:(我好饿) 那你想吃什么呢,$name
u:(我想吃 _*) 你现在想吃 $1 吗,$name $food=$1
u:(我想吃 _[苹果 香蕉]) 你现在想吃 $1 吗,$name $food=$1
u:(我点了什么) ^first["你刚刚点了 $food" "我忘记了"]

u:(给我讲个故事) %故事 好的,要听新故事吗?
u:(!不要 给我讲个新故事) 好的,我会给你讲个新故事!
u:(不要给我讲个新故事) 好的,那我会给你讲老故事 三个和尚!
#u:([Shit Fuck]) 不能讲脏话

u:(外星人) 我不是外星人, 我是人形机器人。

#lower priority level.(你好,外星人或者外星人)
recover:
u:(你好) 你好啊。

===================================


  • 7
    点赞
  • 40
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 9
    评论
nao机器人学习过程中java代码 package com.aldebaran.proxy; import com.aldebaran.proxy.Variant; import com.aldebaran.proxy.ALProxy; public class ALTextToSpeechProxy extends ALProxy { static { System.loadLibrary("jnaoqi"); } public ALProxy proxy; /// /// Default Constructor. /// public ALTextToSpeechProxy(String ip, int port) { super("ALTextToSpeech", ip, port); } /// /// Disables the notifications puted in ALMemory during the synthesis (TextStarted, TextDone, CurrentBookMark, CurrentWord, ...) /// public void disableNotifications() { Variant result = call("disableNotifications" ); // no return value } /// /// Enables the notifications puted in ALMemory during the synthesis (TextStarted, TextDone, CurrentBookMark, CurrentWord, ...) /// public void enableNotifications() { Variant result = call("enableNotifications" ); // no return value } /// /// Exits and unregisters the module. /// public void exit() { Variant result = call("exit" ); // no return value } /// /// Outputs the languages installed on the system. /// /// Array of std::string that contains the languages installed on the system. public String[] getAvailableLanguages() { Variant result = call("getAvailableLanguages" ); return (String[]) result.toStringArray(); } /// /// Outputs the available voices. The returned list contains the voice IDs. /// /// Array of std::string containing the voices installed on the system. public String[] getAvailableVoices() { Variant result = call("getAvailableVoices" ); return (String[]) result.toStringArray(); } /// /// Gets the name of the parent broker. /// /// The name of the parent broker. public String getBrokerName() { Variant result = call("getBrokerName" ); return result.toString(); } /// /// Returns the language currently used by the text-to-speech engine. /// /// Language of the current voice. public String getLanguage() { Variant result = call("getLanguage" ); return result.toString(); } /// /// Returns the encoding that should be used with the specified language. /// /// Language name (as a std::string). Must belong to the languages available in TTS. /// Encoding of the specified language. public String getLanguageEncoding( String pLanguage) { Variant vpLanguage; vpLanguage = new Variant(pLanguage); Variant result = call("getLanguageEncoding" ,vpLanguage); return result.toString(); } /// /// Retrieves a method's description. /// /// The name of the method. /// A structure containing the method's description. public Variant getMethodHelp( String methodName) { Variant vmethodName; vmethodName = new Variant(methodName); Variant result = call("getMethodHelp" ,vmethodName); return result; } /// /// Retrieves the module's method list. /// /// An array of method names. public String[] getMethodList() { Variant result = call("getMethodList" ); return (String[]) result.toStringArray(); } /// /// Retrieves the module's description. /// /// A structure describing the module. public Variant getModuleHelp() { Variant result = call("getModuleHelp" ); return result; } /// /// Returns the value of one of the voice parameters. The available parameters are: \"pitchShift\", \"doubleVoice\",\"doubleVoiceLevel\" and \"doubleVoiceTimeShift\" /// /// Name of the parameter. /// Value of the specified parameter public float getParameter( String pParameterName) { Variant vpParameterName; vpParameterName = new Variant(pParameterName); Variant result = call("getParameter" ,vpParameterName); return result.toFloat(); } /// /// Gets the method usage string. This summarises how to use the method. /// /// The name of the method. /// A string that summarises the usage of the method. public String getUsage( String name) { Variant vname; vname = new Variant(name); Variant result = call("getUsage" ,vname); return result.toString(); } /// /// Returns the voice currently used by the text-to-speech engine. /// /// Name of the current voice public String getVoice() { Variant result = call("getVoice" ); return result.toString(); } /// /// Fetches the current volume the text to speech. /// /// Volume (integer between 0 and 100). public float getVolume() { Variant result = call("getVolume" ); return result.toFloat(); } /// /// Returns true if the method is currently running. /// /// The ID of the method that was returned when calling the method using 'post' /// True if the method is currently running public Boolean isRunning( int id) { Variant vid; vid = new Variant(id); Variant result = call("isRunning" ,vid); return result.toBoolean(); } /// /// Loads a set of voice parameters defined in a xml file contained in the preferences folder.The name of the xml file must begin with ALTextToSpeech_Voice_ /// /// Name of the voice preference. public void loadVoicePreference( String pPreferenceName) { Variant vpPreferenceName; vpPreferenceName = new Variant(pPreferenceName); Variant result = call("loadVoicePreference" ,vpPreferenceName); // no return value } /// /// Just a ping. Always returns true /// /// returns true public Boolean ping() { Variant result = call("ping" ); return result.toBoolean(); } /// /// Performs the text-to-speech operations : it takes a std::string as input and outputs a sound in both speakers. It logs an error if the std::string is empty. String encoding must be UTF8. /// /// Text to say, encoded in UTF-8. public void say( String StringToSay) { Variant vstringToSay; vstringToSay = new Variant(StringToSay); Variant result = call("say" ,vstringToSay); // no return value } /// /// Performs the text-to-speech operations: it takes a std::string as input and outputs the corresponding audio signal in the specified file. /// /// Text to say, encoded in UTF-8. /// RAW file where to store the generated signal. The signal is encoded with a sample rate of 22050Hz, format S16_LE, 2 channels. public void sayToFile( String pStringToSay, String pFileName) { Variant vpStringToSay; vpStringToSay = new Variant(pStringToSay); Variant vpFileName; vpFileName = new Variant(pFileName); Variant result = call("sayToFile" ,vpStringToSay, vpFileName); // no return value } /// /// This method performs the text-to-speech operations: it takes a std::string, outputs the synthesis resulting audio signal in a file, and then plays the audio file. The file is deleted afterwards. It is useful when you want to perform a short synthesis, when few CPU is available. Do not use it if you want a low-latency synthesis or to synthesize a long std::string. /// /// Text to say, encoded in UTF-8. public void sayToFileAndPlay( String pStringToSay) { Variant vpStringToSay; vpStringToSay = new Variant(pStringToSay); Variant result = call("sayToFileAndPlay" ,vpStringToSay); // no return value } /// /// Changes the language used by the Text-to-Speech engine. It automatically changes the voice used since each of them is related to a unique language. If you want that change to take effect automatically after reboot of your robot, refer to the robot web page (setting page). /// /// Language name. Must belong to the languages available in TTS (can be obtained with the getAvailableLanguages method). It should be an identifier std::string. public void setLanguage( String pLanguage) { Variant vpLanguage; vpLanguage = new Variant(pLanguage); Variant result = call("setLanguage" ,vpLanguage); // no return value } /// /// Changes the parameters of the voice. The available parameters are: /// /// pitchShift: applies a pitch shifting to the voice. The value indicates the ratio between the new fundamental frequencies and the old ones (examples: 2.0: an octave above, 1.5: a quint above). Correct range is (1.0 -- 4), or 0 to disable effect. /// /// doubleVoice: adds a second voice to the first one. The value indicates the ratio between the second voice fundamental frequency and the first one. Correct range is (1.0 -- 4), or 0 to disable effect /// /// doubleVoiceLevel: the corresponding value is the level of the double voice (1.0: equal to the main voice one). Correct range is (0 -- 4). /// /// doubleVoiceTimeShift: the corresponding value is the delay between the double voice and the main one. Correct range is (0 -- 0.5) /// /// If the effect value is not available, the effect parameter remains unchanged. /// /// Name of the parameter. /// Value of the parameter. public void setParameter( String pEffectName, float pEffectValue) { Variant vpEffectName; vpEffectName = new Variant(pEffectName); Variant vpEffectValue; vpEffectValue = new Variant(pEffectValue); Variant result = call("setParameter" ,vpEffectName, vpEffectValue); // no return value } /// /// Changes the voice used by the text-to-speech engine. The voice identifier must belong to the installed voices, that can be listed using the 'getAvailableVoices' method. If the voice is not available, it remains unchanged. No exception is thrown in this case. For the time being, only two voices are available by default : Kenny22Enhanced (English voice) and Julie22Enhanced (French voice) /// /// The voice (as a std::string). public void setVoice( String pVoiceID) { Variant vpVoiceID; vpVoiceID = new Variant(pVoiceID); Variant result = call("setVoice" ,vpVoiceID); // no return value } /// /// Sets the volume of text-to-speech output. /// /// Volume (between 0.0 and 1.0). public void setVolume( float volume) { Variant vvolume; vvolume = new Variant(volume); Variant result = call("setVolume" ,vvolume); // no return value } /// /// returns true if the method is currently running /// /// the ID of the method to wait for public void stop( int id) { Variant vid; vid = new Variant(id); Variant result = call("stop" ,vid); // no return value } /// /// This method stops the current and all the pending tasks immediately. /// public void stopAll() { Variant result = call("stopAll" ); // no return value } /// /// Returns the version of the module. /// /// A string containing the version of the module. public String version() { Variant result = call("version" ); return result.toString(); } /// /// Wait for the end of a long running method that was called using 'post' /// /// The ID of the method that was returned when calling the method using 'post' /// The timeout period in ms. To wait indefinately, use a timeoutPeriod of zero. /// True if the timeout period terminated. False if the method returned. public Boolean wait( int id, int timeoutPeriod) { Variant vid; vid = new Variant(id); Variant vtimeoutPeriod; vtimeoutPeriod = new Variant(timeoutPeriod); Variant result = call("wait" ,vid, vtimeoutPeriod); return result.toBoolean(); } }

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

yaked19

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值