{"id":2302,"date":"2008-09-12T10:47:54","date_gmt":"2008-09-12T15:47:54","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/2008\/09\/12\/making-matlab-talk\/"},"modified":"2016-05-10T08:46:20","modified_gmt":"2016-05-10T12:46:20","slug":"making-matlab-talk","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2008\/09\/12\/making-matlab-talk\/","title":{"rendered":"Making MATLAB Talk"},"content":{"rendered":"<div class=\"content\">\r\n\r\nBrett's Pick this week focuses on functionality rather than on a single file.\r\n\r\nFor a project I'm currently playing around with, I recently decided that I wanted to make my computer talk, and to use MATLAB\r\nto control it. A brief search of documentation didn't return any hits that looked promising--MATLAB doesn't really provide\r\nany mechanism for generating speech. Looking at the File Exchange (keyword \"speech\"), though, proved fruitful. In fact, selecting\r\nwhich of the several submissions to use was the most difficult part of the problem.\r\n\r\nChronologically, the first \"speak\" mfile I found was from Fahad Al Mahmood, submitted back in 2004. (Indeed, Fahad's file was selected as a Pick of the Week, back in '04.) But that file uses a call to Excel, and doesn't provide for a lot of control over the\r\ngenerated speech.\r\n\r\nFahad's submission was closely followed by Iari-Gabriel Marino's no-frills ActiveX version of <a title=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadFile.do?objectId=4824&amp;objectType=file (link no longer works)\">TTS<\/a> (text-to-speech).\r\n\r\nWolfgang Garn's 2006 submission includes a function called <a title=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadFile.do?objectId=11297&amp;objectType=FILE (link no longer works)\">text2speech<\/a> that allows a user to control pitch, to insert pauses, and to add emphasis to words.\r\n\r\nAnd Siyi Deng followed up in 2007 with another version of <a title=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadFile.do?objectId=18091&amp;objectType=FILE (link no longer works)\">TTS<\/a> that optionally allows the user to write WAV files, to control the speed of the voice, and to list available voices.\r\n\r\n<embed src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Brett\/FlowPlayer.swf?config=%7Bembedded%3Atrue%2CbaseURL%3A%27http%3A%2F%2Fblogs%2Emathworks%2Ecom%2Fimages%2Fpick%2FBrett%27%2CsplashImageFile%3A%27HelloWorldScreenShot%2Ejpg%27%2CvideoFile%3A%27HelloWorld%2Eflv%27%2Cloop%3Afalse%2CinitialScale%3A%27fit%27%2CshowFullScreenButton%3Afalse%2CautoBuffering%3Afalse%2CmenuItems%3A%5Bfalse%2Cfalse%2Cfalse%2Cfalse%2Cfalse%2Ctrue%5D%2CautoPlay%3Afalse%7D\" type=\"application\/x-shockwave-flash\" width=\"500\" height=\"400\"><\/embed>\r\n\r\nYou gotta love the File Exchange--thanks for these great submissions, Fahad, Iari-Gabriel, Wolfgang, and Siyi!\r\n\r\nAnyone have any good stories to share about using MATLAB to speak, or doing speech recognition in MATLAB? We'd love to hear\r\nfrom you.\r\n\r\n<script>\/\/ <![CDATA[\r\nfunction grabCode_ae656864863e4f139274ed9c80beac16() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='ae656864863e4f139274ed9c80beac16 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' ae656864863e4f139274ed9c80beac16';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        author = 'Brett Shoelson';\r\n        copyright = 'Copyright 2008 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('\r\n\r\n<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\r\n\r\n\r\n\\n');\r\n      \r\n      d.title = title + ' (MATLAB code)';\r\n      d.close();\r\n      }\r\n\/\/ ]]><\/script>\r\n<p style=\"text-align: right; font-size: xx-small; font-weight: lighter; font-style: italic; color: gray;\">\r\n<a><span style=\"font-size: x-small; font-style: italic;\">Get\r\nthe MATLAB code\r\n<noscript>(requires JavaScript)<\/noscript><\/span><\/a>\r\n\r\nPublished with MATLAB\u00ae 7.6<\/p>\r\n\r\n<\/div>\r\n<!--\r\nae656864863e4f139274ed9c80beac16 ##### SOURCE BEGIN #####\r\n%% Making MATLAB Talk\r\n%%\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadAuthor.do?objectId=1093599&objectType=author Brett>'s Pick this week focuses on functionality rather than on a single file.\r\n%%\r\n% For a project I'm currently playing around with, I recently decided that I wanted to make my computer talk, and to use MATLAB to control it. A brief search of documentation didn't return any hits that looked promisingREPLACE_WITH_DASH_DASHMATLAB doesn't really provide any mechanism for generating speech. Looking at the File Exchange (keyword \"speech\"), though, proved fruitful. In fact, selecting which of the several submissions to use was the most difficult part of the problem.\r\n%%\r\n% Chronologically, the first \"speak\" mfile I found was from <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadAuthor.do?objectType=author&objectId=1093883 Fahad Al Mahmood>, submitted back in 2004.\r\n% (Indeed, <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadFile.do?objectId=4769&objectType=file Fahad's file> was <https:\/\/blogs.mathworks.com\/pick\/2004\/06\/23\/talking-matlab\/previously selected> as a Pick of the Week, back in '04.) But that file uses a call to Excel, and doesn't provide for a lot of control over the generated speech.\r\n%%\r\n% Fahad's submission was closely followed by <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadAuthor.do?objectId=1093997&objectType=author Iari-Gabriel Marino>'s no-frills ActiveX version of <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadFile.do?objectId=4824&objectType=file TTS> (text-to-speech).\r\n%%\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadAuthor.do?objectType=author&objectId=1094930 Wolfgang Garn>'s 2006 submission includes a function called <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadFile.do?objectId=11297&objectType=FILE text2speech> that allows a user to control pitch, to insert pauses, and to add emphasis to words.\r\n\r\n%%\r\n% And\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadAuthor.do?objectId=1095035&objectType=author Siyi Deng> followed up in 2007 with another version of <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadFile.do?objectId=18091&objectType=FILE TTS> that optionally allows the user to write WAV files, to control the speed of the voice, and to list available voices.\r\n\r\n%%\r\n% You gotta love the File ExchangeREPLACE_WITH_DASH_DASHthanks for these great submissions, Fahad, Iari-Gabriel, Wolfgang, and Siyi!\r\n\r\n%%\r\n% Anyone have any good stories to share about using MATLAB to speak, or\r\n% doing speech recognition in MATLAB? We'd love to hear from you.\r\n##### SOURCE END ##### ae656864863e4f139274ed9c80beac16\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n\r\nBrett's Pick this week focuses on functionality rather than on a single file.\r\n\r\nFor a project I'm currently playing around with, I recently decided that I wanted to make my computer talk, and to... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2008\/09\/12\/making-matlab-talk\/\">read more >><\/a><\/p>","protected":false},"author":34,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2302"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/34"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=2302"}],"version-history":[{"count":1,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2302\/revisions"}],"predecessor-version":[{"id":6934,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2302\/revisions\/6934"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=2302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=2302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=2302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}