Script Editor – Combining the audio files

 

Combining the recordings has taken a little time to figure out.  But now I can merge them, and convert them to MP3.  Here is a screenshot of the page that produces the script in Spanish (just filter the Spanish lines) and puts links to the combined .Wav and .Mp3

 

 

image

To get this to work, I had to call two command line functions “sox.exe” to combine the wavs  (sox.sourceforge.net/)   together.  and “Lame.exe” to convert it to an MP3 (lame.sourceforge.net/index.php).

I had some trouble with LAME.  It did not like the .Wav in the default format that the Java Sonics ListenUp Java Applet records in, i.e. ADPCM.  It kept saying “unsupported format”.  But it did work with “u8”.  There is some type of distortion in the background though..

 

I should also point out that I found a really neat looking PHP class to work with wav files called wav edit.  I could not get it to work with the wavs I recorded though.  Here are some screenshots of the sample page and a link to give you and idea of what I’m talking about.

www.pviet.com/wavedit/

Sample page using my recordings:

 

image

 

 

using the recordings provided in the .zip

image

Script Editor – Adding lines and recording audio

Making some good progress today!!!  I have added the ability to create lines for the script, delete lines, move lines up and down, record audio, and the like.  Here are some screenshots: 

 

image

The JavaSonic ListenUP applet records things as a .wav.  I will need to join these together.  I found a function to do this:

 

www.splitbrain.org/blog/2006-11/15-joining_wavs_with_php

 

function joinwavs($wavs){
    $fields = join('/',array( 'H8ChunkID', 'VChunkSize', 'H8Format',
                              'H8Subchunk1ID', 'VSubchunk1Size',
                              'vAudioFormat', 'vNumChannels', 'VSampleRate',
                              'VByteRate', 'vBlockAlign', 'vBitsPerSample' ));
    $data = '';
    foreach($wavs as $wav){
        $fp     = fopen($wav,'rb');
        $header = fread($fp,36);
        $info   = unpack($fields,$header);
        // read optional extra stuff
        if($info['Subchunk1Size'] > 16){
            $header .= fread($fp,($info['Subchunk1Size']-16));
        }
        // read SubChunk2ID
        $header .= fread($fp,4);
        // read Subchunk2Size
        $size  = unpack('vsize',fread($fp, 4));
        $size  = $size['size'];
        // read data
        $data .= fread($fp,$size);
    }
    return $header.pack('V',strlen($data)).$data;
}

It streams it out to the client.. .I will want to save it to the filesystem and use LAME to convert it into MP3.

This is the next step…  After I am able to join them and convert them, then I will be at the point that I will have all the technical know how to do what I’m trying to do.  Then it will be a matter of cleaning up the design, (in fact redesign (ok.. ok… not much of  design now… just to design it)), make it look pretty, test test test… (I’m going to try to put the 15 scripts we have done so far for HabloHindu in there and see how that works), I need to add some authentication/security to it, then I will upload it and have Sara give it a try to see what she thinks…

Script Editor – First Attempt

I do not know PHP, but it seems very similar to lots of other web scripting languages I have used (NeoScript, ASP, etc.).  With the help of a book, the web, and my past experience, I was able to put the following together in a few hours:

List of scripts page:

 

image

“Add script” takes you to this page:

image

The date is pre-populated as the “max date” + 1 day.

If you clicked on a script title on the first page, then you would be taken to a view that let you change the script:

image

The code behind all this is not good.  But I just wanted to get through the basics…  Let me put it here for reference:

I called the list page add.php (long story…)

I called the add/edit page addScript.php.

add.php code:

<?php
mysql_connect(“localhost”, “nobody”, “not_telling”);
mysql_select_db(“scriptEditor_dev”);

$query = “select id, date, title, notes from script order by date;”;
$results = mysql_query($query)
?>

<table>
<tr>
  <th>id</th>
  <th>date</th>
  <th>title</th>
  <th>notes</th>
</tr>

<?php
while ($row = mysql_fetch_array($results))
{
    echo ‘<tr><td>’;
    echo $row[‘id’];
    echo ‘</td><td>’;
    echo $row[‘date’];
    echo ‘</td><td><a href=”addScript.php?id=’ . $row[‘id’] . ‘”>’;
    echo $row[‘title’];
    echo ‘</a></td><td>’;
    echo $row[‘notes’];
    echo ‘</td></tr>’;
}

?> 
</table>

<a href=”addScript.php”>add script</a>

—–

<?php
mysql_connect(“localhost”, “nobody”, “not_telling”);

mysql_select_db(“scriptEditor_dev”);

$id = “”;
$date = “”;
$title = “”;
$englishWord = “”;
$spanishWord = “”;
$hindiWord = “”;
$notes = “”;

if($_POST[“date”] != “”){
    if($_POST[“id”] != “”){
        $query = “update script set ”
             . “date = ‘” . $_POST[‘date’] . “‘, ”
             . “Title = ‘” . $_POST[‘title’] . “‘, “
             . “EnglishWord = ‘” . $_POST[‘englishWord’] . “‘, “
             . “SpanishWord = ‘” . $_POST[‘spanishWord’] . “‘, “
             . “HindiWord = ‘” . $_POST[‘hindiWord’] . “‘, “
             . “Notes = ‘” . $_POST[‘notes’] . “‘ “
             . ” where id=” . $_POST[“id”] . “;”;
    }else
    {
    $query = “insert into script (date, Title, EnglishWord, SpanishWord, HindiWord, Notes) values (‘”
             . $_POST[‘date’] . “‘, ‘”
             . $_POST[‘title’] . “‘, ‘”
             . $_POST[‘englishWord’] . “‘, ‘”
             . $_POST[‘spanishWord’] . “‘, ‘”
             . $_POST[‘hindiWord’] . “‘, ‘”
             . $_POST[‘notes’] . “‘);”;
    }
    //echo $query;
    mysql_query($query);
    header(‘Location: add.php’);
} elseif($_GET[‘id’] != “”)
{
    $query = “select date, Title, EnglishWord, SpanishWord, HindiWord, Notes from script where id =” . $_GET[“id”];
    $results = mysql_query($query);
    $row = mysql_fetch_array($results);
    $id = $_GET[‘id’];
    $date = $row[‘date’];
    $title = $row[‘Title’];
    $englishWord = $row[‘EnglishWord’];
    $spanishWord = $row[‘SpanishWord’];
    $hindiWord = $row[‘HindiWord’];
    $notes = $row[‘Notes’];
}else{
$query = “select adddate( max(date), interval 1 day) as mx_dt from script order by date;”;
$results = mysql_query($query);
$row = mysql_fetch_array($results);
$date = $row[“mx_dt”];
}
?>
<form method=”post”>
<input type=”hidden” name=”id” value=”<?php echo $id ?>”>
<table>
<tr><th>date</th><td><input type=”text” name=”date” value=”<?php
echo $date;
?>”></td></tr>
<tr><th>title</th><td><input type=”text” name=”title” value=”<?php echo $title ?>”></td></tr>
<tr><th>English Word</th><td><input type=”text” name=”englishWord” value=”<?php echo $englishWord ?>”></td></tr>
<tr><th>Spanish Word</th><td><input type=”text” name=”spanishWord” value=”<?php echo $spanishWord ?>”></td></tr>
<tr><th>Hindi Word</th><td><input type=”text” name=”hindiWord” value=”<?php echo $hindiWord ?>”></td></tr>
<tr><th>Notes</th><td><input type=”text” name=”notes” value=”<?php echo $notes ?>”></td></tr>
<tr><th></th><td><input type=”submit”></td></tr>
</table>
</form>

 

—–

 

Before moving on, here are the changes I am going to make:

1) Need to have an include file to contain the database connection information

2)  Need to add Model and data access…  Do not need to have SQL intermixed in my HTML page.

3) Need a function that can easily switch from edit to view…

Script Editor – Setting up the dev environment

In order to do programming for LAMP, you have to setup apache webserver, install PHP, setup MySql, and probably a number of other things.  Or you could take the easy route and get from ApacheFriends.

 

For IDE, I am using the Eclipse version of PHP Development Tools.

Script Editor – The Game Plan

If you read the last post, you understand the problem that I am trying to solve.  I need a way to automate the creation of a script for HabloHindu.com.  It should keep track of the word of the day in Spanish/English/Hindi.  Allow for people to know what they need to do, e.g. review a script, answer a question, translate something, record something, etc.  It needs to mix together the various recordings, and post the final results to WordPress. 

In this post, I hope to outline my current approach.  I plan to keep a running journal of my progress, which will be helpful to me later on to review, and will hopefully be helpful for you as well.

Selection of tools:  I am going to write this targeting a LAMP stack (linux, apache, MySql, Php).  My development environment is a windows vista laptop, but my server is a linux server running at DreamHost.  Other than that, my development and production environments are the same.

Let me give you an idea of the flow:

1) Log in to the application

2) See list of scripts with status (Just started; Need review; Need recording; Ready; Published)  Each script will have a notes section displayed on the status screen that will allow for Sara and I to communicate with each other.

3) On the list of scripts page, there will be a “new script” button.  This will allow for you to create a new script.  Let us walk through the new script process

4) Clicking on the “new script” button will take you to the “script edit” page with some fields filled in with defaults, and others that will have to be filled in.

Publish Date: <default to the next day after the last script in the system>

Word of the Day in English:

word of the day in Spanish:

Word of the day in Hindi (devanagari):

Word of the day in Hindi (English Transliteration):

Word of the day in Hindi (Spanish Transliteration):

Notes:

Status: <default to “Just started”>

Then there will be a button to “save”

5) After clicking “save”, you will see the script “header” information in read only mode.  And there will be a button to “add a line”.  When you click this, you will be taken to a page that looks exactly like this one, but will have a new “script line” at the bottom, with the following fields:

Speaker (drop down with a list of speakers) (currently: Sara, Meena, Nariandas)

Spanish:

English:

Notes:

6) After clicking the “save” button, you will be taken to the read-only mode.  And you will have some basic functions like, move line up, move line down, insert line here, delete line, go to script list page, edit script header and the like.

7) The above takes care of the script editing.  Now, to the recording.  to each script line in the recording, I will add  a little Java Applet (Like Java Sonics ListenUp voice recording Applet) or a flash based record like Evoca)

8) Then a good next step will be to have a page by speaker with all the lines.  That way I can sit with Meena or Nariandas and just record all the lines at one time.

9) Mix the audio together here is a discussion about this: ask.metafilter.com/21381/Merge-mp3s-with-PHP

10) post the information to HabloHindi wordpress using the webservices interface or directly into the database…

so, it is a very basic design..  I’ll keep you posted on my progress…

Script Editor – The Problem

I am working with Sara, a friend from Venezuela to create a Spanish site to teach Hindi.  It launches tomorrow with a Hindi word of the day with an audio cast and text for Spanish speakers at HabloHindu.com.  It has required a lot of work to create some relatively short programs.  And most of that work had to do with things that could be automated.

Let me explain our process so far:

1) Create a script.  You can see the list of scripts we have created so far:

www.ispeakhindi.com/wiki/index.php?title=En_Espa%C3%B1ol

You have to create a link to each script.  Put the text in English/Hindi (if I am working on it) and in Spanish/English/Hindi if Sara is working on it.  Then if we have questions or need help about the script, we add a note.  The other person can look at recent changes in the wiki to see this.  It can take a while to create a script.  Each of these scripts probably represent at least 2 hours of work.

2) Record the Spanish part.  After the script is ready, Sara will record the Spanish part.  You can see examples of this on this page: www.ispeakhindi.com/wiki/index.php?title=Make_organised_our_work_together_for_august

Listen to some of the files under “recording by Sara”.

