Rivescript not working as expected- solved

  • 19 Replies
  • 12004 Views
*

brty21

  • Roomba
  • *
  • 10
Rivescript not working as expected- solved
« on: March 18, 2017, 04:20:32 am »
Does anyone use rivescript ? I have it on a local server and it all loads in a browser and working (well nearly)
The problem I have is adding new stuff
I added the following how questions...
---------------------------------------------------------------------------------
+  how do you * the *
-  Well, I like to <star1> the <star2>. How? I cant really say

+  how does the * work
-  I think the <star> works with the help of magic squirrels

+  how does *
-  interesting question. Are you teasing me?
+  no
-  Ok then. I can be a bit dipsy sometimes.

+  how does it *
-  Maybe that is beyond the scope of this conversation

+  how * will that be
-  That depends on how <star> it is to begin with

+  how will I *
-  trust in your instincts
-  there will be no way of knowing for sure

+  how do you like *
-  I like <star> a lot actually
-----------------------------------------------------------------------------
Regardless of things making sense, most of it works. BUT, the " how will I * " results in rivescript not finding the answer
Does anyone know where I am going wrong in the above?
« Last Edit: March 27, 2017, 11:57:37 am by brty21 »

*

brty21

  • Roomba
  • *
  • 10
Re: Rivescript not working as expected
« Reply #1 on: March 18, 2017, 04:20:57 am »
=

*

Freddy

  • Administrator
  • **********************
  • Colossus
  • *
  • 6855
  • Mostly Harmless
Re: Rivescript not working as expected
« Reply #2 on: March 18, 2017, 05:03:40 am »
We have a moderator that knows Rivescript, so hopefully they will be able to help. I've only seen it in passing so can't really help.

The thing I notice about the problem line is that it's the only one that uses two consecutive hyphens - maybe there is a syntax problem there. I'm guessing you want it to pick a random line out of those two, so maybe there is some required structure. I seem to remember being told that it uses the pipe... |

Just an uneducated guess.

*

brty21

  • Roomba
  • *
  • 10
Re: Rivescript not working as expected
« Reply #3 on: March 18, 2017, 12:18:13 pm »
Thanks for looking Freddy. I solved it by changing

how will I *
to
how will i *

I'm very interested in your unity/elfscript project. I'm just using animated gif's of daz animations but would love to use a 3d figure and will be trying it when i have time.

*

Art

  • At the end of the game, the King and Pawn go into the same box.
  • Trusty Member
  • **********************
  • Colossus
  • *
  • 5865
Re: Rivescript not working as expected
« Reply #4 on: March 18, 2017, 01:56:32 pm »
Right on! The Capital I catches me especially if I'm typing in a hurry.

Capitals are not allowed in the Trigger input from the user. They are handled by the program.

One can have two, three or a bunch of the - 's (hyphens) as they are the various responses RiveScript can use when selecting an answer.

The Pipes are useful in the Trigger statements from the user such as + Do you have a (vehicle | car | automobile)

No ?'s / punctuation is allowed at the end of Trigger / possible User input sentences (denoted with a +)

Glad you found the culprit!

« Last Edit: March 21, 2017, 04:03:58 pm by Art »
In the world of AI, it's the thought that counts!

*

brty21

  • Roomba
  • *
  • 10
Re: Rivescript not working as expected
« Reply #5 on: March 18, 2017, 05:36:06 pm »
Hi Art,

Yes, i didn't notice about the capital letter thing until just after posting the question..

I'm using rivescript-js-1.17.2 on localhost

I'm happy now that calling TTS and avatars is possible with rivescript and javascript. I don't know how to program, but there are a lot of examples that help
I am building separate .rive files in an effort to make editing things faster. I don't know if they should all be merged later or not? The standard Eliza based rive is still in there.

main things I want to do next are...

Build more brain .rive files
Use Mary tts instead of windows (no idea how to call this with javascript yet)
Do a lot more gif animations -as at the moment its set to talking or not talking (linked to the text to speech)

hmm this may take some time ;-)


*

Freddy

  • Administrator
  • **********************
  • Colossus
  • *
  • 6855
  • Mostly Harmless
Re: Rivescript not working as expected
« Reply #6 on: March 18, 2017, 06:45:41 pm »
Glad you got it sorted.

I'm very interested in your unity/elfscript project. I'm just using animated gif's of daz animations but would love to use a 3d figure and will be trying it when i have time.

Elfscript is on hold at the moment as I have so much on. But it's usable now, I'll look into opening up the private board where Art and myself had been discussing it. That's going to be a few weeks away though when I have more time to support it hopefully.

There is a technical difficulty in using my avatars in a browser that I have not got around yet and that involves multi threading. The short version is that it will not work just yet. I need to explore other ways of doing things, if indeed there are any - or for Unity to come up with something.

Quote
The Pipes are useful in the Trigger statements from the user such as + Do you have a (vehicle | car | automobile)

Interesting, that's the same method I came up with for variations of input. I use double pipes for random sentences (and also different input) and singles for variable phrases...

For sentences :

Code
i: hello||howdy||Greetings||good day;
o: Hello there !||Good to meet you !;

