{"id":7379,"date":"2014-04-23T05:09:41","date_gmt":"2014-04-22T19:09:41","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=7379"},"modified":"2018-11-25T21:06:44","modified_gmt":"2018-11-25T11:06:44","slug":"xcode-cocoa-applescript-dictation-program-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/xcode-cocoa-applescript-dictation-program-primer-tutorial\/","title":{"rendered":"Xcode Cocoa-Applescript Dictation Program Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/Xcode\/Cocoa-ApplescriptApplication\/\"><img decoding=\"async\" id='xcimage' style=\"float:left;border: 15px solid pink;\" alt=\"Xcode Cocoa-Applescript Dictation Program Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/Mac\/Xcode\/Cocoa-ApplescriptApplication\/Dictation_Program-51of.jpg\" title=\"Xcode Cocoa-Applescript Dictation Program Primer Tutorial\"  \/><\/a><p class=\"wp-caption-text\">Xcode Cocoa-Applescript Dictation Program Primer Tutorial<\/p><\/div>\n<p>Building on yesterday&#8217;s relevant <a target=_blank title='Mac OS X Dictation Primer Tutorial' href='#moxdpt'>Mac OS X Dictation Primer Tutorial<\/a> as shown below, which addressed the Operating System view of the Dictation functionality, today we take some first steps down the road of writing an application to use this Dictation functionality.<\/p>\n<p><script type='text\/javascript'>var xcimageo = null;  setInterval(eatAtJoes, 3000); function eatAtJoes() { if (xcimageo == null) xcimageo = document.getElementById('xcimage'); xcimageo.src = xcimageo.src.replace(\"-51\", \"~52\").replace(\"-52\", \"-51\").replace(\"~\",\"-\"); } <\/script><\/p>\n<p>We make use of the Xcode IDE and create a new project which is a Cocoa-Applescript Application project, and as you may have guessed from this we also make use of Mac Applescript Editor application to unit test what we place into the application in the &#8220;slot&#8221; where you place your Applescript script code.<\/p>\n<p>The first slides of our <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/Xcode\/Cocoa-ApplescriptApplication\/\" title='Click picture.'>tutorial<\/a> address the System Preferences Privacy and Security issues associated with allowing access of software to the Dictation system (read more <a target=_blank title='Mac OS X Dictation System Preferences Privacy and Security information' href='http:\/\/www.macosautomation.com\/mavericks\/guiscripting\/index.html'>here<\/a>), and with Mac OS X 10.9 (Mavericks) this has tightened up quite a bit (rather than the <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/Xcode\/Cocoa-ApplescriptApplication\/Dictation_Program-2of.jpg\">one checkbox<\/a> as for previous Mac OS Xs, for Mavericks we, as administration users, need to <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/Xcode\/Cocoa-ApplescriptApplication\/Dictation_Program-3of.jpg\">specify individual applications<\/a> given access to the functionality).<\/p>\n<p>Then we see the Xcode IDE File->New Project &#8230; Cocoa-Applescript Application creation of an Xcode application, which is added to our System Preference Dictation &#8220;allow&#8221; list.<\/p>\n<p>Here is some downloadable Applescript script called <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/Xcode\/Cocoa-ApplescriptApplication\/AppDelegate.applescript_GETME\" title='AppDelegate.applescript'>AppDelegate.applescript<\/a> (for this we need to thank brilliance of Open Source community on this <a target=_blank title='great tutorial ... thanks' href='https:\/\/discussions.apple.com\/message\/21338713#21338713'>link<\/a>) supervised by some Objective-C programming source code called <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/Xcode\/Cocoa-ApplescriptApplication\/main.m_GETME\" title='main.m'>main.m<\/a><\/p>\n<p>There are, as you might expect, means to functionality, to do away with all mouse and keyboard aspects to this Dictation functionality.<\/p>\n<p><span><\/p>\n<h4><b>Did you know?<\/b> &#8230; or &#8230; <b>By the way<\/b><\/h4>\n<p><\/span><\/p>\n<p>The little &#8220;Eat at Joes&#8221; bizzo with the tutorial picture today is an example of Javascript embedded into the blog post as featured at  <a target=_blank title='Javascript Thumbnails in Your WordPress Post Primer Tutorial' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=7306'>Javascript Thumbnails in Your WordPress Post Primer Tutorial<\/a>, and involved:<\/p>\n<ul>\n<li>Giving the image an id (don&#8217;t we all crave for this) &#8230; made it &#8220;xcimage&#8221;<\/li>\n<li>Embedded into the blog post <br \/><i>&lt;script type=&#8217;text\/javascript&#8217;&gt;var xcimageo = null;  setInterval(eatAtJoes, 3000); function eatAtJoes() { if (xcimageo == null) xcimageo = document.getElementById(&#8216;xcimage&#8217;); xcimageo.src = xcimageo.src.replace(&#8220;-51&#8221;, &#8220;~52&#8221;).replace(&#8220;-52&#8221;, &#8220;-51&#8221;).replace(&#8220;~&#8221;,&#8221;-&#8220;); } &lt;\/script&gt;<br \/>\n<\/i><\/li>\n<p><\/p>\n<p>If this embedding feels odd to you, that is a natural enough reaction, but bear in mind that (Javascript) Bookmarklets all work in this similar vein &#8230; refer to <a target=_blank title='Bookmarklet tutorials here' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=Bookmarklet'>this link<\/a> perhaps.<\/p>\n<p>Another approach to this &#8220;look&#8221; are animated GIFs, and for this would recommend <a target=_blank title='Gifpal' href='http:\/\/gifpal.com'>Gifpal<\/a> and you can catch up on some tutorials about Gifpal <a target=_blank title='Bookmarklet tutorials here' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=Gifpal'>here<\/a>.<\/p>\n<hr \/>\n<p id='moxdpt'>Previous relevant <a target=_blank title='Mac OS X Dictation Primer Tutorial' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=7264'>Mac OS X Dictation Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/Dictation\/Dictation.m4v\"><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"Mac OS X Dictation Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/Mac\/Dictation\/Dictation.jpg\" title=\"Mac OS X Dictation Primer Tutorial\"  \/><\/a><p class=\"wp-caption-text\">Mac OS X Dictation Primer Tutorial<\/p><\/div>\n<p>The ability to use Dictation to text boxes using Mac OS X has been around awhile, but the means to demonstrate this for you in a tutorial got harder with Mac OS X Mavericks with the demise of an integrated <a target=_blank title='Podcast Puiblisher tutorials here' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=podcast-publisher'>Podcast Publisher<\/a> to show you both the audio and the video together, easily, in a presentation.<\/p>\n<p>First off, let&#8217;s say how great Dictation is, with the incredible functionality of interpreting what you say getting sent to and from an Apple server (via <a target=_blank title='Speech or voice rgognition information from Wkipedia' href='http:\/\/en.wikipedia.org\/wiki\/Speech_recognition'>voice recognition<\/a> functionality) and onto a text box within a Mac application like Notes, as we show you here today &#8230; just incredible.<\/p>\n<p>Showing you &#8230; well &#8230; that needed &#8230;<\/p>\n<ul>\n<li>Two passes with Quicktime Player, first laying down a Video track of <i>Dictation<\/i>, then secondly synchronizing an Audio track of <i>Dictation<\/i> later (<a target=_blank title='Quicktime Player Audio track with playing previously created Video track' href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/Dictation\/Dictation-81of.jpg\">while playing the Video track<\/a>) &#8230; doesn&#8217;t seem to be able to let you record both at once, though tried this, to find corrupt data when trying to save them.<\/li>\n<li>One pass at the brilliant VLC Media Player (<a target=_blank title='VLC home page' href='http:\/\/www.videolan.org\/'>home page<\/a>) via File-&gt;Advanced Open File&#8230; opening video plus synchronized audio with Streaming\/Saving checked to a <a target=_blank title='VLC .m4v' href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/Dictation\/Dictation-91of.jpg\">*.m4v encapsulation method MPEG 4<\/a><\/li>\n<li><i>Dictation<\/i> involved opening Mac OS X Notes application and having the cursor ready at the top of a new note and then sets of pressing fn-fn (ie. function key twice &#8230; this is configurable with <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/Dictation\/Dictation-51of.jpg\">System Preferences<\/a>) to show the microphone, <a target=_blank title='Dictation on Mac via fn-fn keypresses' href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/Dictation\/Dictation-71of.jpg\">dictating your piece<\/a>, then clicking Done (remarkably this goes to an Apple server and back, but there is no big delay).<\/li>\n<\/ul>\n<p>As you view the <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/Dictation\/Dictation.m4v\" title='Click picture'>tutorial<\/a> would like to apologize if you can&#8217;t hear it clearly &#8230; figure you can divide the world into those who like to record and those who&#8217;d prefer to do this work in a dark cupboard &#8230; hope not too many elephants fall into this latter category?!   Anyway, the last point above could help clarify what was going on in the tutorial.<\/p>\n<p>This functionality can help some users who find typing at the keyboard difficult, and for those who like the kinesthetic approach of talking and thinking on their feet, perhaps.   Imagine there are many other uses, and users for these uses, out there.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d7264' onclick='var dv=document.getElementById(\"d7264\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=podcast-publisher\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d7264' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr \/>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d7379' onclick='var dv=document.getElementById(\"d7379\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=Xcode\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d7379' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Building on yesterday&#8217;s relevant Mac OS X Dictation Primer Tutorial as shown below, which addressed the Operating System view of the Dictation functionality, today we take some first steps down the road of writing an application to use this Dictation &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/xcode-cocoa-applescript-dictation-program-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,29,33,37,40],"tags":[94,157,217,327,652,676,723,852,997,1179,1180,1258,1319,1389,1473],"class_list":["post-7379","post","type-post","status-publish","format-standard","hentry","category-elearning","category-operating-system","category-software","category-tutorials","category-xcode","tag-applescript","tag-bookmarklet","tag-cocoa-framework","tag-did-you-know","tag-javascript","tag-kinesthetic","tag-mac","tag-objective-c","tag-programming","tag-speech","tag-speech-recognition","tag-text-to-speech","tag-tutorial","tag-voice-recognition","tag-xcode"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/7379"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=7379"}],"version-history":[{"count":2,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/7379\/revisions"}],"predecessor-version":[{"id":42036,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/7379\/revisions\/42036"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=7379"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=7379"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=7379"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}