rivescript for french language|angelz1702|fabrice@telecom4all.be|1345624758|angelz1702|xx|0|91.178.36.59|hello,<br /><br />I am new user of rivescript (very nice)<br />i want to make a bot (intteligent who can learn what i ask to learn<br />+ bot learn this<br />- ok I am save this infos<br />) <br /><br />I wish I could teach him about the people I want<br /> (example:<br /> + Robot I present marc<br /> - Marc nice to meet you give me more info about you<br /><br /> + Robot learn the date of birth marc<br /> - Yes give me his date of birth<br /><br /> ....<br /> )<br /> for each user and create a new save file. rs (marc.rs)<br /> in which there would be variable (like the bot! var name) I do not know if it is possible to make a file like this for the bot but for users<br /><br /> marc.rs<br /> ! id_user var = 1<br /> ! var = Marc name_user<br /> ! var .....<br /><br />another point is for control domotique system (knx-linknx)<br />i want to do some script (perl or other language) to control light bind heating ...<br /><br />+robot turn on light room 1<br />- ok (lanch script to turn on light) (after that wait status of this light) light is now on<br /><br />and all of that by vocal command :) (but in the first step I would be very happy already if it works without voice recognition)<br /><br />question :) <br />1. Is that all this is possible with rivescrip?<br /> 2. someone did it already you do something like this<br /> 3. there you have a little documentation<br />4. is possible to 'patch' rivescript to accept special character of french language as '-....<br />5. I need help :)<br /><br /><br />thank you very much for the time you have already put to read this post and thank you for your help<br />Fabrice<br />ps : sorry my english is not very fluent :)||||
Re: rivescript for french language|Kirsle|casey@cuvou.net|1345651986|Kirsle|xx|0|76.170.44.159|You can have a RiveScript bot learn new replies on the fly by doing something like this:<br /><br />[code]+ learn a new reply<br />- Ok, what will the trigger be?<br /><br />+ *<br />% ok what will the trigger be<br />- &lt;set trigger=&lt;star&gt;&gt;And the reply?<br /><br />+ *<br />% and the reply<br />- &lt;call&gt;learn TRIGGER &lt;get trigger&gt; REPLY &lt;star&gt;&lt;/call&gt;<br />^ I have learned that reply!<br /><br />&gt; object learn perl<br />  my ($rs, $args) = @_;<br />  my $arg = join(&quot; &quot;, @&#123;$args&#125;);<br /><br />  my ($trigger, $reply) = ($arg =~ /TRIGGER (.+?) REPLY (.+?)/);<br /><br />  # learn the new code dynamically<br />  $rs-&gt;stream(&quot;+ $trigger\n- $reply&quot;);<br />  $rs-&gt;sortReplies();<br />&lt; object[/code]<br /><br />You could also use $rs-&gt;write() to write the RiveScript code to a file on disk (but note that this will write *ALL* of the code in memory, creating one large file that has everything the bot knows--not just the new thing it learned). Alternatively, you could simply write the new thing it learned to a file instead:<br /><br />[code]open (my $fh, &quot;&gt;&gt;&quot;, &quot;new-replies.rs&quot;);<br />print &#123;$fh&#125; &quot;+ $trigger\n&quot;;<br />print &#123;$fh&#125; &quot;- $reply\n\n&quot;;<br />close ($fh);<br /><br /># refresh the bot's memory<br />$rs-&gt;loadFile(&quot;new-replies.rs&quot;);<br />$rs-&gt;sortReplies(); # always do this after loading new code![/code]<br /><br />Having said all that, I'm not sure how useful it is to teach the bot new variables about [i]users[/i] in this way, since it already has a way of doing that:<br /><br />[code]+ my name is *<br />- &lt;set name=&lt;formal&gt;&gt;I will remember that your name is &lt;formal&gt;.<br /><br />+ what is my name<br />- Your name is &lt;get name&gt;![/code]<br /><br />RiveScript already has a way of learning details about its individual users (but there's no sharing of information [i]between[/i] users, i.e. if you, the botmaster, tell the bot your favorite color, a different user talking to the bot won't be able to ask &quot;what is angelz1702's favorite color&quot;... and this is by design. :) (privacy concerns and such)<br /><br />As far as preserving user variables between sessions (i.e. if you shut down your bot and then start it back up, and you want it to keep all the user variables it learned), your program will need to manage this. You can use $rs-&gt;getUservars() and related methods to get the variables out of RiveScript and then you could save them to disk or something, and use $rs-&gt;setUservar() to set them again next time your script starts up.<br /><br />For the home automation thing, if you can do this in Perl you can do it in RiveScript... just write a Perl object.<br /><br />[code]+ turn on light room 1<br />- Turning on... &lt;call&gt;automation turn_on_light room 1&lt;/call&gt;<br /><br />&gt; object automation perl<br />  my ($rs, $args) = @_;<br /><br />  # do whatever you need to do in Perl to turn the light on<br />  return &quot;Done!&quot;;<br />&lt; object[/code]<br /><br />Similarly, voice recognition would have to come from outside RiveScript itself and be handled by your program. I'm not sure of any Perl modules that handle voice recognition though (or for that matter, any software for Linux that does this). I recently completed a JavaScript-based RiveScript interpreter though, and one could conceivably use this with [url=http://phonegap.com/]PhoneGap[/url] to make an Android and iPhone app for your bot to live in, and use the voice recognition and text-to-speech APIs provided by those platforms.||1345652011|Kirsle|
Re: rivescript for french language|angelz1702|fabrice@telecom4all.be|1345676171|angelz1702|xx|0|91.178.36.59|hello,<br /><br />thanks for you complete reply :)<br /> <br />for the home automation it's ok thanks<br /><br />for the learn I have one error with the code <br /><br />[code]+ learn a new reply<br />- Ok, what will the trigger be?<br /><br />+ *<br />% ok what will the trigger be<br />- &lt;set trigger=&lt;star&gt;&gt;And the reply?<br /><br />+ *<br />% and the reply<br />- &lt;call&gt;learn TRIGGER &lt;get trigger&gt; REPLY &lt;star&gt;&lt;/call&gt;<br />^ I have learned that reply!<br /><br />&gt; object learn perl<br />  my ($rs, $args) = @_;<br />  my $arg = join(&quot; &quot;, @&#123;$args&#125;);<br /><br />  my ($trigger, $reply) = ($arg =~ /TRIGGER (.+?) REPLY (.+?)/);<br /><br />  # learn the new code dynamically<br />  $rs-&gt;stream(&quot;+ $trigger\n- $reply&quot;);<br />  $rs-&gt;sortReplies();<br />&lt; object <br /><br />[/code]<br /><br />error :<br /><br />Can't use string (&quot;TRIGGER&quot;) as an ARRAY ref while &quot;strict refs&quot; in use at (eval 8) line 3, &lt;STDIN&gt; line 5<br /><br />shame that we can not save multiple user data but I understand the reason for confidentiality<br />but it's possible to save only name and add an id for each user ?<br /><br />for this <br /><br />[code]open (my $fh, &quot;&gt;&gt;&quot;, &quot;new-replies.rs&quot;);<br />print &#123;$fh&#125; &quot;+ $trigger\n&quot;;<br />print &#123;$fh&#125; &quot;- $reply\n\n&quot;;<br />close ($fh);<br /><br /># refresh the bot's memory<br />$rs-&gt;loadFile(&quot;new-replies.rs&quot;);<br />$rs-&gt;sortReplies(); # always do this after loading new code! <br />[/code]<br /><br />i don't undestand where I must put this code<br /><br />thanks a lot for you help||||
Re: rivescript for french language|Kirsle|casey@cuvou.net|1345680430|Kirsle|xx|0|38.122.20.226|[quote]Can't use string (&quot;TRIGGER&quot;) as an ARRAY ref while &quot;strict refs&quot; in use at (eval 8) line 3, &lt;STDIN&gt; line 5[/quote]<br /><br />Are you sure you wrote the code properly? It shouldn't be mentioning anything about the word &quot;TRIGGER&quot; because that was inside a regular expression. I think you probably made a syntax error somewhere.<br /><br />The snippit of Perl code that writes to new-replies.rs would go in the Perl object in the RiveScript code, like:<br /><br />[code]&gt; object learn perl<br /> &nbsp; my ($rs, $args) = @_;<br /> &nbsp; my $arg = join(&quot; &quot;, @&#123;$arg&#125;);<br /> &nbsp; my ($trigger, $reply) = ($arg =~ /^TRIGGER (.+?) REPLY (.+?)$/);<br /><br /> &nbsp; # HERE<br />&lt; object[/code]<br /><br />This is [url=http://www.perl.org/]Perl[/url] code being used in RiveScript. If you're not familiar with Perl, you should probably learn that first (or, if you're more familiar with [url=http://python.org/]Python[/url] instead, use the Python version of RiveScript so that you can use Python code to write these objects).||||
Re: rivescript for french language|angelz1702|fabrice@telecom4all.be|1345682567|angelz1702|xx|0|91.178.36.59|hello again :)<br /><br />for home automation i try to optimise the code but i have a little error<br /><br />[code]<br />+ turn on * * <br />- turn on &lt;star1&gt; &lt;star2&gt;... &lt;call&gt;turn_on &lt;star1&gt; &lt;star2&gt;&lt;/call&gt;<br /><br />&gt; object turn_on perl<br />#!/usr/bin/perl -w<br />my ($rs, $args) = @_;<br />my $type = &quot;$ARGV[0]&quot;;<br /><br />my $location = &quot;$ARGV[1]&quot;;<br />my $device = &quot;&quot;;<br /><br />if (defined($ARGV[2])) &#123;<br />  $device = &quot;$ARGV[2]&quot;;<br />  system(&quot;perl /root/bot/jarvis/turn_on.pl $type $location $device&quot;);<br /><br />&#125;<br />else &#123;<br /> &nbsp; &nbsp; &nbsp; system(&quot;perl /root/bot/jarvis/turn_on.pl $type $location &quot;);<br /><br />&#125;<br /><br /><br />&lt; object [/code]<br /><br />but error<br />Use of uninitialized value $ARGV[1] in string at (eval 6) line 5, &lt;STDIN&gt; line 5.<br /><br />as you have see I don't know very well perl I begin my learning about it (and i don't know nothing in pyton ^^)<br />may be I know well javascript but I don't know if the javascrip interpreter is nice for use in console<br /><br />so I think I will continue my learning of perl (it seems to be very powerful)<br /><br />thanks a lot for your help<br /><br />ps the perl script that is called by rivescript<br />[code]#!/usr/bin/perl -w<br />use Switch;<br /><br />my ($rs, $args) = @_;<br />my $objet=&quot;&quot;;<br />my $type = &quot;$ARGV[0]&quot;;<br />my $location = &quot;$ARGV[1]&quot;;<br /><br />switch (&quot;$type&quot;)&#123;<br />    case &quot;spot&quot; &#123;<br />       switch (&quot;$location&quot;)&#123;<br />          case &quot;cuisine&quot; &#123;<br />             $objet = &quot;1/1/13&quot;;<br />          &#125;<br />       &#125;<br />    &#125;<br />    case &quot;lampe&quot; &#123;<br />       print &quot;lampe allume&quot;;<br />    &#125;<br />    case &quot;lustre&quot; &#123;<br />        print &quot;lustre allume&quot;;<br />    &#125;<br />    case &quot;prise&quot; &#123;<br />       switch (&quot;$location&quot;)&#123;<br />           case &quot;cuisine&quot; &#123;<br />              switch (&quot;$ARGV[2]&quot;)&#123;<br />                 case &quot;radio&quot; &#123;<br />                    $objet = &quot;12/5/1&quot;;<br />                 &#125;<br />              &#125;<br />           &#125;<br />       &#125;<br />     &#125;<br />&#125;<br /><br /># do whatever you need to do in Perl to turn the light on<br /><br />system(&quot;groupswrite ip:192.168.1.25 $objet 1&quot;);[/code]<br />||||
Re: rivescript for french language|Kirsle|casey@cuvou.net|1345683712|Kirsle|xx|0|38.122.20.226|In the Perl RiveScript objects, the arguments are sent in through the $args variable (it's an array reference). So instead of using $ARGV[0], use $args-&gt;[0].<br /><br />In Perl, @ARGV is the list of command line arguments given [i]to your Perl script[/i] when you run it. They're not useful besides that. In RiveScript, it will call your Perl code and give it $rs (a reference to the RiveScript instance), and $args (the array reference to the parameters sent to your code from RiveScript).||||
Re: rivescript for french language|angelz1702|fabrice@telecom4all.be|1345719014|angelz1702|xx|0|91.178.36.59|hello,<br /><br />I really struggled for just a simple passing arguments ...<br /> I read a lot of web page on the subject and try a lot of different ways to pass arguments (array, string)<br /> but always a mistake<br /><br />[code]<br /><br />+ allume * * *<br />- allumage &lt;star1&gt; &lt;star2&gt; &lt;star3&gt; ... &lt;call&gt;turn_on &lt;star1&gt; &lt;star2&gt; &lt;star3&gt;&lt;/call&gt;<br /><br /><br />+ allume * * <br />- allumage &lt;star1&gt; &lt;star2&gt; ... &lt;call&gt;turn_on &lt;star1&gt; &lt;star2&gt; &lt;/call&gt;<br /><br /><br /><br /><br />&gt; object turn_on perl<br />#!/usr/bin/perl -w<br /><br />my ($rs, $args) = @_;<br />my $type = &quot;$args-&gt;[0]&quot;;<br />my $location = &quot;$args-&gt;[1]&quot;;<br />my $device = &quot;&quot;;<br />if (defined &quot;$args-&gt;[2]&quot;) &#123;<br />  $device = &quot;$args-&gt;[2]&quot;;<br />  system(&quot;perl /root/bot/jarvis/test.pl $type $location $device&quot;);<br />&#125;<br />else &#123;<br /> &nbsp; &nbsp; &nbsp; system(&quot;perl /root/bot/jarvis/test.pl $type $location &quot;);<br />&#125;<br />&lt; object <br />[/code]<br /><br />if you could unblock me<br /><br /> apparently there are some differences between perl and perl rivescript, is there documentation on the differences between the two<br /><br />thanks<br />regards||||
Re: rivescript for french language|Kirsle|casey@cuvou.net|1345739153|Kirsle|xx|0|76.170.44.159|Maybe it'll make it easier if I tell you how the Perl code inside RiveScript works. ;)<br /><br />When you create a RiveScript object like this:<br /><br />[code]&gt; object md5sum perl<br /> &nbsp; my ($rs, $args) = @_;<br /> &nbsp; require Digest::MD5;<br /> &nbsp; return Digest::MD5::md5_hex(join(&quot; &quot;, @&#123;$args&#125;);<br />&lt; object[/code]<br /><br />RiveScript turns that into this Perl code:<br /><br />[code]sub RSOBJ_md5sum &#123;<br /> &nbsp; my ($rs, $args) = @_;<br /> &nbsp; require Digest::MD5;<br /> &nbsp; return Digest::MD5::md5_hex(join(&quot; &quot;, @&#123;$args&#125;);<br />&#125;[/code]<br /><br />And then it just evaluates that code. When you call it from your RiveScript reply, it just calls the Perl subroutine &amp;RSOBJ_md5sum() and gives it $rs (a reference to the RS module) and $args (an array reference of args sent to it).<br /><br />So:<br /><br />[code]+ md5sum *<br />- The MD5 hash is: &lt;call&gt;md5sum &lt;star&gt;&lt;/call&gt;[/code]<br /><br />This translates to this Perl code:<br /><br />[code]$reply = &quot;The MD5 hash is: &quot;;<br />$reply .= &amp;RSOBJ_md5sum ($rs, [ $star1 ]);[/code]<br /><br />So... it's all the same Perl as you'd write programs in outside of RiveScript. RiveScript just creates a subroutine that it calls, passes a couple arguments to, and takes the return value to include in the reply.||||
Re: rivescript for french language|angelz1702|fabrice@telecom4all.be|1345749186|angelz1702|xx|0|91.178.36.59|hello thanks for this informations<br />I understant (a little) how rivescript 'speak' with perl but I don't see how I can pass argument and how receive argument<br /><br />with eg is better :)<br />[code]<br />+ allume * * <br />- allumage &lt;star1&gt; &lt;star2&gt; ... &lt;call&gt;turn_on &lt;star1&gt; &lt;star2&gt; &lt;/call&gt;<br /><br />&lt;star1&gt; is arg1 and &lt;star2&gt; is arg2<br /><br /><br />&gt; object turn_on perl                     #object rivescript<br />#!/usr/bin/perl -w                       #I don't know if this line is necessary<br /><br />my ($rs, $args) = @_;                    #here is initialisation variable i think ?<br /><br /><br />my $type = &quot;@&#123;$args&#125;)-&gt;[0]&quot;;            #here I want to recover the arg1 (&lt;star1&gt;) but i suck do this always same error<br />                   # Can't use string (&quot;spot&quot;) as an ARRAY ref while &quot;strict refs&quot; in use at (eval 6) line 4, &lt;STDIN&gt; line 3<br />                                  # &quot;spot&quot; is the &lt;star1&gt;<br />my $location = &quot;@&#123;$args&#125;-&gt;[1]&quot;;          #same as over but arg2 (&lt;star2&gt;)<br />my $device = &quot;&quot;;<br /><br />if (defined &quot;@&#123;$args&#125;-&gt;[2]&quot;) &#123;<br />  $device = &quot;@&#123;$args&#125;)-&gt;[2]&quot;;<br />  system(&quot;perl /root/bot/jarvis/test.pl $type $location $device&quot;);   #here I call a perl script on my linux with <br />                                                   # argument arg1 arg2 arg3<br /><br />&#125;<br />else &#123;<br /> &nbsp; &nbsp; &nbsp; system(&quot;perl /root/bot/jarvis/test.pl $type $location &quot;);<br /><br />&#125;<br /><br />[/code]<br />I have dificult to recover args to use in script<br /><br />sorry for my probably stupid question but ... :)<br /><br />thanks<br /><br />&lt; object ||||
Re: rivescript for french language|Kirsle|casey@cuvou.net|1345751999|Kirsle|xx|0|38.122.20.226|Oh, sorry about that. I haven't used Perl RiveScript in a while and forgot the details of how things worked (with Python and JavaScript, arrays always act like array references do in Perl, so I got a big confused).<br /><br />Perl objects don't receive an array reference, but a regular list of arguments. So what you'd want to do is this:<br /><br />[code]my ($rs, $type, $location) = @_;[/code]<br /><br />Or:<br /><br />[code]my ($rs, @args) = @_;<br />my $type = $args[0];<br />my $location = $args[1];[/code]<br /><br />Sorry about the confusion. :) <br /><br />And yes, the #!/usr/bin/perl line isn't useful there (it's just taken as a normal commented line of code... the #! line is only special when used as the very first line of the perl file that you execute from e.g. a terminal window).||1345752087|Kirsle|
Re: rivescript for french language|angelz1702|fabrice@telecom4all.be|1345759958|angelz1702|xx|0|91.178.36.59|[color=#0000ff]<br />ok thanks my homeautomation works :)<br />for the user who need there is the code<br /><br />domotic.rs<br />[code]<br />+ turn on * * *<br />- turn on &lt;star1&gt; &lt;star2&gt; &lt;star3&gt; ... &lt;call&gt;turn_on &lt;star1&gt; &lt;star2&gt; &lt;star3&gt;&lt;/call&gt;<br /><br />+ turn on * * <br />- turn on &lt;star1&gt; &lt;star2&gt; ... &lt;call&gt;turn_on &lt;star1&gt; &lt;star2&gt; &lt;/call&gt;<br /><br />+ turn off * * *<br />- turn off &lt;star1&gt; &lt;star2&gt; &lt;star3&gt; ... &lt;call&gt;turn_off &lt;star1&gt; &lt;star2&gt; &lt;star3&gt;&lt;/call&gt;<br /><br />+ turn off * * <br />- turn off &lt;star1&gt; &lt;star2&gt;... &lt;call&gt;turn_off &lt;star1&gt; &lt;star2&gt; &lt;/call&gt;<br /><br />&gt; object turn_on perl<br />my ($rs, @args) = @_;<br />my $type = $args[0];<br />my $location = $args[1]; <br />my $device = &quot;&quot;;<br />if (defined $args[2]) &#123;<br />  $device = $args[2];<br />  system(&quot;perl /root/bot/jarvis/turn_on.pl $type $location $device&quot;);<br /><br />&#125;<br />else &#123;<br /> &nbsp; &nbsp; &nbsp; system(&quot;perl /root/bot/jarvis/turn_on.pl $type $location &quot;);<br />&#125;<br />&lt; object <br /><br />&gt; object turn_off perl<br />my ($rs, @args) = @_;<br />my $type = $args[0];<br />my $location = $args[1]; <br />my $device = &quot;&quot;;<br />if (defined $args[2]) &#123;<br />  $device = $args[2];<br />  system(&quot;perl /root/bot/jarvis/turn_off.pl $type $location $device&quot;);<br />&#125;<br />else &#123;<br /> &nbsp; &nbsp; &nbsp; system(&quot;perl /root/bot/jarvis/turn_off.pl $type $location &quot;);<br />&#125;<br />&lt; object<br />[/code]<br /><br />and the perl script to connect linknx and turn on<br /><br />turn_on.pl<br />[code]<br />#!/usr/bin/perl -w<br />use Switch;<br />use IO::Socket;<br />my ($rs, $args) = @_;<br />my $remote_host=&quot;192.168.1.25&quot;;   # ip addresse linknx<br />my $remote_port=1028;        # port du Server<br />my $protocole=&quot;tcp&quot;;       <br />my $objet=&quot;&quot;;<br />my $type = &quot;$ARGV[0]&quot;;<br />my $location = &quot;$ARGV[1]&quot;;<br />my $device = &quot;&quot;;<br />if (defined $ARGV[2]) &#123;<br />  $device = &quot;$ARGV[2]&quot;;<br />&#125;<br />switch (&quot;$type&quot;)&#123;<br />    case &quot;spot&quot; &#123;<br />       switch (&quot;$location&quot;)&#123;<br />          case &quot;cuisine&quot; &#123;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;   $objet = &quot;spots_cuisine_on_off&quot;; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />          &#125;<br />       &#125;<br />    &#125;<br />    case &quot;lampe&quot; &#123;<br />       print &quot;lampe allume&quot;;<br />    &#125;<br />    case &quot;lustre&quot; &#123;<br />        print &quot;lustre allume&quot;;<br />    &#125;<br />    case &quot;prise&quot; &#123;<br />       switch (&quot;$location&quot;)&#123;<br />           case &quot;cuisine&quot; &#123;<br />              switch (&quot;$device&quot;)&#123;<br />                 case &quot;radio&quot; &#123;<br />                  $objet = &quot;prise_radio_a1&quot;;<br />                 &#125;<br />              &#125;<br />           &#125;<br />       &#125;<br />     &#125;<br />&#125;<br /><br />my $socket = IO::Socket::INET-&gt;new(PeerAddr =&gt; $remote_host, <br />                PeerPort =&gt; $remote_port,<br />                Proto  =&gt; $protocole,<br />                Type   =&gt; SOCK_STREAM)<br />  or die &quot;Echec de connexion avec les parametres suivant: $remote_host:$remote_port : $@n&quot;;<br /><br /><br /><br />$tmp=&quot;&lt;write&gt;&lt;object id='$objet' value='on'/&gt;&lt;/write&gt;\4&quot;;<br /><br />$socket-&gt;send($tmp);<br /><br />close($socket);<br /><br /><br />[/code]<br />turn_off.pl<br />[code]<br />#!/usr/bin/perl -w<br />use Switch;<br />use IO::Socket;<br />my ($rs, $args) = @_;<br />my $remote_host=&quot;192.168.1.25&quot;;   # ip addresse linknx<br />my $remote_port=1028;        # port du Server<br />my $protocole=&quot;tcp&quot;;       <br />my $objet=&quot;&quot;;<br />my $type = &quot;$ARGV[0]&quot;;<br />my $location = &quot;$ARGV[1]&quot;;<br />my $device = &quot;&quot;;<br />if (defined $ARGV[2]) &#123;<br />  $device = &quot;$ARGV[2]&quot;;<br />&#125;<br />switch (&quot;$type&quot;)&#123;<br />    case &quot;spot&quot; &#123;<br />       switch (&quot;$location&quot;)&#123;<br />          case &quot;cuisine&quot; &#123;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;   $objet = &quot;spots_cuisine_on_off&quot;; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />          &#125;<br />       &#125;<br />    &#125;<br />    case &quot;lampe&quot; &#123;<br />       print &quot;lampe allume&quot;;<br />    &#125;<br />    case &quot;lustre&quot; &#123;<br />        print &quot;lustre allume&quot;;<br />    &#125;<br />    case &quot;prise&quot; &#123;<br />       switch (&quot;$location&quot;)&#123;<br />           case &quot;cuisine&quot; &#123;<br />              switch (&quot;$device&quot;)&#123;<br />                 case &quot;radio&quot; &#123;<br />                  $objet = &quot;prise_radio_a1&quot;;<br />                 &#125;<br />              &#125;<br />           &#125;<br />       &#125;<br />     &#125;<br />&#125;<br /><br />my $socket = IO::Socket::INET-&gt;new(PeerAddr =&gt; $remote_host, <br />                PeerPort =&gt; $remote_port,<br />                Proto  =&gt; $protocole,<br />                Type   =&gt; SOCK_STREAM)<br />  or die &quot;Echec de connexion avec les parametres suivant: $remote_host:$remote_port : $@n&quot;;<br /><br /><br /><br />$tmp=&quot;&lt;write&gt;&lt;object id='$objet' value='off'/&gt;&lt;/write&gt;\4&quot;;<br /><br />$socket-&gt;send($tmp);<br /><br />close($socket);<br /><br /><br />[/code]<br /><br />thanks Kirsle for your help[/color]||||
Re: rivescript for french language|angelz1702|fabrice@telecom4all.be|1345760717|angelz1702|xx|0|91.178.36.59|another problem variable with the script learn<br />[code]<br />+ learn a new reply<br />- Ok, what will the trigger be?<br /><br />+ *<br />% ok what will the trigger be<br />- &lt;set trigger=&lt;star&gt;&gt;And the reply?<br /><br />+ *<br />% and the reply<br />- &lt;call&gt;learn TRIGGER &lt;get trigger&gt; REPLY &lt;star&gt;&lt;/call&gt;<br />^ I have learned that reply!<br /><br />&gt; object learn perl<br />  my ($rs, $args) = @_;<br />  my $arg = join(&quot; &quot;, @&#123;$args&#125;);<br /><br />  my ($trigger, $reply) = ($arg =~ /TRIGGER (.+?) REPLY (.+?)/);<br /><br />  # learn the new code dynamically<br />  $rs-&gt;stream(&quot;+ $trigger\n- $reply&quot;);<br />  $rs-&gt;sortReplies();<br />&lt; object <br />[/code]<br /><br />error :<br />Can't use string (&quot;TRIGGER&quot;) as an ARRAY ref while &quot;strict refs&quot; in use at (eval 8) line 3, &lt;STDIN&gt; line 5.<br /><br />apparently a proble with the argument same as homeautomation<br />I think the proble is in this line <br />my $arg = join(&quot; &quot;, @&#123;$args&#125;);<br />but I don't see how correct it<br /><br />another question it's possible to have a script to delete one tigger add before but not correct ?<br /><br />thanks very mutch||||
Re: rivescript for french language|Kirsle|casey@cuvou.net|1345764695|Kirsle|xx|0|38.122.20.226|Its another array reference problem.<br /><br />my ($rs, @args) = @_;<br />my $arg = join &quot; &quot;, @args;<br /><br /> you don't need to delete a trigger first to redefine the reply. Simply reusing the same trigger with new reply info will do the trick. :-) ||||
Re: rivescript for french language|angelz1702|fabrice@telecom4all.be|1345765935|angelz1702|xx|0|91.178.36.59|ok this correct the error variable<br />now another error &nbsp;:)<br /><br />Bot&gt; [ERR: Object Not Found]I have learned that reply!<br /><br />complete code here :<br />[code]<br />+ learn a new reply<br />- Ok, what will the trigger be?<br /><br />+ *<br />% ok what will the trigger be<br />- &lt;set trigger= &lt;star&gt; &gt;And the reply?<br /><br />+ *<br />% and the reply<br />- &lt;call&gt;learn TRIGGER &lt;get trigger&gt; REPLY &lt;star&gt; &lt;/call&gt;<br />^ I have learned that reply!<br /><br />&gt; object learn perl<br /> &nbsp; my ($rs, $args) = @_;<br /> &nbsp; my $arg = join &quot; &quot;, @args;<br /><br /> &nbsp; my ($trigger, $reply) = ($arg =~ /TRIGGER (.+?) REPLY (.+?)/);<br /><br /> &nbsp; # learn the new code dynamically<br /> &nbsp; $rs-&gt;stream(&quot;+ $trigger\n- $reply&quot;);<br /> &nbsp; $rs-&gt;sortReplies();<br />&lt; object <br />[/code]||||
Re: rivescript for french language|Kirsle|casey@cuvou.net|1345766897|Kirsle|xx|0|38.122.20.226|There's a runtime error in that code. ;)<br /><br />[quote]  my ($rs, [blue]@args[/blue]) = @_;<br />  my $arg = join &quot; &quot;, @args;[/quote]||||
Re: rivescript for french language|angelz1702|fabrice@telecom4all.be|1345808683|angelz1702|xx|0|91.178.36.59|ok nice all is ok :)<br /><br />thanks<br /><br />2 another question ^^<br /><br />1. it's possible to &quot;patch&quot; Rivescript for accept special character on tigger (french language '-) ?<br /><br />2. it's possible to &quot;link&quot; rivescrip to wikipedia <br /> &nbsp; &nbsp; &nbsp;eg:<br />  + robot search definition of *<br />  - yes ... &lt;call&gt;wikipedia<br /><br />  + robot search information of *<br />  - yes ... &lt;call&gt;wikipedia<br /><br />...<br />3. a &quot;link&quot; with weather for belgium :)<br />  + robot waht is the weather today*<br />  - yes ... &lt;call&gt;weather<br /><br />thanks very a lot <br /><br />ps : 4. how I can activate the bot by his name ?<br /> &nbsp; &nbsp; &nbsp;I try this but :(<br /> &nbsp; &nbsp;<br />[code]<br />&gt; begin<br /> &nbsp; &nbsp; &nbsp;+ request<br /> &nbsp; &nbsp; &nbsp; &nbsp;* &lt;get met&gt; != true =&gt; &#123;topic=welcome&#125;&#123;ok&#125;<br /> &nbsp; &nbsp; &nbsp;- &#123;ok&#125;<br />&lt; begin<br /><br />&gt; topic welcome<br /> &nbsp; &nbsp; &nbsp;+ robot #bot name<br /> &nbsp; &nbsp; &nbsp;- hello how can i help you ?&lt;set met=true&gt;<br />&lt; topic<br /><br />[/code]<br /><br />You&gt; robot<br />but with this i am blocked <br />Bot&gt; ERR: No Reply Matched<br />||1345810944|angelz1702|
Re: rivescript for french language|Kirsle|casey@cuvou.net|1345822706|Kirsle|xx|0|76.170.44.159|It should be possible to patch RiveScript to support UTF-8 characters, but I haven't looked into it very closely.<br /><br />You can write objects to fetch things from wikipedia or get weather reports and such. You can use the Perl module [url=http://search.cpan.org/perldoc?LWP::Simple]LWP::Simple[/url] to fetch content from URLs and then parse the responses you get from the server to find the info you need.<br /><br />Don't use # as a comment character, that's obsolete -- especially on the same line as a trigger (in triggers, # is a wildcard character that matches numbers). Use // for comments instead, like in JavaScript.<br /><br />You can use &lt;bot name&gt; in a trigger if you want the bot's own name to be used, like:<br /><br />[code]! var name = Android<br /><br />+ hello &lt;bot name&gt;<br />- Hello yourself, &lt;get name&gt;!<br /><br />+ my name is &lt;bot name&gt;<br />- Wow, that's my name too![/code]||||
Re: rivescript for french language|angelz1702|fabrice@telecom4all.be|1345844599|angelz1702|xx|0|91.178.36.59|hello,<br /><br />thanks for reply I will search to create 'widget' for weather and wiki:)<br /><br />for the moment I am trying to run the voice recognition :)<br />with espeak and mbrola<br /><br />I use this little script to to read a text (works fine)<br /><br />[code]<br />espeak -vmb/mb-fr4 &quot;\$@&quot; &#124; mbrola -t 1.4 -f 1.1 /usr/share/mbrola/voices/fr4 - -.au &#124; aplay -D plughw:2,0 - 2&gt;/dev/null<br />EOF<br />[/code]<br /><br />sayit &quot;text to read&quot; <br /><br />but I don(t see how I can use this script with rivescript, are you an idea ?<br /><br />thanks||||
Re: rivescript for french language|Kirsle|casey@cuvou.net|1345848520|Kirsle|xx|0|38.122.20.226|I'm not familiar with any of those programs. :(<br /><br />If the programs take text to speak out loud via standard input, you can probably pipe them in via Perl. For example, if the usage of a text-to-speech program on the CLI would be like this:<br /><br />[code]$ tts &lt; my_text_file.txt[/code]<br /><br />..and it would read the contents of my_text_file.txt out loud, you could simulate this input in Perl by opening it like this:<br /><br />[code]open (my $tts, &quot;&#124;-&quot;, &quot;/usr/bin/tts&quot;);<br />print &#123;$tts&#125; &quot;hello human, this text should be read out loud&quot;;<br />close ($tts);[/code]<br /><br />Or: if the program accepts text input via command line arguments, which is the case with the `say` command on Mac OS X, you could invoke it like this from Perl:<br /><br />[code]system(&quot;/usr/bin/say&quot;, &quot;hello human, this text should be read out loud&quot;);[/code]<br /><br />(side note: you should usually use the multiple-argument version of system() instead of the single-argument version that you were using in your other code snippits. it's safer. see http://perldoc.perl.org/functions/system.html)<br /><br />If you have a program that listens for the human to say something out loud and converts it to text, hopefully a lot of the same mechanics will apply. For example, if the program listens to you and writes the text version to its standard output, so that this would show up on the command prompt:<br /><br />[code]$ voice-to-text<br />Hello, this is just a test.[/code]<br /><br />You could open this with a pipe and read from its standard output in Perl:<br /><br />[code]open (my $fh, &quot;-&#124;&quot;, &quot;/usr/bin/voice-to-text&quot;);<br />while (my $line = &lt;$fh&gt;) &#123;<br />  print &quot;Read from voice-to-text: $line&quot;;<br />&#125;<br />close ($fh);[/code]<br /><br />See http://perldoc.perl.org/perlopentut.html#Pipe-Opens||1345848633|Kirsle|
Re: rivescript for french language|angelz1702|fabrice@telecom4all.be|1345856090|angelz1702|xx|0|91.178.36.59|hello,<br /><br />thanks for help it's woks :)<br />[code]<br />+ robot<br />- &lt;call&gt;talk hello can i help you&lt;/call&gt;<br /><br />&gt; object talk perl<br /> my ($rs, @args) = @_;<br /> my $arg = join &quot; &quot;, @args;<br /> <br />system(&quot;/usr/local/bin/sayit&quot;, $arg); <br />&lt; object<br /><br />[/code]<br /><br />but is it possible to ensure that everything says the robot is read?<br />or do I need to call each time the topic &quot;talk&quot;<br />||||
Re: rivescript for french language|Kirsle|casey@cuvou.net|1345856260|Kirsle|xx|0|76.170.44.159|You can probably handle this in the Perl code running the bot.<br /><br />[code]use RiveScript;<br /><br />my $rs = new RiveScript();<br />$rs-&gt;loadDirectory(&quot;./replies&quot;);<br />$rs-&gt;sortReplies();<br /><br />while (1) &#123;<br /> &nbsp; print &quot;You&gt; &quot;;<br /> &nbsp; chomp(my $message = &lt;STDIN&gt;);<br /><br /> &nbsp; my $reply = $rs-&gt;reply(&quot;user&quot;, $message);<br /> &nbsp; print &quot;Bot&gt; $reply\n&quot;;<br /> &nbsp; system(&quot;/usr/local/bin/sayit&quot;, $reply);<br />&#125;[/code]||||
Re: rivescript for french language|angelz1702|fabrice@telecom4all.be|1345858776|angelz1702|xx|0|91.178.36.59|thanks it's works :)<br /><br />next step speech to text :)<br /><br /><br /> thanks for you big help<br />||||
Re: rivescript for french language|angelz1702|fabrice@telecom4all.be|1347521342|angelz1702|xx|0|91.178.9.178|hello is still me :)<br /><br />I work on the speetch to text <br />I have a file who's record my order with an 'echo $vocal &gt; file'<br /><br />how I can use this <br /><br /><br /> Code:open (my $fh, &quot;-&#124;&quot;, &quot;/usr/bin/voice-to-text&quot;);<br />while (my $line = &lt;$fh&gt;) &#123;<br /> &nbsp; print &quot;Read from voice-to-text: $line&quot;;<br />&#125;<br />close ($fh); <br /><br />for eatch new line in this file send to rivescript<br /><br />I don't see how I can do that<br /><br />thanks||||
Re: rivescript for french language|Kirsle|casey@cuvou.net|1347552515|Kirsle|xx|0|76.170.44.159|Something like this?<br /><br />[code]open (my $fh, &quot;-&#124;&quot;, &quot;/usr/bin/voice-to-text&quot;);<br />while (my $line = &lt;$fh&gt;) &#123;<br /> &nbsp; print &quot;User&gt; $line\n&quot;;<br /><br /> &nbsp; my $reply = $rs-&gt;reply(&quot;user&quot;, $line);<br /> &nbsp; print &quot;Bot&gt; $reply\n&quot;;<br /><br /> &nbsp; system(&quot;/usr/bin/espeak&quot;, $line);<br />&#125;<br />close ($fh); [/code]||||
Re: rivescript for french language|angelz1702|fabrice@telecom4all.be|1348342331|angelz1702|xx|0|91.178.67.161|hello,<br /><br />I have try this code<br /><br />for launch the bot i have this code :<br /><br />[code]<br /><br />#!/usr/bin/perl -w<br />use RiveScript;<br /><br />my $rs = new RiveScript();<br />$rs-&gt;loadDirectory(&quot;./cervo&quot;);<br />$rs-&gt;sortReplies();<br /><br />while (1) &#123;<br />  print &quot;You&gt; &quot;;<br />  chomp(my $message = &lt;STDIN&gt;);<br /><br />  my $reply = $rs-&gt;reply(&quot;user&quot;, $message);<br />  print &quot;Bot&gt; $reply\n&quot;;<br />  system(&quot;/usr/local/bin/sayit&quot;, $reply);<br />&#125;<br /><br /><br />@ARGV = (&quot;/media/owl_db/recovocal&quot;);<br /><br />while ($line = &lt;&gt;)&#123;<br /> print &quot;User&gt; $line\n&quot;;<br /><br />  my $reply = $rs-&gt;reply(&quot;user&quot;, $line);<br />  print &quot;Bot&gt; $reply\n&quot;;<br /><br />  system(&quot;/usr/local/bin/sayit&quot;, $line);<br /><br /><br />&#125;<br />[/code]<br /><br />the text to speech works<br />but the speech to text no ..<br /> maybe I don't use correctly<br />have you an idea ?<br /><br />thanks||||
Re: rivescript for french language|Kirsle|casey@cuvou.net|1348511202|Kirsle|xx|0|38.122.20.226|The code is probably getting caught up in that first while(1) loop and not getting any further. Also, I'm pretty sure that @ARGV part is wrong. Try something like this:<br /><br />[code]#!/usr/bin/perl -w<br />use RiveScript;<br /><br />my $rs = new RiveScript();<br />$rs-&gt;loadDirectory(&quot;./cervo&quot;);<br />$rs-&gt;sortReplies();<br /><br />open (my $voice, &quot;-&#124;&quot;, &quot;/media/owl_db/recovocal&quot;);<br />while (my $line = &lt;$voice&gt;)&#123;<br /> print &quot;User&gt; $line\n&quot;;<br /><br />  my $reply = $rs-&gt;reply(&quot;user&quot;, $line);<br />  print &quot;Bot&gt; $reply\n&quot;;<br /><br />  system(&quot;/usr/local/bin/sayit&quot;, $reply);<br />&#125;[/code]||1348511241|Kirsle|
Re: rivescript for french language|angelz1702|fabrice@telecom4all.be|1348664468|angelz1702|xx|0|91.178.35.123|hello,<br /><br />I have try with this code but don't works :(<br /><br />i have try change the code as this :<br /><br />[code]#!/usr/bin/perl -w<br />use RiveScript;<br /><br />my $rs = new RiveScript();<br />$rs-&gt;loadDirectory(&quot;./cervo&quot;);<br />$rs-&gt;sortReplies();<br /><br />open (my $voice, &quot;-&#124;&quot;, &quot;/media/test&quot;);<br />while (my $line = &lt;$voice&gt;) &#123;<br /><br /><br /> &nbsp; print &quot;You&gt; $line\n&quot;;<br /> &nbsp; chomp(my $message = &lt;STDIN&gt;);<br /><br /> &nbsp; my $reply = $rs-&gt;reply(&quot;user&quot;, $message);<br /> &nbsp; print &quot;Bot&gt; $reply\n&quot;;<br /> &nbsp; system(&quot;/usr/local/bin/sayit&quot;, $reply);<br />&#125;<br />[/code]<br /><br />and the file /media/test contain :<br />[code]allume spot cuisine[/code]<br /><br />and when I try the code I don't see the prompt of the bot and I have this message :<br /><br /><br />perl bot.pl <br />/media/test: 1: allume: not found<br /><br />thanks for your help :)<br />Fabrce||||
Re: rivescript for french language|Kirsle|casey@cuvou.net|1348679768|Kirsle|xx|0|38.122.20.226|I was assuming that /media/owl_db/recovocal was a program that would listen to your microphone and print out the speech-to-text that it recognizes to standard output.<br /><br />If you're opening a flat text file, replace the &quot;-&#124;&quot; part with a &quot;&lt;&quot; instead. General examples:<br /><br />[code]# Reading from a text file<br />open (my $fh, &quot;&lt;&quot;, &quot;/etc/fstab&quot;);<br />print while &lt;$fh&gt;;<br />close ($fh);<br /><br /># Reading output from a program<br />open (my $fh, &quot;-&#124;&quot;, &quot;/usr/bin/mount&quot;);<br />print while &lt;$fh&gt;;<br />close ($fh);[/code]<br /><br />See http://perldoc.perl.org/functions/open.html||||
Re: rivescript for french language|angelz1702|fabrice@telecom4all.be|1348687238|angelz1702|xx|0|91.178.35.123|ok a little step in more :)<br /><br />now with this code <br /><br />bot.pl<br />[code]#!/usr/bin/perl -w<br />use RiveScript;<br /><br />my $rs = new RiveScript();<br />$rs-&gt;loadDirectory(&quot;./cervo&quot;);<br />$rs-&gt;sortReplies();<br /><br />open (my $voice, &quot;&lt;&quot;, &quot;/media/test&quot;);<br />while (my $line = &lt;$voice&gt;) &#123;<br /><br /><br />  print &quot;You&gt; $line\n&quot;;<br />  chomp(my $message = &lt;STDIN&gt;);<br /><br />  my $reply = $rs-&gt;reply(&quot;user&quot;, $message);<br />  print &quot;Bot&gt; $reply\n&quot;;<br />  system(&quot;/usr/local/bin/sayit&quot;, $reply);<br />&#125;[/code]<br /><br />when I launch<br />perl bot.pl<br /><br />it's read the line on the file but add an space or return and of course the sentence is not reconyse by the bot (not in the .rs)<br /><br />example :<br /><br />when I try : <br />[code]<br />./bot.pl  <br />You&gt; allume spot cuisine<br /><br /><br />[/code]<br />the program stop here<br />if I press enter :<br /><br />Bot&gt; je suis une version beta j'ai peut encore quelques problemes !<br /><br />and close the prgram<br /><br />the sentence allume spot cuisine is not reconise by the bot because (i think) there are space or return after the sentence<br /><br />and the program don't 'simulate' the enter key<br /><br />thanks for help<br />||||
Re: rivescript for french language|Kirsle|casey@cuvou.net|1348688686|Kirsle|xx|0|38.122.20.226|A few problems:<br /><br />1) This line needs to go:<br /><br />[code] &nbsp; chomp(my $message = &lt;STDIN&gt;);[/code]<br /><br />What this line does is, it reads a line of text from STanDard INput (where you would type something and hit enter). The reason you have to hit enter when you run your script is because this line is pausing the script and waiting for some input from you.<br /><br />2) You should probably send $line instead of $message as the second parameter to $rs-&gt;reply(), since $line is the variable you read from the file ($message was read from STDIN, but that line's gotta go).<br /><br />3) I forgot to mention, when you read lines from a text file or from STDIN, the end-of-line character(s) stay in the string. For example, a text file that says:<br /><br />[code]line 1<br />line 2<br />line 3[/code]<br /><br />Actually looks like this to the computer:<br /><br />[code]line 1\nline 2\nline 3\n[/code]<br /><br />(where the \n is the end-of-line character). In Perl when you read a line from the file, it would get for example, &quot;line 1\n&quot; with the EOL character.. you have to use chomp() to remove this (I used chomp() in that &lt;STDIN&gt; line as a shortcut).<br /><br />So your code should instead look more like this:<br /><br />[code]#!/usr/bin/perl -w<br />use RiveScript;<br /><br />my $rs = new RiveScript();<br />$rs-&gt;loadDirectory(&quot;./cervo&quot;);<br />$rs-&gt;sortReplies();<br /><br />open (my $voice, &quot;&lt;&quot;, &quot;/media/test&quot;);<br />while (my $line = &lt;$voice&gt;) &#123;<br /> &nbsp; chomp($line);<br /> &nbsp; print &quot;You&gt; $line\n&quot;;<br /><br /> &nbsp; my $reply = $rs-&gt;reply(&quot;user&quot;, $line);<br /> &nbsp; print &quot;Bot&gt; $reply\n&quot;;<br /> &nbsp; system(&quot;/usr/local/bin/sayit&quot;, $reply);<br />&#125; [/code]||||