For phrases :

Code
i: I have a (bike|car|lorry);
o: Oh, that's a means of transport.||How long have you had one ?;

My interpreter is not fussy about capitals because all input is normalised.

*

Art

  • At the end of the game, the King and Pawn go into the same box.
  • Trusty Member
  • **********************
  • Colossus
  • *
  • 5865
Re: Rivescript not working as expected
« Reply #7 on: March 19, 2017, 04:41:36 pm »
Yes I recall that, Freddy.

It would be nice if a 3D animated avatar could be realized via Unity, Daz3d, Poser, Blender or some other "fairly realistic" method. Most users and fans of chatbots agree that an avatar provides a visual connection to an otherwise talking computer program.

Most also know of those 3D avatars from Haptek that UltraHal (Zabaware) and other programs used in the past. It's a shame that the People Putty developers didn't keep up with Windows. I'm sure there are other opportunities available...we just have to find them.
In the world of AI, it's the thought that counts!

*

Freddy

  • Administrator
  • **********************
  • Colossus
  • *
  • 6855
  • Mostly Harmless
Re: Rivescript not working as expected
« Reply #8 on: March 19, 2017, 07:14:52 pm »
Well there's no difficulty with the avatars running on the desktop as you've seen from my videos - even in virtual reality it's a goer. I'd like to crack browser support though some time.

*

brty21

  • Roomba
  • *
  • 10
Re: Rivescript not working as expected
« Reply #9 on: March 20, 2017, 01:01:40 am »
A blender addon or Daz studio plugin would be amazing! It's a shame haptek faded too, i did try to get it working on windows 10 but no
So far, yours seems the best solution for using 3d figures Freddy -but I'd have to get my head around Unity. It kind of bewilders me like blender did in earlier versions

*

Freddy

  • Administrator
  • **********************
  • Colossus
  • *
  • 6855
  • Mostly Harmless
Re: Rivescript not working as expected
« Reply #10 on: March 20, 2017, 01:59:57 am »
Unity is not so bad, there are a lot of tutorials and in their forums are some of the most helpful people you can find.

I wrote one for getting the figures into Unity here :

http://widdershinsstudio.uk/exporting-daz3d-models-or-characters-into-unity-for-animation/

Learning the interface in Unity is one of the first things to crack. You could opt to use javascript as your language of choice - personally I prefer c# in Unity despite doing a lot of js programming in web work.

You mentioned this :

Quote
Use Mary tts instead of windows (no idea how to call this with javascript yet)

You'll need a server to set Mary up on, I'm not sure if you can do it on a regular hosting site - I've only set it up on a VPS. But if you go that route I can probably help - calling the Mary server through javascript and using HTML5 audio should be relatively straight forward. Lipsync is where it gets complicated.

Apologies if I am telling things you already know :)

*

brty21

  • Roomba
  • *
  • 10
Re: Rivescript not working as expected
« Reply #11 on: March 21, 2017, 09:42:05 pm »
I have read through your article with interest while on my quest last week. I will get back to trying it soon.

Using marytts would be perfect as if i later upload a rivescript bot  that's using microsoft speechsynth it may sound very strange on some computers using the older voices. (i use windows 10)
I am using localhost and have put mary on it but no idea how to get rivescript to use it. There is an example web page in the mary folder that i can browse to but it just outputs a wav file to save.
Well there's no rush as its going take quite a while to get my rivebot talking without falling back to the * trigger to much

Lip sync is way beyond me atm as I can only get javascript to load a talking gif and an idle gif right now. still at least an avatar of sorts.

...This is all pushing me to actually try to learn javascript- well, you never know!

I am enjoying rive-script though - even if it doesn't really allow for much learning through conversations like some bots




*

Freddy

  • Administrator
  • **********************
  • Colossus
  • *
  • 6855
  • Mostly Harmless
Re: Rivescript not working as expected
« Reply #12 on: March 23, 2017, 01:27:05 am »
Here's a short couple of scripts that I came up with which use PHP and javascript to interface with MaryTTS.

Browsers/JS don't like cross site scripting. There's ways to get around it, but I find them complicated and it's easily solved with a relay for testing purposes. You can get into all that other gubbins later if you want.

Take these two scripts and put them in some directory that is useful to you. The HTML/JS script calls the PHP. The PHP calls Mary. The PHP then sends what it got from Mary back to the client or browser. The client then plays it.

The main reason why you get the cross site problem is that Mary uses a different port compared to normal, ie port 80 in most cases.



Here's the HTML/JS :

Code
<html>

<title>Demo Play TTS</title>

<head>

</head>

<script>

// It's a pain using JS for cross site so just use a simple PHP relay to start with.
var relay = "gettts.php";

// The words to render.
var tts = "Just a simple Demo. Refresh page if you change the words in the script.";

// The URL for the relay with the words added on.
var url = relay + "?words=" + tts;

// Set up an audio player and get the audio from the relay URL.
var audio = new Audio(url);

// Play the audio which would have been made by Mary.
audio.play();

</script>

<body>

Just a simple Demo. Refresh page if you change the words in the script.

</body>

</html>

