{"id":126,"date":"2018-06-12T10:13:57","date_gmt":"2018-06-12T10:13:57","guid":{"rendered":"https:\/\/hegars83.wordpress.com\/?p=126"},"modified":"2018-06-20T20:27:46","modified_gmt":"2018-06-20T10:27:46","slug":"script-mac-generate-voice-and-upload","status":"publish","type":"post","link":"https:\/\/blog.hegars.com\/?p=126","title":{"rendered":"Apple mac generate voice and upload"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">#!\/bin\/bash<\/span><\/p>\n<p><span style=\"font-weight: 400;\">#<br \/>\n<\/span><span style=\"font-weight: 400;\"># to convert and upload voice prompts to asterisk using mac voice.<br \/>\n<\/span><span style=\"font-weight: 400;\">#<\/span><\/p>\n<p><span style=\"font-weight: 400;\">rate=200<br \/>\n<\/span><span style=\"font-weight: 400;\">voice=lee<br \/>\n<\/span><span style=\"font-weight: 400;\">file=$1<br \/>\n<\/span><span style=\"font-weight: 400;\">words=$2<br \/>\n<\/span><span style=\"font-weight: 400;\">extype=\/$3<\/span><\/p>\n<p><span style=\"font-weight: 400;\">user=root<br \/>\n<\/span><span style=\"font-weight: 400;\">host=192.168.81.240<br \/>\n<\/span><span style=\"font-weight: 400;\">dst=\/var\/lib\/asterisk\/sounds\/$voice$extype<br \/>\n<\/span><span style=\"font-weight: 400;\">pem=\/Users\/hegars\/ssh.pem<\/span><\/p>\n<p><strong>#define the function to process files<br \/>\n<\/strong><span style=\"font-weight: 400;\">function process {<\/span><\/p>\n<p><strong>#generate voice file<br \/>\n<\/strong><span style=\"font-weight: 400;\">say -v $voice -r $rate &#8220;$words&#8221; -o $file.wav &#8211;file-format=WAVE &#8211;data-format=LEF32@8000<\/span><\/p>\n<p><strong>#all in one?<\/strong><br \/>\n<span style=\"font-weight: 400;\">#say -v $voice -r $rate &#8220;$words&#8221; -o $file.ulaw &#8211;file-format=WAVE &#8211;data-format=ulaw@8000<\/span><\/p>\n<p><strong>#convert voice files to right format<br \/>\n<\/strong><span style=\"font-weight: 400;\">ffmpeg -i $file.wav -codec:a pcm_mulaw -f mulaw $file.ulaw -y<\/span><\/p>\n<p><strong>#copy file to server<br \/>\n<\/strong><span style=\"font-weight: 400;\">scp -i $pem $file.ulaw $user@$host:$dst<\/span><\/p>\n<p><strong>#remove temp files<br \/>\n<\/strong><span style=\"font-weight: 400;\">rm $file.wav<br \/>\n<\/span><span style=\"font-weight: 400;\">rm $file.ulaw<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><strong>#end function process<\/strong><br \/>\n}<\/span><\/p>\n<p><strong>#check to see if input from console else continue<br \/>\n<\/strong><span style=\"font-weight: 400;\">if [ &#8220;$1&#8221; = &#8220;&#8221; ]; then<br \/>\n<\/span><span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0echo nothing entered, please try again<br \/>\n<\/span>\u00a0 \u00a0 \u00a0 \u00a0exit<br \/>\n<span style=\"font-weight: 400;\">else<br \/>\n<\/span>\u00a0 \u00a0 \u00a0 \u00a0process<br \/>\n<span style=\"font-weight: 400;\">fi<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>#!\/bin\/bash # # to convert and upload voice prompts to asterisk using mac voice. # rate=200 voice=lee file=$1 words=$2 extype=\/$3 user=root host=192.168.81.240 dst=\/var\/lib\/asterisk\/sounds\/$voice$extype pem=\/Users\/hegars\/ssh.pem #define the function to process files function process { #generate voice file say -v $voice -r $rate &#8220;$words&#8221; -o $file.wav &#8211;file-format=WAVE &#8211;data-format=LEF32@8000 #all in one? #say -v $voice -r $rate &#8220;$words&#8221; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-container-style":"default","site-container-layout":"default","site-sidebar-layout":"default","disable-article-header":"default","disable-site-header":"default","disable-site-footer":"default","disable-content-area-spacing":"default","footnotes":""},"categories":[9,3],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.hegars.com\/index.php?rest_route=\/wp\/v2\/posts\/126"}],"collection":[{"href":"https:\/\/blog.hegars.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.hegars.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.hegars.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.hegars.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=126"}],"version-history":[{"count":6,"href":"https:\/\/blog.hegars.com\/index.php?rest_route=\/wp\/v2\/posts\/126\/revisions"}],"predecessor-version":[{"id":231,"href":"https:\/\/blog.hegars.com\/index.php?rest_route=\/wp\/v2\/posts\/126\/revisions\/231"}],"wp:attachment":[{"href":"https:\/\/blog.hegars.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=126"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.hegars.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=126"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.hegars.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}