{"id":188,"date":"2017-05-04T08:50:21","date_gmt":"2017-05-04T08:50:21","guid":{"rendered":"https:\/\/candicemorey.org\/?p=188"},"modified":"2017-05-04T20:01:09","modified_gmt":"2017-05-04T20:01:09","slug":"use-mac-os-to-generate-speech-files-from-text","status":"publish","type":"post","link":"https:\/\/www.candicemorey.org\/?p=188","title":{"rendered":"Use Mac OS to generate speech files from text"},"content":{"rendered":"<p>Here&#8217;s a free (if you&#8217;ve got access to a Mac), quick\u00a0method for creating spoken experimental stimuli, which I&#8217;ve implemented in this <a href=\"https:\/\/osf.io\/s6w4b\/\">project<\/a>\u00a0and now use regularly in my lab. Hat tip to <a href=\"https:\/\/medium.com\/@richarddmorey\">Richard Morey<\/a> for suggesting this and writing a few lines of code that saves many hours of tedious voice recording.<\/p>\n<ol>\n<li>Create a plain text file with the texts\u00a0you want to create .wavs for entered on separate lines. Line break after each word or phrase that you want to generate a sound file for. Name your text file &#8220;words.txt&#8221;. It should look something like this one we recently used to generate audio files for a digit span task:\u00a0<a href=\"https:\/\/candicemorey.org\/wp-content\/uploads\/2017\/05\/Screen-Shot-2017-05-04-at-9.35.13-AM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-191 alignright\" src=\"https:\/\/candicemorey.org\/wp-content\/uploads\/2017\/05\/Screen-Shot-2017-05-04-at-9.35.13-AM-300x194.png\" alt=\"\" width=\"300\" height=\"194\" srcset=\"https:\/\/www.candicemorey.org\/wp-content\/uploads\/2017\/05\/Screen-Shot-2017-05-04-at-9.35.13-AM-300x194.png 300w, https:\/\/www.candicemorey.org\/wp-content\/uploads\/2017\/05\/Screen-Shot-2017-05-04-at-9.35.13-AM.png 648w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/li>\n<li>Open iTerm, and navigate to the folder where your &#8220;words.txt&#8221; file is located. Here&#8217;s a lesson on <a href=\"http:\/\/linuxcommand.org\/lc3_lts0020.php\">how to<\/a> navigate via command line. TLDR: the &#8220;cd&#8221; (current directory) command is what you need. cd .. will move you to the directory one above where you are. The &#8220;ls&#8221; command lists the folders in the current directory.<\/li>\n<li>Type\u00a0the following into iTerm:<\/li>\n<\/ol>\n<p><a href=\"https:\/\/candicemorey.org\/wp-content\/uploads\/2017\/05\/Screen-Shot-2017-05-04-at-9.35.25-AM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-190 aligncenter\" src=\"https:\/\/candicemorey.org\/wp-content\/uploads\/2017\/05\/Screen-Shot-2017-05-04-at-9.35.25-AM-300x194.png\" alt=\"\" width=\"300\" height=\"194\" srcset=\"https:\/\/www.candicemorey.org\/wp-content\/uploads\/2017\/05\/Screen-Shot-2017-05-04-at-9.35.25-AM-300x194.png 300w, https:\/\/www.candicemorey.org\/wp-content\/uploads\/2017\/05\/Screen-Shot-2017-05-04-at-9.35.25-AM.png 642w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>In a few seconds, the directory containing &#8220;words.txt&#8221; will also include a .wav file for each entry from &#8220;words.txt&#8221;.<\/p>\n<p>This code uses the MacOS voice &#8220;Kate&#8221; (a female voice with a British accent). You can replace &#8220;Kate&#8221; with any voice available on your system by removing &#8220;Kate&#8221; from the code and typing your preferred voice instead.<\/p>\n<p>Text-to-speech isn&#8217;t \u00a0perfect. You want to check that your .wav files sound like the text you meant for them to sound like. Different voices sometimes pronounce the text in different ways, so one solution to weird-sounding speech is to try another voice. You can also try alternative spellings to get the right pronunciation.<\/p>\n","protected":false},"excerpt":{"rendered":"Here&#8217;s a free (if you&#8217;ve got access to a Mac), quick\u00a0method for creating spoken experimental stimuli, which I&#8217;ve implemented in this project\u00a0and now use regularly in my lab. Hat tip to Richard Morey for suggesting this and writing a few lines of code that saves many hours of tedious voice&hellip;\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-188","post","type-post","status-publish","format-standard","hentry","category-measurement","odd"],"_links":{"self":[{"href":"https:\/\/www.candicemorey.org\/index.php?rest_route=\/wp\/v2\/posts\/188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.candicemorey.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.candicemorey.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.candicemorey.org\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.candicemorey.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=188"}],"version-history":[{"count":12,"href":"https:\/\/www.candicemorey.org\/index.php?rest_route=\/wp\/v2\/posts\/188\/revisions"}],"predecessor-version":[{"id":202,"href":"https:\/\/www.candicemorey.org\/index.php?rest_route=\/wp\/v2\/posts\/188\/revisions\/202"}],"wp:attachment":[{"href":"https:\/\/www.candicemorey.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.candicemorey.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.candicemorey.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}