And the PHP...

Code
<?php

// Your server or host.
$host = "http://localhost";

// A voice you have installed with Mary.
$voice = "cmu-slt-hsmm";

// Get the words sent from the JS - best to do some sanitising here later.
$words = $_GET['words'];

// URL to the Mary port and various settings.
$url = $host  . ":59125/process?INPUT_TEXT=" . $words . ".&INPUT_TYPE=TEXT&OUTPUT_TYPE=AUDIO&LOCALE=en_US&AUDIO=WAVE_FILE&VOICE=" . $voice;

// Mary doesn't like spaces.
$url = str_replace(" ", "+", $url);

// Get the WAV file from Mary.
$wav = file_get_contents($url);

// Set a header for the client.
header('Content-Type: audio/wav');

// Echo the audio data.
echo $wav;

// End.
die();

Have a play with that. Save the PHP as 'gettts.php' and the HTML whatever you see fit. Change the JS variable 'tts' to whatever you like. Just hit the HTML page in your browser to see what it does.

Hopefully it will work, it did for me. You may have to change the voice setting if you don't have that one, but I think that is the default voice when installing.

Note that PHP is server side - so you need to browse to the HTML via your local host. Just double clicking on the HTML file will not work.
« Last Edit: March 23, 2017, 12:13:05 pm by Freddy »

*

8pla.net

  • Trusty Member
  • ***********
  • Eve
  • *
  • 1302
  • TV News. Pub. UAL (PhD). Robitron Mod. LPC Judge.
    • 8pla.net
Re: Rivescript not working as expected
« Reply #13 on: March 23, 2017, 03:23:37 am »
Reporting success installing MaryTTS on Ubuntu using these directions...

Reference: http://askubuntu.com/questions/709241/how-to-install-marytts-on-ubuntu

Please see attachment (for discussion purposes only). 

The default demo site address runs on localhost port 59125 . 

NOTE:  This seems to be version 5.1.2 (not the latest version apparently).
As this was just an experiment, no recommendations are intended here.

My Very Enormous Monster Just Stopped Using Nine

*

8pla.net

  • Trusty Member
  • ***********
  • Eve
  • *
  • 1302
  • TV News. Pub. UAL (PhD). Robitron Mod. LPC Judge.
    • 8pla.net
Re: Rivescript not working as expected
« Reply #14 on: March 23, 2017, 05:51:17 am »
Wow!  Mary generates Parts of Speech in XML ...

Code
<?xml version="1.0" encoding="UTF-8"?>
<maryxml xmlns="http://mary.dfki.de/2002/MaryXML" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="0.5" xml:lang="en-US">
<p>
<voice name="cmu-slt-hsmm">
<s>
<t pos="VB">Welcome</t>
<t pos="TO">to</t>
<t pos="DT">the</t>
<t pos="NN">world</t>
<t pos="IN">of</t>
<t pos="NN">speech</t>
<t pos="NN">synthesis</t>
<t pos=".">!</t>
</s>
</voice>
</p>
</maryxml>

And phonemes as well in XML ...

Code
<?xml version="1.0" encoding="UTF-8"?>
<maryxml xmlns="http://mary.dfki.de/2002/MaryXML" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="0.5" xml:lang="en-US">
<p>
<voice name="cmu-slt-hsmm">
<s>
<t g2p_method="lexicon" ph="' w E l - k @ m" pos="VB">Welcome</t>
<t g2p_method="lexicon" ph="' t u" pos="TO">to</t>
<t g2p_method="lexicon" ph="D @" pos="DT">the</t>
<t g2p_method="lexicon" ph="' w r= l d" pos="NN">world</t>
<t g2p_method="lexicon" ph="' V v" pos="IN">of</t>
<t g2p_method="lexicon" ph="s - ' p i tS" pos="NN">speech</t>
<t g2p_method="lexicon" ph="' s I n - T @ - s @ s" pos="NN">synthesis</t>
<t pos=".">!</t>
</s>
</voice>
</p>
</maryxml>
My Very Enormous Monster Just Stopped Using Nine

 


OpenAI Speech-to-Speech Reasoning Demo
by MikeB (AI News )
March 31, 2024, 01:00:53 pm
Say good-bye to GPUs...
by MikeB (AI News )
March 23, 2024, 09:23:52 am
Google Bard report
by ivan.moony (AI News )
February 14, 2024, 04:42:23 pm
Elon Musk's xAI Grok Chatbot
by MikeB (AI News )
December 11, 2023, 06:26:33 am
Nvidia Hype
by 8pla.net (AI News )
December 06, 2023, 10:04:52 pm
How will the OpenAI CEO being Fired affect ChatGPT?
by 8pla.net (AI News )
December 06, 2023, 09:54:25 pm
Independent AI sovereignties
by WriterOfMinds (AI News )
November 08, 2023, 04:51:21 am
LLaMA2 Meta's chatbot released
by 8pla.net (AI News )
October 18, 2023, 11:41:21 pm

Users Online

168 Guests, 0 Users

Most Online Today: 291. Most Online Ever: 2369 (November 21, 2020, 04:08:13 pm)

Articles