{"id":74,"date":"2022-10-06T22:47:52","date_gmt":"2022-10-06T22:47:52","guid":{"rendered":"https:\/\/engprojects.tcnj.edu\/rover-rescue\/?p=74"},"modified":"2022-10-06T22:49:19","modified_gmt":"2022-10-06T22:49:19","slug":"project-update-5-python-script-running-wav-file","status":"publish","type":"post","link":"https:\/\/engprojects.tcnj.edu\/rover-rescue\/2022\/10\/06\/project-update-5-python-script-running-wav-file\/","title":{"rendered":"Project Update 5: Python script running .wav file"},"content":{"rendered":"\n<p>The team was able to succesfully use the PyAudio python library in order to play a .wav file out loud. The reason this is important is because the group wants the rover to have some sort of feedback, whether that be auditory, visual, or preferably both. This python script enables the group to provide auditory feedback to persons in the vicinity of the rover. Here is a link to the PyAudio API documentation: https:\/\/people.csail.mit.edu\/hubert\/pyaudio\/<\/p>\n\n\n\n<p>Below shows the audio file called &#8220;test2.wav&#8221; as well as the python code used to play it out loud. <\/p>\n\n\n\n<figure class=\"wp-block-audio\"><audio controls src=\"https:\/\/engprojects.tcnj.edu\/rover-rescue\/wp-content\/uploads\/sites\/223\/2022\/10\/test2.wav\"><\/audio><figcaption>test2.wav<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">PyAudio Python code<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#!usr\/bin\/env python  \n#coding=utf-8  \n\nimport pyaudio  \nimport wave  \n\n#define stream chunk   \nchunk = 1024  \n\n#open a wav format music  \nf = wave.open(\"test2.wav\",\"rb\")  \n#instantiate PyAudio  \np = pyaudio.PyAudio()  \n#open stream  \nstream = p.open(format = p.get_format_from_width(f.getsampwidth()),  \n                channels = f.getnchannels(),  \n                rate = f.getframerate(),  \n                output = True)  \n#read data  \ndata = f.readframes(chunk)  \n\n#play stream  \nwhile data:  \n    stream.write(data)  \n    data = f.readframes(chunk)  \n\n#stop stream  \nstream.stop_stream()  \nstream.close()  \n\n#close PyAudio  \np.terminate() \n\n\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The team was able to succesfully use the PyAudio python library in order to play a .wav file out loud. The reason this is important is because the group wants the rover to have some sort of feedback, whether that be auditory, visual, or preferably both. This python script enables the group to provide auditory &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/engprojects.tcnj.edu\/rover-rescue\/2022\/10\/06\/project-update-5-python-script-running-wav-file\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Project Update 5: Python script running .wav file&#8221;<\/span><\/a><\/p>\n","protected":false},"author":438,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-74","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/engprojects.tcnj.edu\/rover-rescue\/wp-json\/wp\/v2\/posts\/74","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/engprojects.tcnj.edu\/rover-rescue\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/engprojects.tcnj.edu\/rover-rescue\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/engprojects.tcnj.edu\/rover-rescue\/wp-json\/wp\/v2\/users\/438"}],"replies":[{"embeddable":true,"href":"https:\/\/engprojects.tcnj.edu\/rover-rescue\/wp-json\/wp\/v2\/comments?post=74"}],"version-history":[{"count":0,"href":"https:\/\/engprojects.tcnj.edu\/rover-rescue\/wp-json\/wp\/v2\/posts\/74\/revisions"}],"wp:attachment":[{"href":"https:\/\/engprojects.tcnj.edu\/rover-rescue\/wp-json\/wp\/v2\/media?parent=74"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/engprojects.tcnj.edu\/rover-rescue\/wp-json\/wp\/v2\/categories?post=74"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/engprojects.tcnj.edu\/rover-rescue\/wp-json\/wp\/v2\/tags?post=74"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}