James T.
user 3821838
Louisville, KY
Post #: 172
I have a problem which might possibly lead to a LouPUG project.

My website at
poop.jetroy.we.bs

shows a series of PHP OOP examples. The highlighted code for
the website, index.html, is shown when "<" is clicked after
the url is loaded. I would like to add an audio description to
each example which would be triggered when an example is first
shown which is controlled by the javascript routine next. (The next function hides
the current example, increments the example pointer nx, and
shows the next example.) The next function would use .pause() and
.play() methods of the audio tag in the routines, paus and pla:
------------------------------------
function next() {
$(".example").eq(nx).hide();
paus(); // pause the audio player
nx++; // set pointer to the next example
$(".example").eq(nx).show();
pla(nx); // set up the audio player for file nx.ogg & play()
}
------------------------------------
This would be easy to code but a lot of work to record each
ogg file for each example. I would like to automate this
with a php program that would automatically create the files
during a presentation. I would have an authoring program similar
to index.html but with a next() function modified as follows:
------------------------------------
function next() {
$(".example").eq(nx).hide();
$.get("stop.php",{nx:nx}); // stop the recorder, save file nx.ogg to disk
nx++; // set pointer to the next example
$(".example").eq(nx).show();
$.get("rec.php",{nx:nx}); // start recording file nx.ogg
}
------------------------------------
Then on the server side (localhost) I would need 2 php files
------------------------------------
<?php //rec.php
$nx=$_GET['nx'];
record($nx); // turns on recording
?>

<?php //stop.php
$nx=$_GET['nx'];
stopnsave($nx); // stops recording and saves nx.ogg to disk
?>
------------------------------------
Everything is straightforward except for record() and stopnsave()
routines. How could they be coded?

}
James T.
user 3821838
Louisville, KY
Post #: 173
record() and stopnsave() could be coded using
sox

and
pskill()

I use xampp with windows vista for the localhost

Here's how it might be coded
---------------------------------


<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapi...­
<script>

function rec(){
$.get('rec.php',{nx:nx});
}
function kill(){
$.get('kill.php');
}
function play(){
$.get('play.php',{nx:nx});
}

function init() {
nx=3;
}
$(init);
</script>
</head>
<body>
<input type=button value=rec onclick="rec()">
<input type=button value=kill onclick="kill()">
<input type=button value=play onclick="play()">
</body>
</html>

<?php // rec.php
$nx=$_GET['nx'];
$cmd= '"c:\Program Files\sox\sox"';
$cmd .= " -d r$nx.ogg";
exec($cmd,$output,$ret);
?>

<?php //play.php
$nx=$_GET['nx'];
$cmd= '"c:\Program Files\sox\sox"';
$cmd .= " r$nx.ogg -d";
exec($cmd,$output,$ret);
?>

<?php //kill.php
exec('"c:\users\jim\downloads\pst­ools\pskill.exe" sox',$output,$ret);
?>
A former member
Post #: 1
To start, you could use one of the text-to-speech systems to read text. In that case, you'd play the pre-recorded .ogg if you have it, otherwise play the text-to-speech and invite people to record their own.

for record() you'll probably want to us a plugin like Flash or Silverlight - the trick is hooking up the remote computers mic to the application, which requires (among other things) permission from the user.

You may want to look into new Chrome API's, per this thread:
http://stackoverflow....­

James T.
user 3821838
Louisville, KY
Post #: 174
Thanks for the ideas.
Powered by mvnForum

Our Sponsors

  • Twilio

    APIs to Build Voice, VoIP and SMS Applications in the Cloud.

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy