<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.3" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>baküzen</title>
	<link>http://www.bakuzen.com</link>
	<description>because language is kind of important</description>
	<pubDate>Mon, 26 Apr 2010 19:06:13 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<item>
		<title>Moses Machine Translation</title>
		<link>http://www.bakuzen.com/?p=21</link>
		<comments>http://www.bakuzen.com/?p=21#comments</comments>
		<pubDate>Mon, 26 Apr 2010 18:56:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[NLP]]></category>

		<guid isPermaLink="false">http://www.bakuzen.com/?p=21</guid>
		<description><![CDATA[Moses is, as stated in the title, a machine translation system. That is, it&#8217;s an open-source system that one can download and use to translate, potentially, from any language to any language. That&#8217;s saying a lot, but there&#8217;s also a lot to do in order to get it working.The moses website is actually quite good, [...]]]></description>
			<content:encoded><![CDATA[<p>Moses is, as stated in the title, a machine translation system. That is, it&#8217;s an open-source system that one can download and use to translate, potentially, from any language to any language. That&#8217;s saying a lot, but there&#8217;s also a lot to do in order to get it working.The moses website is actually quite good, so before you try my instructions, follow the instructions there: <a href="http://www.statmt.org/moses/">http://www.statmt.org/moses/</a>But if you still don&#8217;t know what to do, I might be able to help. I&#8217;m going to step through getting the source code from an SVN repository via eclipse. You can get the source code via the website in a tar file, or you can just download the binary and run it without compiling, assuming your computer can handle the binary.&lt;br&gt;</p>
<p><strong>The Environment:</strong> One could potentially use any means of an editor and svn, but, like I said, I will use eclipse. Eclipse was written for Java, but I find it, though not perfect, pretty functional with other languages, including C/C++ in which moses was written. So, you will need a version of eclipse that has the plugin for C/C++. If you don&#8217;t know how to install it, just download a fresh eclipse with it already included here: <br /><a href="http://www.eclipse.org/cdt/downloads.php">http://www.eclipse.org/cdt/downloads.php</a><br />The other thing eclipse will need is a way to access svn. If you know of one, add it and make it work. Or, you can just install subclipse. Once you have your eclipse up and running with C/C++ capabilities, you can then go to help-&gt;install new software-&gt;add (type Subclipse for the name and the URL is: http://subclipse.tigris.org/svn/subclipse/tags/subclipse/1.6.5) then just continue on until it downloads and installs it. You&#8217;ll need to restart eclipse to have it take effect.Now, with C/C++ and SVN capabilities in eclipse, you are ready to get your hands dirty with moses.</p>
<p><strong>Getting Moses: </strong>In eclipse, go to File-&gt;new-&gt;other-&gt;svn-&gt;Checkout Projects from SVN. Create a new location and click next. Add the following:<br /> https://mosesdecoder.svn.sourceforge.new/svnroot/mosesdecoderand<br /> hit next. It will take a second to download the information. There are many branches that people are working on (I currently use the config-switching branch for several reasons) but if you just want to get in and play, you can just click on &#8220;trunk&#8221; and then click next. Lucky for you, the people who maintain moses include eclipse project files, so it is quite easy to get set up with eclipse. Anyway, you may want to change the project name, or you can leave it as trunk, it doesn&#8217;t really matter. Make sure it sets it up as a C/C++ project, or things won&#8217;t work out right later. It should be an empty C++ project. Then click finish. It&#8217;ll take a few minutes to download. Once it&#8217;s done, all is not quite ready.</p>
<p><strong>To Build: </strong>I went to Project and de-selected &#8220;Build Automatically&#8221; so I could tell it when to build (compile).There are a few things done be done before we can build. The makefiles that tell eclipse what to compile aren&#8217;t even there yet, we have to generate them. It&#8217;s quite easy, however. Open up a console and navigate to the directory where your moses code is. Then run:<br />./regenerate-makefiles.sh<br />This will take a few seconds and will generate your makefiles based on how your computer is configured. The only problem I ran into was this: possibly undefined macro: AC_PROG_LIBTOOL and I was able to fix it easily by installing libtool (in ubuntu: sudo apt-get install libtool -thanks to <a href="http://desk.stinkpot.org:8080/tricks/index.php/2007/05/fixing-error-undefined-macro-ac_prog_libtool/">this</a> site for the info) and then tried again and it worked fine. Now, this next step will separate those who just want to get their homework done from those who really want to use moses. You have your makefiles, but you also need to tell moses where to find a few things. If you already have the phrase tables, that is the data required to train the moses (statistical) machine translation engine, then you can simply type<br /> ./configure<br /> and let it run. If you want to make your own phrase tables, you&#8217;ll need to install either srilm or irstlm, or both. These are separate pieces of software that do a lot of the data building necessary to make moses work (why reinvent the wheel?). Moses is nice to be compatible with different kinds, so pick the one you want. Installation for both can be tricky (I found irstlm much easier), but doable. Perhaps in a later post I&#8217;ll explain how to install them. Until then, be happy with the little bit that moses comes with.Now, go back to eclipse, right-click on your project and hit refresh. Then, click on Project-Properties-&gt;C/C++ build. I deselected &#8220;Generate Makefiles automatically&#8221; and then click on &#8220;Workspace&#8221; and just then clicked on the root workspace folder and clicked okay (something like ${workspace_loc:/moses} showed in the Build directory field, where moses was the name of my project). This tells it to look in the moses folder for a Makefile, which we generated earlier.Now, press Ctrl+B and it will take a few minutes to build. It&#8217;s compiling C and C++ code using make, so eclipse really isn&#8217;t doing much but calling it for you. You can click on the Console tab in the lower part of eclipse to see what it&#8217;s doing at any given time</p>
<p><strong>To Run: </strong>When it&#8217;s done compiling, you can give it a test. Have fun. Just kidding, this is how you try it out: notice that you have a new list called &#8220;Binaries&#8221; in your project explorer. Expand that and you&#8217;ll see everything that was just compiled. Right-click on moses and run as local C/C++ Application. Then it will run, but not really. It just spits out the help information because you provided no command line arguments. The problem is, we don&#8217;t have any phrase tables for it to use to actually do translation. The moses website provides a sample one for testing to see if your compile worked. You can download it here:<br /> http://www.statmt.org/moses/download/sample-models.tgz<br />Now, by no means is this going to be what you use to actually do some translating. This is just a tiny sample that utilizes the moses MT system, but with a very small amount of training data and only select phrases to translate. Sorry, if you want data, you&#8217;ll have to make your own using some parallel corpora (something I hope to discuss later).Once you downloaded the sample_models.tgz file, you can open a command window and navigate to where it is and then run:tar -xzf sample-models.tgzand then go into the new sample-models directory that it just made. Then go into the phrase-tables directory. This is what you need. Open up the moses.ini file with an editor and change the line under [ttable-file] to the path where it currently is (in my case it was on my desktop under Desktop/sample-models/phrase-table/phrase-table) and then save it and close.We&#8217;re getting close. Now, you need to note where the moses.ini file is on your computer. Now, go to eclipse and then click on the green &#8220;Run&#8221; button (looks like a &#8220;Play&#8221; button&#8221;) make sure you hit the down-arrow part, and then click on Run Configurations. Under C/C++ Application, you&#8217;ll see moses (it&#8217;s there because you tried to run it before). Select it and go to the Arguments tab on the right. Then type in the following:-f {path to the moses.ini file}In my case it was something like:<br /> -f /home/something/Desktop/phrase-table/phrase-model/moses.ini<br />That&#8217;s all you need. Now, click &#8220;Apply&#8221; and then &#8220;Run&#8221; and then you&#8217;ll notice that it gets into motion. After a few seconds of running, it stops. At this point it is waiting for input. As this is a German-English sample phrase table, you can type:das ist ein kleines hauspress enter, and you should see the translation:this is a small houseThat&#8217;s it. You&#8217;ve successfully used moses to translate something. Congratulations. Now, to actually use moses in a big way is up to you. You can look into the boost library and work with multi-threading, or you can get the srilm and create your own phrase tables to feed to moses to do your own translations. There is a lot you can do, so check the website and see what&#8217;s available.</p>
<p>Appendix:You may need some other things, so I included them here without descriptive steps:</p>
<p>If you need tcl (srilm uses tcl):<br />.sudo apt-get install tcl tcllib tcl-dev<span class="Apple-style-span" style="font-family: 'Courier New', fixed; line-height: 13px; font-size: 11px; white-space: pre">TCL_INCLUDE, TCL_LIBRARY:  to whatever is needed to find the Tcl header files and library.  If Tcl is not available, set NO_TCL=X and leave the above variables empty.</span>
<pre>I had to copy the /usr/include/tcl8.5/ files to the srilm/misc/src dir</pre>
<pre></pre>
<pre>Also, exclude LanguageModelRandLM from compile!</pre>
<pre>I also put the srilm directory in the same as moses</pre>
<pre>

To get boost:</pre>
<p>http://cl.aist-nara.ac.jp/~eric-n/ubuntu-nlp/dists/jaunty/all//etc/ld.so.conf<br />boost:<code>sudo apt-get install libboost-date-time-dev libboost-date-time1.34.1 libboost-dev libboost-doc libboost-filesystem-dev libboost-filesystem1.34.1 libboost-graph-dev libboost-graph1.34.1 libboost-iostreams-dev libboost-iostreams1.34.1 libboost-program-options-dev libboost-program-options1.34.1 libboost-python-dev libboost-python1.34.1 libboost-regex-dev libboost-regex1.34.1 libboost-signals-dev libboost-signals1.34.1 libboost-test-dev libboost-test1.34.1 libboost-thread-dev libboost-thread1.34.1t</code>Use flag for compiler:-std=c++0xhttp://www.52nlp.com/moses-support-digest-moses-compilation-problem-on-fedora-11/in sphinx, i removed the randlm related flags to the compile<font face="Verdana">http://www.statmt.org/moses_steps.html</font>binarize: (make sure you use the .gz compressed version)processPhraseTableprocessLexicalTable</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bakuzen.com/?feed=rss2&amp;p=21</wfw:commentRss>
		</item>
		<item>
		<title>Mary Text to Speech</title>
		<link>http://www.bakuzen.com/?p=24</link>
		<comments>http://www.bakuzen.com/?p=24#comments</comments>
		<pubDate>Sat, 20 Feb 2010 15:27:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[NLP]]></category>

		<guid isPermaLink="false">http://www.bakuzen.com/?p=24</guid>
		<description><![CDATA[This is the second TTS system I&#8217;m posting about, not because I&#8217;m a TTS guy, but because this system was shown to me recently and I found it very well done and intuitive. The installation was so easy, that I&#8217;m not even going to post a step-by-step how-to. It comes with an installer and it [...]]]></description>
			<content:encoded><![CDATA[<p>This is the second TTS system I&#8217;m posting about, not because I&#8217;m a TTS guy, but because this system was shown to me recently and I found it very well done and intuitive. The installation was so easy, that I&#8217;m not even going to post a step-by-step how-to. It comes with an installer and it was written in Java so it should theoretically run on any platform. It does install several different executables that serve different purposes. It&#8217;s one of the projects of DFKI.</p>
<p><a href="http://mary.dfki.de/Download">http://mary.dfki.de/Download</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bakuzen.com/?feed=rss2&amp;p=24</wfw:commentRss>
		</item>
		<item>
		<title>Note</title>
		<link>http://www.bakuzen.com/?p=23</link>
		<comments>http://www.bakuzen.com/?p=23#comments</comments>
		<pubDate>Wed, 03 Feb 2010 18:45:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[NLP]]></category>

		<guid isPermaLink="false">http://www.bakuzen.com/?p=23</guid>
		<description><![CDATA[I&#8217;ve been getting a lot of comments, questions, and emails lately which is great, but this week is finals week for me in my master&#8217;s program. Therefore, I&#8217;m quite busy. I&#8217;ll have time to look at some of your comments in a week or two.
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been getting a lot of comments, questions, and emails lately which is great, but this week is finals week for me in my master&#8217;s program. Therefore, I&#8217;m quite busy. I&#8217;ll have time to look at some of your comments in a week or two.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bakuzen.com/?feed=rss2&amp;p=23</wfw:commentRss>
		</item>
		<item>
		<title>Python in Eclipse</title>
		<link>http://www.bakuzen.com/?p=20</link>
		<comments>http://www.bakuzen.com/?p=20#comments</comments>
		<pubDate>Fri, 16 Oct 2009 14:33:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[NLP]]></category>

		<guid isPermaLink="false">http://www.bakuzen.com/?p=20</guid>
		<description><![CDATA[There are many IDE&#8217;s available for any language, and Python has plenty to choose from. However, I&#8217;ve been programming in eclipse for Java, JSP/Servlets, Flex, and PHP for a while now and found it to be a solid IDE for at least those languages. I&#8217;ve found it to be quite good for Python, as well. [...]]]></description>
			<content:encoded><![CDATA[<p>There are many IDE&#8217;s available for any language, and Python has plenty to choose from. However, I&#8217;ve been programming in eclipse for Java, JSP/Servlets, Flex, and PHP for a while now and found it to be a solid IDE for at least those languages. I&#8217;ve found it to be quite good for Python, as well. If you already have something you like, then use that, of course. But for those of you computational linguists out there who are new to programming, but realize that you had better get with the computational side of things, including programming, this is where you can start.</p>
<p>First, download eclipse. You can either search in Google for &#8220;eclipse&#8221; and choose what you want, or you can click <a href="http://www.eclipse.org/downloads/">here</a>. I would recommend the eclipse for PHP developers. WHY?!? Because it has built-in web tools that might come in handy later if you really get into Python. So, look to the right of that option and choose your operating system. Clicking on that link should take you to the download site which will choose the closest download mirror for you. It&#8217;s about 138 mb to download.</p>
<p>Once you&#8217;ve downloaded it, unzip it. If all is well, you should be able to just run it. In windows, just double-click on the eclipse file inside your eclipse folder. In linux, you may have to open a terminal, navtigate to the folder, and type: ./eclipse</p>
<p>If that worked, you should see the eclipse Galileo splash screen. If it doesn&#8217;t load up, the problem could be anything. One problem might be that you downloaded the wrong one for your OS. The other problem might be your java version (eclipse uses java to run). I don&#8217;t know what version it was built with, but my eclipse works fine and I am using java 1.6.16. You can check your java version in Linux (or windows) by opening a terminal (command window) and typing: java -version<br />
If you type that and it says it can&#8217;t find java, then you don&#8217;t have it installed. So, install it. I won&#8217;t go over that here. If someone needs help with that, shoot me an email or leave a comment.</p>
<p>Now that your eclipse is open, you&#8217;re halfway there. Now, click on Help-&gt;Install New Software-&gt;Add. Type in &#8220;Python&#8221; in the name area and:<br />
http://pydev.org/updates/<br />
in the Location box and click OK. Now, you&#8217;ll see a drop-box to the left of the Add button. Click on that and find Python. Now, select the box next to &#8220;Pydev&#8221; and click Next. You may be taken to a place where you choose your mirror site (just choose any one), and you&#8217;ll need to read some licensing agreement. It will take a few minutes to download and it will ask if you want to restart eclipse when it is done. Yes, do restart eclipse.</p>
<p>Now, you have the ability to program in Python, but we&#8217;re not quite there yet. With eclipse open, click on File-&gt;New-&gt;Other. Scroll to Pydev, and expand the tree. Then choose Pydev Project and click Next. Type in the name of your project, anything will do. This will create a project folder for your code under the name you give. Notice that you can&#8217;t go on yet because you don&#8217;t have an interpreter. Click on the link to configure the interpreter. Now, click on Auto Config and then OK. You&#8217;ll see it spend some time looking through your computer for libraries. This means you won&#8217;t have to set your PYTHON_PATH variable, eclipse takes care of that (assuming you already installed the nltk).</p>
<p>When it&#8217;s done, click Next until it creates your project. You&#8217;ll see your project folder on the left. Now, expand your project folder and find the src folder. Right-click on that src folder, and select New-&gt;Pydev Module. Skip the package name and just put in a name for the file (eg, &#8220;test&#8221;). You&#8217;ll notice that it can fill in the template stuff for classes, etc., but you can just choose &#8220;none&#8221; and click OK. You should now see a new file.</p>
<p>Now let&#8217;s test it. First, type:<br />
print &#8220;Hello World&#8221;</p>
<p>And press the green play button on top. It will ask you how you want to run the file. Just scroll down and choose &#8220;Python Run&#8221; and you can set it to autosave the file when you click run so you don&#8217;t have to. Then click OK and it should say &#8220;Hello World&#8221; in the output below.</p>
<p>To see if the nltk works, type:<br />
import nltk<br />
nltk.probability.demo()</p>
<p>And run it again. It should show some probabilities in the output. Now you know that you can use the nltk. You can make as many files as you&#8217;d like, classes, access those classes easily with eclipse, etc. Happy programming. Feel free to ask questions of any kind.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bakuzen.com/?feed=rss2&amp;p=20</wfw:commentRss>
		</item>
		<item>
		<title>Python NLTK</title>
		<link>http://www.bakuzen.com/?p=18</link>
		<comments>http://www.bakuzen.com/?p=18#comments</comments>
		<pubDate>Tue, 06 Oct 2009 18:58:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[NLP]]></category>

		<guid isPermaLink="false">http://www.bakuzen.com/?p=18</guid>
		<description><![CDATA[The Python Natural Language Tool Kit has a lot of stuff to offer the DIY NLPer. It has a parser, POS tagger, lambda calculus, a chunker, a classifier, a tokenizer, even a WordNet interface, and much, much&#8230;..much more. It&#8217;s loaded and it&#8217;s not terribly difficult to use granted you know some python and at least [...]]]></description>
			<content:encoded><![CDATA[<p>The Python Natural Language Tool Kit has a lot of stuff to offer the DIY NLPer. It has a parser, POS tagger, lambda calculus, a chunker, a classifier, a tokenizer, even a WordNet interface, and much, much&#8230;..much more. It&#8217;s loaded and it&#8217;s not terribly difficult to use granted you know some python and at least a little bit about NLP.</p>
<p>First, you need python, the programming language in which that the tool kit is developed. Most distros of Linux will have python installed, but if you don&#8217;t have it you can go to www.python.org to get it and download it. If you don&#8217;t know how to do that, you&#8217;re hard-pressed to know how to use the tool kit anyway. So, spend some time learning python before you go crazy with the tool kit.</p>
<p>If you&#8217;re beyond that and you&#8217;re ready for the tool kit, you can go to www.nltk.org and download it. I tried a few different things and ended up just getting the zip file and downloading that, extracting it, then go into the directory with your console and type (as root or sudo):</p>
<p>python setup.py install</p>
<p>and you&#8217;re almost done. Run python by just typing:</p>
<p>python</p>
<p>and you&#8217;ll see the python command-line interpreter interface. Type:</p>
<p>include nltk<br />
nltk.probability.demo()</p>
<p>and you should see some output with some frequency distributions. There are more tutorials on how to use the tools individually on the www.nltk.org website.</p>
<p>One more thing. You might want to include some of the other optional packages, like numpy. Go back to the same download site as the nltk and grab what you want.  Open a console and get to where you downloaded the file,then run:</p>
<p>tar -xvf numpy[ver]</p>
<p>Then go into your numpy directory and run (again, as root/sudo):</p>
<p>python setup.py install</p>
<p>It will take some time because it is also compiling a lot of c code. Best of luck. I&#8217;ll post more as I learn more about it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bakuzen.com/?feed=rss2&amp;p=18</wfw:commentRss>
		</item>
		<item>
		<title>KWIC Dictionary</title>
		<link>http://www.bakuzen.com/?p=17</link>
		<comments>http://www.bakuzen.com/?p=17#comments</comments>
		<pubDate>Mon, 27 Apr 2009 20:43:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Corpora]]></category>

		<category><![CDATA[NLP]]></category>

		<guid isPermaLink="false">http://www.bakuzen.com/?p=17</guid>
		<description><![CDATA[There are many different versions of (Key-Word in Context&#8221; (KWIC) dictionaries out there, but for the most part they simply take a search string and lines up the search string in context as found in a given corpus. For example, I searched for &#8220;beef&#8221; in the Online BLC KWIC Concordance Dictionary and got the following [...]]]></description>
			<content:encoded><![CDATA[<p>There are many different versions of (Key-Word in Context&#8221; (KWIC) dictionaries out there, but for the most part they simply take a search string and lines up the search string in context as found in a given corpus. For example, I searched for &#8220;beef&#8221; in the Online BLC KWIC Concordance Dictionary and got the following results:</p>
<p><tt><tt></p>
<pre>     1  remises of our supplying less expensive beef and management know-how in running the
     2  At the time, I proposed to supply dried beef continuously, but you made a counter of
     3  antage of your supplying less expensive beef is considered, and we most reluctantly
     4  cities in Japan; and 2) that you supply beef to the restaurant chain.
     5  lp sell chicken and pork in addition to beef.
     6  0 tons of Nebraska USDA choice corn-fed beef.</pre>
<p></tt></tt> Some KWIC dictionaries are rich in features. For example, you can change the justification of the search string, add more words returned with each found result, etc. Is it useful? That depends on what you need to do. For me, I&#8217;ve been studying German and haven&#8217;t been able to see certain things in context. For example, I want to understand the difference, in context, between those prepositions that can take the accusitive or dative case depending on what you&#8217;re trying to say. I want to see examples, but can&#8217;t find any real German KWIC online (that responds faster than 10 minutes). So, I wrote a DIY KWIC.</p>
<p>What it requires: A URL and a search string. The search string you understand. The URL is going to be the corpus. When you click &#8220;Go&#8221; it will actually go to the URL, parse out the HTML and find links. It will dig several links and get the text from those sites, as well. It will then generate a single corpus of multi-page data will be your corpus that will then be searched through, looking for your search string. Just open up the link to the right called &#8220;KWIC&#8221; and just click &#8220;Go&#8221; with what&#8217;s there and see what happens. It&#8217;s not feature rich, nor is it pretty, but it gets the job done. I&#8217;m happy for feedback. Now, when I want to study German, I just throw in a Wikipedia article in German and search for a string.</p>
<p>Disclaimer: This is only to be used for personal purposes. It parses any website given, so you are responsible for the URL you search. You are not able to copy text, so it is read-only. The primary purpose is to help you with language study.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bakuzen.com/?feed=rss2&amp;p=17</wfw:commentRss>
		</item>
		<item>
		<title>Acoustic Model Creation using SphinxTrain</title>
		<link>http://www.bakuzen.com/?p=16</link>
		<comments>http://www.bakuzen.com/?p=16#comments</comments>
		<pubDate>Sat, 24 Jan 2009 17:29:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[NLP]]></category>

		<guid isPermaLink="false">http://www.bakuzen.com/?p=16</guid>
		<description><![CDATA[Before you look at this, you can peruse the official SphinxTrain documentation at the CMU website. It&#8217;s not for the faint-hearted, but if you&#8217;re a programmer and know how to get around Linux, then use it instead. Even if you&#8217;re interested in each step of how to do this, you may want to consider a [...]]]></description>
			<content:encoded><![CDATA[<p>Before you look at this, you can peruse the official <a href="http://www.speech.cs.cmu.edu/sphinxman/scriptman1.html">SphinxTrain documentation</a> at the CMU website. It&#8217;s not for the faint-hearted, but if you&#8217;re a programmer and know how to get around Linux, then use it instead. Even if you&#8217;re interested in each step of how to do this, you may want to consider a much easier way&#8230;.</p>
<p><strong>Getting the programs</strong></p>
<p>First, you need <a href="http://sourceforge.net/project/showfiles.php?group_id=1904&amp;package_id=68406">sphinx3</a> (I had to go back a few versions, or else it wouldn&#8217;t work). and <a href="http://cmusphinx.org/download/nightly/SphinxTrain.nightly.tar.gz">SphinxTrain</a> (This is the nightly build location; there isn&#8217;t an official release). Again, I assume you&#8217;re using Linux as root. Once downloaded, un-tar them:</p>
<p>&gt;tar -xvf sphinx3&#8230;<br />
&gt;tar -xvf SphinxTrain-</p>
<p>(Another assumption&#8230;.you have gcc and g++ (the c and c++ compilers) installed on your machine.) After they expand into their respective folders, go into the sphinx3 folder and run the config script:<br />
&gt;./configure<br />
If there are no errors, it should have made a make file. Make sure you&#8217;re root and run the command:<br />
&gt;make<br />
This will take a while. You will also need to run<br />
&gt;make install</p>
<p>Now move into the SphinxTrain folder and perform the following steps:<br />
&gt;./configure<br />
&gt;make</p>
<p>No need to run &#8220;make install&#8221; for SphinxTrain</p>
<p><strong>Creating your project/task folder</strong></p>
<p>Okay, now you need to make a project folder. For example&#8217;s sake, I&#8217;ll call our project myam (&gt;mkdir myam) and it needs to be in the same folder that SphinxTrain and sphinx3 are in.  Then naviagte into myam and run this command:<br />
&gt;<span style="color: #333333">../SphinxTrain/scripts_pl/setup_SphinxTrain.pl –task myam</span></p>
<p>Notice that myam is the name of the task and is also the name of your folder. It doesn&#8217;t have to be, but it makes things easier later.</p>
<p><strong>Collecting your data</strong></p>
<p>Put all of these files, unless otherwise specified, into your myam/etc folder.</p>
<p>First, you need the audio files that you want to use as your model of speech. I happened to have about 160 wav files, each of them is a single-sentence utterance. For example, if you listened to the first one, it might say &#8220;a player threw the ball to me&#8221; and that is all. Therefore, you need a bunch of single-sentence audio files, preferably in wav or raw format. Put all of your audio files into the myasm/wav folder</p>
<p>Next, you need a control file. It&#8217;s just a text file. Name it myam_train.fileids (you MUST name it [name]_train.fileids where [name] is the name of your taks, if you&#8217;re not using myam) that has the name of each of your audio files (note that there are no file extensions).     0001<br />
0002<br />
0003<br />
0004</p>
<p>Next, you need a transcription file that has the transcript of everything uttered where each line has a single file&#8217;s utterance on it. It MUST correspond to your control file your control file. For example, if I look at my control file, it says 0001 on the first line, therefore the transcript for the first line of my corpus file will be &#8220;A player threw the ball to me&#8221; because that&#8217;s the transcript of 0001.wav. The corpus file, another text file named myam.corpus, should have as many lines as your control file. Remove any punctuation. For exmaple:</p>
<p>a player threw the ball to me<br />
does he like to swim out to sea<br />
how many fish are in the water<br />
you are a good kind of person</p>
<p>Corresponds to my 0001, 0002, 0003, and 0004 files in that order.</p>
<p>What if I don&#8217;t have any transcripts of my audio files? Well, you&#8217;ll have to get some. NLP has to start somewhere, which means some people have to deal with manually creating data to train from. There is also a vast amount of data on the Internet where you can find audio/transcript bundles, some at the LDC (but that requires a membership).</p>
<p>Anyway, you now have your folder of audio files, a control file, and a transcription file. You still have a long ways to go. You still need a main dictionary which includes each word and the phonemes that make up the word, a filler dictionary, and a phone list. Lucky for you, CMU has an online tool that does the dictionary part for free: <a href="http://www.speech.cs.cmu.edu/tools/lmtool-adv.html" target="_blank">http://www.speech.cs.cmu.edu/tools/lmtool-adv.html</a>.</p>
<p>This website asks for several files, but you really only need one and that&#8217;s transcript file (myam.corpus). Browse for your transcription file under the &#8220;Sentence corpus file:&#8221; field.  Then click &#8220;Compile Knowledge Base&#8221; and wait a few seconds for the results. Download the sentence file and call it myam_train.transcription (notice that this file differs from your corpus file only in that it has start and end stentence tags &lt;s&gt; and &lt;/s&gt; and everything is upper-case). Download the dictionary file and call it myam.dic. Download the LM file and call it myam.lm. You&#8217;ll only need the first two for SphinxTrain, but the LM file is handy to have for other things. Put all files in your myam/etc file.</p>
<p>You will next need a filler dictionary. You can get specific here with different filler sounds, but we&#8217;ll just put together a base one. Make a file called myam.filler and paste this into it:</p>
<p>&lt;s&gt;     SIL<br />
&lt;sil&gt;   SIL<br />
&lt;/s&gt;    SIL</p>
<p>That leaves one last file, your phone file. This tells the trainer what phonemes that are part of your training set. You should only have the phonemes you need, no more, no less. How do you find the phonemes you need? Open up your myam.dic file. You&#8217;ll see words and then you&#8217;ll see a breakdown of how those words are pronounced. For example, in my dic file I have:</p>
<p>ACTING    AE K T IH NG</p>
<p>The AE, K, T, IH, NG are all phonemes that make up the word acting. You&#8217;ll need a list of all the phonemes used without duplicates. You can either just follow the next steps and home the errors tell you which phonemes are missing, or you can go to the page I made that will extract the phonemes for you:</p>
<p><a href="http://bakuzen.com/extractphoneme.php" target="_blank">http://bakuzen.com/extractphoneme.php</a></p>
<p>Be gentle. I just threw it together as I put together this post. It takes the dictionary file (myam.dic) that was generated by the CMU site and displays all the unique phonemes. The only problem is&#8230;they aren&#8217;t all completely unique. You may have to go through and take out duplicates. I don&#8217;t know why, but some of them aren&#8217;t counted as unique in the php unique_array function. Anyway, copy the phoneme list into a file called myam.phone.</p>
<p>That&#8217;s it for file collecting. A recap:</p>
<ol>
<li>All wav audio files into the myam/wav folder</li>
<li>The rest will be in the myam/etc folder
<ol>
<li>myam.dic</li>
<li>myam.filler</li>
<li>myam.phone</li>
<li>myam_train.fileids</li>
<li>myam_train.transcription</li>
<li>feat.params</li>
<li>sphinx_train.cfg</li>
</ol>
</li>
</ol>
<p>NOTE!!! Double check the following&#8230;..</p>
<ol>
<li>your .dic,.filler, .phones, and .transcription file have everything capitalized. If not, you can capitalize everything with Kate in Linux or PSPad in Windows (or a similar program)</li>
<li>you have an empty line at the bottom of each file</li>
<li>you have the same number of lines in the .transcription file as you do in the .fileids file</li>
<li>make sure your .phone file has no duplicate entries</li>
</ol>
<p>You have some configuring to do now. Open up myam/etc/sphinx_train.cfg with an editor (&gt;kate myam/etc/sphinx_train.cfg). It looks like a fairly daunting file, but there won&#8217;t be much you have to change here. First, notice that $CFG_DB_NAME = &#8220;myam&#8221; or whatever you set your task name to be. Many other properties in this file hinge around that name. That&#8217;s why we named the .dic, .phone, and other files the way we did. Also notice the $CFG_BASE_DIR is set to the directory where your task folder exists. If you ever moved the folder, you&#8217;ll need to  change this path. The next property, $CFG_SPHINXTRAIN_DIR, is set to the relative path where your SphinxTrain folder is, just in case it needs something from it.</p>
<p>Now, on to editing a few things. First, you&#8217;ll want to find the line that has the property: $CFG_WAVFILE_EXTENSION in it. To the right of the = sign is the file extension of your audio files. This is appended onto each of the filenames in your myam.fileids file. I set mine to &#8216;wav&#8217; and you need to be sure the single quotes are there, too. I also had to set the $CFG_WAVFILE_TYPE = &#8216;mswav&#8217; since my wav files were created in Windows (by someone else). I forgot to set this at first, and it never gives an error; the training sort of just hangs and doesn&#8217;t do anything. Save your changes, and close the editor.</p>
<p><strong>Creating the model</strong></p>
<p>NOW you get to create the acoustic model. First, navigate to your myam folder and then run this command:</p>
<p>&gt;./scripts.pl/make_feats -ctl etc/voxforge_it_train.fileids</p>
<p>This creates feature files from the wav files and stores them in the myam/feat directory. It should move through the files fairly quickly. It went through my 160 files, each averaging about 10 words, in a few seconds.</p>
<p>If there were no errors, you can move onto the last part. Run this command from the myam folder:</p>
<p>&gt;./scripts.pl/RunAll.pl</p>
<p>This is where the magic happens, and it could (really should) take several minutes depending on how much data you have. It first goes through and makes sure the data you have are usable, and then it actually goes through the different phases of the acoustic model training. It logs errors to the myam/logdir folder, and it creates an easier-to-read html error log in your myam folder, named myam.html (or the name of your task+.html). The bottom of the file has your latest log information.You will probably have several errors and warnings, but if there was no &#8220;fatal error&#8221; then your training should be complete.</p>
<p><strong>Making the model usable for Sphinx4 </strong></p>
<p>I really just copied an acoustic model jar file, like the WSJ one, renamed it to zip, and created a similar file structure. CMU has a <a href="http://cmusphinx.sourceforge.net/sphinx4/doc/UsingSphinxTrainModels.html" target="_blank">tutorial</a> that is very helpful in putting together your sphinx4 acoustic mode, and I refer you to that for further help. Once you get your folder structure created (just to test out, make it the same as CMU&#8217;s structure), you&#8217;ll need this file structure:</p>
<pre><font><font face="Arial">cd_continuous_8gau/means
cd_continuous_8gau/mixture_weights
cd_continuous_8gau/variances
cd_continuous_8gau/transition_matrices
dict/cmudict.0.6d
dict/fillerdict
etc/TOY_8gau_13dCep_16k_40mel_130Hz_6800Hz.4000.mdef
etc/TOY_8gau_13dCep_16k_40mel_130Hz_6800Hz.ci.mdef
</font></font></pre>
<p>There are several files in cd_continuous_8ga, etc, and dict. The files that belong in the cd_continuous_8gau folder can be found in your myam/model_parameters/eimodel.ci_cont/ folder (the names correspond). The dic folder wants any dictionary files. Add your myam.dic and your myam.filler dictionaries to it. The etc directory uses two files found in the myam/model_architecture/ directory. The mdef file will be your myam.alltriphones.mdef file, and the ci.mdef file will be your myam.ci.mdef file. Copy each file into the correct folders.</p>
<p>Now you need to create a file in the directory that holds the etc, dict, and cd_continuous_8ga folders. The file needs to be named model.props and you need to add these properties to it:</p>
<p>description = any description of your model file<br />
modelClass = edu.cmu.sphinx.model.acoustic.EI_8gau_13dCep_16k_40mel_130Hz_6800Hz.Model<br />
modelLoader = edu.cmu.sphinx.model.acoustic.EI_8gau_13dCep_16k_40mel_130Hz_6800Hz.ModelLoader</p>
<p>isBinary = true<br />
featureType = 1s_c_d_dd<br />
vectorLength = 39<br />
sparseForm = false</p>
<p>numberFftPoints = 512<br />
numberFilters = 40<br />
gaussians = 8<br />
minimumFrequency = 130<br />
maximumFrequency = 6800<br />
sampleRate = 16000</p>
<p>dataLocation = cd_continuous_8gau<br />
modelDefinition = etc/myam.ci.mdef</p>
<p>Save the file and close the editor. You will also need the  Model.class, ModelLoader.class, and the PropertiesDumper.class. You can either get those from an exisiting jar, or go to the site I referred you to on how to create it correctly.</p>
<p>Now navtigate into the etc folder where your mdef files are. Create a file called variables.def and put this info into it:</p>
<p>set exptname = myam<br />
set vector_length = 13<br />
set dictionary = $base_dir/lists/myam.dic<br />
set fillerdict = $base_dir/lists/myam.filler<br />
set statesperhmm = 3<br />
set skipstate = no<br />
set gaussiansperstate = 8<br />
set feature = 1s_c_d_dd<br />
set n_tied_states = 4000<br />
set agc = none<br />
set cmn = current<br />
set varnorm = no</p>
<p>Notice the myam.dic and myam.filler. Be sure to use the link I provided for more information. Save the file and close.</p>
<p>Now, if you want to do it the easy way, go back to your first folder (if you followed the CMU way, the foler &#8220;edu&#8221; and create a zip file out of it. Rename the zip file to a jar file exension and you now have an acoustic model. The rest is linking it into Sphinx4 via eclipse and setting up the information in your config.xml file. There will be three places do to that, the dictionary, the loader, and the acoustic model definitions. Refer to my <a href="http://www.bakuzen.com/?p=7" target="_blank">original post</a> on sphinx4 on how do deal with the config file.  I had to play with it for a while before I got everything to work correctly, but it was thrilling to see my own first acoustic model to work in Sphinx4.</p>
<p>If you have any trouble, feel free to leave a comment with your question and I&#8217;ll see what I can&#8217;t help you through. There is also a great site called <a href="http://voxforge.org/" target="_blank">http://voxforge.org/</a> that is a go-to site for DIY NLP people out there. A site like that may make my site obsolete one way, but I&#8217;ll still be around for those of you who aren&#8217;t as programming savvy as those folks typically are. It&#8217;s an excellent site and I encourage you to look there for data you can use in acoustic model creation, help on problems you run into, and also to contribute by adding data you have, giving insights on aspects of NLP, or helping people by answering questions they may have.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bakuzen.com/?feed=rss2&amp;p=16</wfw:commentRss>
		</item>
		<item>
		<title>LiveMocha</title>
		<link>http://www.bakuzen.com/?p=15</link>
		<comments>http://www.bakuzen.com/?p=15#comments</comments>
		<pubDate>Thu, 08 Jan 2009 22:48:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[German]]></category>

		<category><![CDATA[Japanese]]></category>

		<guid isPermaLink="false">http://www.bakuzen.com/?p=15</guid>
		<description><![CDATA[I haven&#8217;t posted for a while because I&#8217;ve been applying for graduate school. That&#8217;s all I have to say about that.
But that&#8217;s not all. I&#8217;ve also been studying German. In a late issue of PC Magazine, it listed &#8220;100 useful websites&#8221; and among it was a website for people who wish to learn foreign languages. [...]]]></description>
			<content:encoded><![CDATA[<p>I haven&#8217;t posted for a while because I&#8217;ve been applying for graduate school. That&#8217;s all I have to say about that.</p>
<p>But that&#8217;s not all. I&#8217;ve also been studying German. In a late issue of PC Magazine, it listed &#8220;100 useful websites&#8221; and among it was a website for people who wish to learn foreign languages. It&#8217;s called&#8230;</p>
<p>http://www.livemocha.com</p>
<p>It&#8217;s fairly new, but has been around long enough to get a very diverse userbase. Here&#8217;s how it works.</p>
<p>Livemocha is a site that couples social networking with language lessons. You can go to the site and exclusively focus on the lessons they offer or you can go to the site just to chat and ask language questions to other people who know your target language. When you sign up, it asks you what languages you are learning and what languages you know. It then suggests friends to add to your friends list that either know the language you&#8217;re trying to learn or people trying to learn a language that you know. You can add people to your friends list and either send them messages like email or chat with them online (audio or typed). But that&#8217;s not all. As you take the Livemocha language lessons, you will be confronted with 40 flashcards, drilled on those flashcards (it will test your listening, reading, and fill-in-the-sentence abilities), and then you take what you learn and practice typing in your target language. You can then send that which you typed to friends on your list who can comment on how well you did or how to improve. You are also recorded via microphone which is also send to friends of your choice who coach you on pronunciation.</p>
<p>For example&#8230;</p>
<p>I am a native English speaker and I also speak advanced Japanese. I have people on my friends list who are learning English or Japanese who send me their submissions and ask me questions about the two languages that I help answer.</p>
<p>A typical session for  me goes like this&#8230;. I log into Livemoha.com and continue my German lesson. It takes me through the 40 flash cards, then drills me, then I am asked to write about something specific (eg, &#8220;Based on what you learned in this lesson, write about what you did over the weekend. Describe 3 events that took place and who was with you,&#8221; etc). Then I spend some time forming German sentences to answer the question of what I did over the weekend making sure I include everything it asks. When I submit, it asks me which friends I want to notify so they can rate what I wrote. Then I am taken to a speaking activity where I read already written German text into a microphone and then choose which friends I want to notify about that so they can comment. That process takes about 30 minutes. Then, in the next day or two, I get emails telling me that people have commented on my writing and speaking items. I can go look at their comments anytime. Then, when I have time, I can catch certain freinds online and practice my German by chatting with them.</p>
<p>Sounds easy? It is. Did I mention it&#8217;s&#8230;.free.</p>
<p>What&#8217;s the catch? There are advertisements, but they aren&#8217;t too bad. I click on ones that interest me sometimes in order to help keep the website going. The other catch is that if you receive help, you should also offer help to others. When you comment on other people&#8217;s submissions, be specific and helpful about what they need to do to improve. I am lucky enough to have a very nice German woman who I send all of my submissions to and she is nitpicky about how I pronounce things. She sends me to websites to learn about certain German grammar that I struggle with. It&#8217;s very effective, and very affordable. Good luck, and happy language learning.</p>
<p>PS- It&#8217;s still in Beta form, so be patient as they add it is a continual work in progress.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bakuzen.com/?feed=rss2&amp;p=15</wfw:commentRss>
		</item>
		<item>
		<title>MP3 Conversion in Sphinx4</title>
		<link>http://www.bakuzen.com/?p=14</link>
		<comments>http://www.bakuzen.com/?p=14#comments</comments>
		<pubDate>Thu, 28 Aug 2008 11:48:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[NLP]]></category>

		<guid isPermaLink="false">http://www.bakuzen.com/?p=14</guid>
		<description><![CDATA[It&#8217;s actually not that specific; this is how you can do MP3 conversion in any Java program. I&#8217;m just going to show you how to do it in the context of Sphinx4. The tool that does the job is called Tritonus a series of Java jars that can encode from several different formats into several [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s actually not that specific; this is how you can do MP3 conversion in any Java program. I&#8217;m just going to show you how to do it in the context of Sphinx4. The tool that does the job is called <a href="http://tritonus.org/" target="_blank">Tritonus</a> a series of Java jars that can encode from several different formats into several different formats.</p>
<p>Why bother? Because Sphinx4 requires 16-bit mono files in wav format. It can&#8217;t recognize anything else. Sometimes all you get to work with are MP3s and that means you have to convert them. There are a lot of programs out that (free ones, even) that you can use to convert from various formats to various formats, but Sphinx4 is a little bit pickier than just an easy conversion. For example, Audacity is a common program you would use to manipulate or convert an audio file, but for some reason the output is difficult to read by Sphinx4 even though it sounds just fine through any audio player. Trinonus does it right and&#8230;it can do it on the fly. It can detect the format of an audio file and, if all is set up properly, can convert to the coveted 16-bit format needed by Sphinx. With Tritonus there&#8217;s no need to convert everything beforehand.That&#8217;s why.</p>
<p>Now for the how. If you&#8217;ve followed my posts by now you should have been able to recognize a simple file, understand how the config file works, and change some things around to meet your needs. It&#8217;s actually not too difficult. All you need is a file in the proper format to recognize, a config file, and a Java program to utilize the Sphinx4 jar. Assuming you have the former 2, the Java file can be a pretty base file that looks something like this (note that the blog software I use automatically left-justified everything, sorry for the formatting!):</p>
<p>public class FileRecognizer {<br />
public static void main(String[] args) {<br />
try {<br />
URL audioFileURL = FileRecognizer.class.getResource(&#8221;insert path to audio file here&#8221;);<br />
URL configURL = FileRecognizer.class.getResource(&#8221;config.xml&#8221;);<br />
ConfigurationManager cm = new ConfigurationManager(configURL);<br />
Recognizer recognizer = (Recognizer) cm.lookup(&#8221;recognizer&#8221;);<br />
/* allocate the resource necessary for the recognizer */<br />
recognizer.allocate();<br />
StreamDataSource reader = (StreamDataSource) cm.lookup(&#8221;streamDataSource&#8221;);<br />
AudioInputStream ais  = AudioSystem.getAudioInputStream(audioFileURL);<br />
reader.setInputStream(ais, audioFileURL.getFile());<br />
Result result = recognizer.recognize();<br />
if (result != null) {<br />
System.out.println(&#8221;\nRESULT: &#8221; +<br />
result.getBestFinalResultNoFiller() + &#8220;\n&#8221;);<br />
}<br />
catch (Exception e) {<br />
e.printStackTrace();<br />
}<br />
}</p>
<p>At a glance, this Java class file has the main method, a line that gets the path of the file you want to recognize, reads information from the config file, then recognizes the file and prints the results. Assuming you have the Sphinx4 jar file linked in (see <a href="http://www.bakuzen.com/?p=4">this</a> post if you don&#8217;t  know what I&#8217;m talking about) this should compile and work just fine.</p>
<p>Now the trick is to be able to read in an audio file and have it be converted to the proper format on the fly. The steps to be able to do this are similar to using Sphinx4. You have to link in the proper jars (and in the proper order) and know how to import and utilize them.</p>
<p>First, you need to go to the <a href="http://tritonus.org/plugins.html" target="_blank">trinonus plugins</a> website and download a few things.</p>
<ol>
<li>tritonus.jar</li>
<li>tritonus_share.jar</li>
<li>tritonus_remaining.jar</li>
<li>tritonus_mp3.jar</li>
</ol>
<p>Note that these jars probably have version numbers attached to them (for example, tritonus_mp3 might be tritonus_mp3-0.3.6.jar) which is fine. Download the latest of each jar into (or move them into) the lib folder you created inside your sphinx4 directory. If you don&#8217;t know what I&#8217;m talking about, then refer back to <a href="http://www.bakuzen.com/?p=4">this</a> post to see what I&#8217;m talking about). Now, in order to link them in using eclipse, you want to go to Project-&gt;Properties-&gt;Java Build Path-&gt;Libaries-&gt;Add Jars (add all 4 of them) then go to the Order and Export tab and move the order of them to the order shown above (tritonus.jar, share, remaining, mp3).</p>
<p>You&#8217;re not out of the woods yet. You still need some more jars to get the job done. You may need to specially link in tools.jar which can be found in your java jre/lib folder. For some reason I had to do that to get it to work properly. The other jar you&#8217;ll need is called javalayer.jar. You can run a Google search. It&#8217;s a javazoom project and for some reason is necessary for Sphinx4 to work with tritonus to do anything with mp3s. Download it, get it into the lib folder, and link it in like you did before.</p>
<p>That should do it for getting the necessary plugins- now you need to utilize them with the code. It&#8217;s not too tough. First, import the right stuff:</p>
<p>import javax.sound.sampled.AudioFileFormat;<br />
import javax.sound.sampled.AudioFormat;<br />
import javax.sound.sampled.AudioInputStream;<br />
import javax.sound.sampled.AudioSystem;<br />
import javax.sound.sampled.UnsupportedAudioFileException;</p>
<p>Then, there are some steps that you&#8217;ll need to follow. After you get the AudioInputStream for the file you want to recognize, you&#8217;ll need to tell it what to change it into and then actually do the change:</p>
<p>AudioFormat targetFormat =<br />
new AudioFormat(16000f,<br />
16,    // sample size in bits<br />
1,     // mono<br />
true,  // signed<br />
true);</p>
<p>AudioInputStream convertedAis = wavFile.convertAudioInputStream(ais, targetFormat);</p>
<p>The last line is a call to a function that will run through a few things and then return the converted AudioInputStream. If all goes well, <em>that&#8217;s</em> what you&#8217;ll be sending through to the recognizer. This is the function convertAudioInputStream (NOTE!!! I didn&#8217;t make this function. I was kindly shown this by Robbie Haertel so he gets credit for all of this):</p>
<p>private AudioInputStream convertAudioInputStream(AudioInputStream sourceAis, AudioFormat targetFormat) {<br />
AudioFormat baseFormat = sourceAis.getFormat();<br />
AudioFormat intermediateFormat;<br />
AudioInputStream convertedAis = sourceAis;</p>
<p>// First convert the encoding, if necessary<br />
if (!baseFormat.getEncoding().equals(targetFormat.getEncoding())) {<br />
intermediateFormat = new AudioFormat(<br />
targetFormat.getEncoding(),<br />
baseFormat.getSampleRate(), baseFormat.getSampleSizeInBits(), baseFormat.getChannels(),<br />
baseFormat.getChannels() * 2, baseFormat.getSampleRate(),<br />
false);<br />
convertedAis = AudioSystem.getAudioInputStream(intermediateFormat, sourceAis);<br />
//this.writeConvertedFile(convertedAis, &#8220;C:\\encoding.wav&#8221;);<br />
baseFormat = intermediateFormat;<br />
sourceAis = convertedAis;<br />
convertedFile = true;<br />
}</p>
<p>// Then convert the sample rate<br />
if (baseFormat.getSampleRate() != targetFormat.getSampleRate()) {<br />
intermediateFormat = new AudioFormat(<br />
baseFormat.getEncoding(),<br />
targetFormat.getSampleRate(), baseFormat.getSampleSizeInBits(), baseFormat.getChannels(),<br />
baseFormat.getChannels() * 2, targetFormat.getSampleRate(),<br />
false);<br />
convertedAis = AudioSystem.getAudioInputStream(intermediateFormat, sourceAis);<br />
//this.writeConvertedFile(convertedAis, &#8220;C:\\sample.wav&#8221;);<br />
baseFormat = intermediateFormat;<br />
sourceAis = convertedAis;<br />
convertedFile = true;<br />
}</p>
<p>// Then convert the number of channels<br />
if (baseFormat.getChannels() &gt; targetFormat.getChannels()) {<br />
intermediateFormat = new AudioFormat(<br />
baseFormat.getEncoding(),<br />
baseFormat.getSampleRate(), baseFormat.getSampleSizeInBits(), targetFormat.getChannels(),<br />
targetFormat.getChannels() * 2, baseFormat.getSampleRate(),<br />
false);<br />
convertedAis = AudioSystem.getAudioInputStream(intermediateFormat, sourceAis);<br />
//this.writeConvertedFile(convertedAis, &#8220;C:\\channels.wav&#8221;);<br />
baseFormat = intermediateFormat;<br />
sourceAis = convertedAis;<br />
convertedFile = true;<br />
}<br />
return convertedAis;<br />
}</p>
<p>Of course, on the reader.setInputStream call you send it the convertedAis in stead of the original ais. That should do the trick.</p>
<p align="center">If only it were that easy.</p>
<p align="left">I found that this didn&#8217;t work sometimes for some reasons. It turns out that working with audio providers (like tritonus) things can get in the way and audio streaming becomes a difficult thing to do. For those of you who had the same problem, I found a work-around hack that has never failed me. After I create the new AudioInputStream aptly known as convertedAis, I write it out to disk as a new audio file (in this case, it&#8217;ll be the converted wav file). Then I read it in from scratch as if the conversion never happened. As soon as I recognize the file, I delete it so no one is the wiser. However, this can be useful because you can now use Sphinx4 to not only convert your MP3 files and recognize them on the fly, but you can write the converted wav files to disk (of course, giving them good names) and using them later for&#8230;.whatever you want. You can write your own program to convert whole folders of files.</p>
<p align="left">You can now see how adding in other jars from tritonus will give you the option of converting files from and into different formats. Have fun. I attached my final version of the <a href="http://www.bakuzen.com/FileRecognizer.java">FileRecognizer.java</a> file complete with conversion, writing the file out to disk, recognizing it, then deleting it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bakuzen.com/?feed=rss2&amp;p=14</wfw:commentRss>
		</item>
		<item>
		<title>LREC</title>
		<link>http://www.bakuzen.com/?p=13</link>
		<comments>http://www.bakuzen.com/?p=13#comments</comments>
		<pubDate>Fri, 15 Aug 2008 21:11:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Corpora]]></category>

		<category><![CDATA[NLP]]></category>

		<guid isPermaLink="false">http://www.bakuzen.com/?p=13</guid>
		<description><![CDATA[The International Language Resource and Evaluation Conference took place at the end of May this year in Marrakesh, Morocco. I was able to go for the same research we did on second language proficiency testing. We presented a poster in one of the poster sessions and had a lot of interested people ask many questions.
There [...]]]></description>
			<content:encoded><![CDATA[<p>The International Language Resource and Evaluation Conference took place at the end of May this year in Marrakesh, Morocco. I was able to go for the same research we did on second language proficiency testing. We presented a poster in one of the poster sessions and had a lot of interested people ask many questions.</p>
<p>There was a big difference between the conference goers here and the ones at CALICO. The CALICO conference sported mostly educators looking for ways to improve language teaching in the classroom where LREC focused more on natural language processing. There would be more software engineers and linguists rather than educators. There were talks in the range from very in-depth statistical theory to corpora. I mostly sat in on what people were doing with machine translation or the Japanese language.</p>
<p>Now a word on corpora. For some naive reason, I thought that we had a pretty good amount of corpora for most purposes, like POS tagging, word chunking, parsing, etc. But, from this conference, I found that many organizations are working on new corpora all the time. There are general corpora like the Wall Street Journal spoken English to more specific corpora like the utterances of drunk people. Corpora is huge in NLP whether it&#8217;s statistical NLP or otherwise. The big corpora repositories are the <a href="http://www.ldc.upenn.edu/" target="_blank">LDC</a> in the United States and <a href="http://www.elra.info/" target="_blank">ELRA</a> in Europe. There are a few in Asia, as well. The problem is most useful corpora isn&#8217;t freely available. You can either 1. contribute or 2. pay for membership to get corpora. They will give corpora for free, but not typically to a hobbyist individual. They like to let universities use the data and they like to know why. That doesn&#8217;t mean the individual can&#8217;t have fun, he/she just has to be more creative.</p>
<p>Big companies like Microsoft presented some things at the conference, as well. Companies use NLP more and more these days even if they aren&#8217;t a specific NLP company like, say, Nuance. Microsoft can use NLP in MS Word. I worked for a company where we worked on developing a way to make a part of speech tagger to automatically tag new dialogs so someone wouldn&#8217;t have to go in and do it by hand- something that didn&#8217;t necessarily affect the end user. Cell phone companies, car companies, and many different software companies are using NLP more and more. This conference may not have the bleeding edge of NLP technology of our time, but it is a great conference for seeing what&#8217;s going on in the field and possibly finding a job doing NLP.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bakuzen.com/?feed=rss2&amp;p=13</wfw:commentRss>
		</item>
	</channel>
</rss>