3) Then we have to record the Hindi part.  To do this, I need a list of the Hindi words/phrases and who says them (Nariandas or Meena).  To create that list, I scan through the scripts looking for Hindi.  Then I created another wiki page to track this: www.ispeakhindi.com/wiki/index.php?title=Recordings_that_Meena_and_Nariandas_need_to_make

Then I sit with Meena and Nariandas to record the Hindi.  Recording each of these files took some time in Audacity.  I had to give each file a name that reflect to the word.  I had to click “OK” on the MP3 properties dialog box.  All that time adds up.  It probably takes at least a minute for each of the phrases/words…

4) Then I have to mix the Spanish and Hindi together.  I listen to the Spanish in Audacity and read along with the script.  Sara leaves pauses for me to know where the Hindi needs to go.  Then I find the right Hindi file, insert it in.  I try to match the volume between the two recordings, but have not been able to do a good job at this.   Editing each of the recordings probably takes 15 minutes.

5) Then a post needs to be created in WordPress on HabloHindu.com.  This means copying the script from the wiki to WordPress and removing all the English.  Also, have to upload the final recording and set it up in the PodPress.  This probably takes about 5 minutes a recording.  And set the go live date to the appropriate day.

Here are the totals for one script:

2 hours script creation/editing

?? Record by sara

15 minutes to record the Hindi

15 minutes to mix together

5 minutes to post on HabloHindu

Therefore, each 30 second – 1minute HabloHindu episode is currently taking around 2 and a half hours to create.  I think it might be possible to get that down to 30 minutes or less using an automated solution.  I’ll talk about that in the next post.

Vegan Chocolate Frosting

(from vegweb.com/index.php?topic=6441.0)

Vegan Chocolate Frosting

Ingredients (use vegan versions):

    1 cup margarine
    4 cups powdered sugar (make your own if you want – blend sugar and cornstarch)
    2 tablespoon vanilla
    4 tablespoon soy milk
    1/2 cup cocoa powder (or more)
    dash of salt

Directions:

Margin should be at room temperature when being placed in bowl. Blend until mushy, and then add vegan powdered sugar, salt, vanilla, chocolate and soymilk. You can add in more soymilk to make it a bit smoother but not too much. Spread on cake and enjoy.

Vegan Birthday Cake

I am allways looking for this recipe.  So, thought I would put it on my blog:

allrecipes.com/Recipe/Vegan-Chocolate-Cake/Detail.aspx

 

INGREDIENTS (Nutrition)

  • 1 1/2 cups all-purpose flour
  • 1 cup white sugar
  • 1/4 cup cocoa powder
  • 1 teaspoon baking soda
  • 1/2 teaspoon salt
  • 1/3 cup vegetable oil
  • 1 teaspoon vanilla extract
  • 1 teaspoon distilled white vinegar
  • 1 cup water

DIRECTIONS

  1. Preheat oven to 350 degrees F (175 degrees C). Lightly grease one 9×5 inch loaf pan.
  2. Sift together the flour, sugar, cocoa, baking soda and salt. Add the oil, vanilla, vinegar and water. Mix together until smooth.
  3. Pour into prepared pan and bake at 350 degrees F (175 degrees C) for 45 minutes. Remove from oven and allow to cool.

Sucker!

Yesterday I was visiting a friend two streets over from where I live.  After we got past the normal, “how are you doing?”, “What’s been going on?”, “Can I get you something to eat/drink?” phase, my neighbor says, “Did you send a guy over here last week?”

To which I responded, “No, of course not.”  Then I thought back to last week.

Last week I was pulling in the drive way and there was a guy walking away from my house.  When he saw me pull up he walked back and address me, “Good afternoon”.  He was going around selling those coupon books.  I really didn’t want one.  But I thought why not.  So, I got one.  Then he said that his boss was wanting to keep track of people he sold the book to.  And had a form for name & address.

Now putting these two events together, I can only assume that this guy then went to all my neighbors, and said that I had sent him there…