Rivescript not working as expected- solved

  • 19 Replies
  • 1660 Views
*

Freddy

  • Administrator
  • **********************
  • Colossus
  • *
  • 6114
  • Mostly Harmless
Re: Rivescript not working as expected
« Reply #15 on: March 23, 2017, 11:56:49 am »
Yup - Mary is really very good. You can also change pronunciation too.

Mary will also provide phoneme timings, which is what you need for lip sync.

*

brty21

  • Roomba
  • *
  • 10
Re: Rivescript not working as expected
« Reply #16 on: March 23, 2017, 11:32:27 pm »
 :) Thanks I will definitely try to get mary going with that info -after the weekend (i got five children!)

Then, on the front end side of things, all I want to do is figure out how to get an extra avatar pic to show temporarily before it goes back to idle.   ie idle-talking-action-idle or idle-action-talking-idle
....If you see what i mean
- I will post my code tampering attempts another time though

*

brty21

  • Roomba
  • *
  • 10
Re: Rivescript not working as expected
« Reply #17 on: March 27, 2017, 11:34:23 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: [Select]
<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: [Select]
<?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.
:)

Working well, Thanks a lot! At least I have some idea now

Since RiveScript is working as expected now. I will post new topics to new threads

*

8pla.net

  • Trusty Member
  • *********
  • Terminator
  • *
  • 800
    • 8pla.net
Re: Rivescript not working as expected- solved
« Reply #18 on: March 28, 2017, 10:32:21 pm »
Does MaryTTS require Dedicated Server Hosting?

It seems to me it may, but I'm not really sure, since
I've only just tested it on my localhost.
My Very Enormous Monster Just Stopped Using Nine

*

Freddy

  • Administrator
  • **********************
  • Colossus
  • *
  • 6114
  • Mostly Harmless
Re: Rivescript not working as expected- solved
« Reply #19 on: March 28, 2017, 11:04:18 pm »
I don't think a regular shared server is possible unless they bundle it. You'd need shell access to install it. I use a VPS.

 


Dreaming
by Freddy (New Users Please Post Here)
September 21, 2017, 11:24:24 pm
AI safety
by korrelan (General AI Discussion)
September 21, 2017, 11:16:03 pm
Hello
by Freddy (New Users Please Post Here)
September 21, 2017, 10:46:16 pm
Grats to SquareBear
by korrelan (General Chatbots and Software)
September 21, 2017, 10:44:42 pm
Map of Computer Science
by keghn (General AI Discussion)
September 21, 2017, 07:25:21 pm
XKCD Comic : USB Cables
by Tyler (XKCD Comic)
September 21, 2017, 12:01:33 pm
outline from gadient mask
by yotamarker (General AI Discussion)
September 21, 2017, 11:32:35 am
the emergence of AI
by Memnon (Future of AI)
September 21, 2017, 10:37:19 am

Users Online

21 Guests, 2 Users
Users active in past 15 minutes:
keghn, Freddy
[Administrator]
[Trusty Member]

Most Online Today: 23. Most Online Ever: 208 (August 27, 2008, 09:36:30 am)

Articles