{"id":6267,"date":"2022-05-18T12:49:24","date_gmt":"2022-05-18T03:49:24","guid":{"rendered":"https:\/\/www.sambuichi.jp\/?p=6267"},"modified":"2022-05-18T12:52:31","modified_gmt":"2022-05-18T03:52:31","slug":"aws-amazon-transcribe%e3%81%a7audio-identification%e3%81%8c%e4%b8%8d%e8%aa%bf%e3%81%aa%e3%81%ae%e3%81%a7%e5%80%8b%e5%88%a5%e5%87%ba%e5%8a%9b%e3%81%95%e3%82%8c%e3%81%9f%e9%9f%b3%e5%a3%b0%e3%83%95","status":"publish","type":"post","link":"https:\/\/www.sambuichi.jp\/?p=6267","title":{"rendered":"AWS Amazon Transcribe\u3067Audio identification\u304c\u4e0d\u8abf\u306a\u306e\u3067\u500b\u5225\u51fa\u529b\u3055\u308c\u305f\u97f3\u58f0\u30d5\u30a1\u30a4\u30eb\u3092\u5909\u63db"},"content":{"rendered":"<p>Views: 65<\/p><p>\u524d\u56de\u306e\u8a18\u4e8b<a href=\"https:\/\/www.sambuichi.jp\/?p=6080\"><i class=\"fa fa-external-link\" aria-hidden=\"true\"><\/i><\/a>\u3067\u7d39\u4ecb\u3057\u305fAudio identification\u3067\u306e\u8a71\u8005\u8b58\u5225\u5206\u96e2\u304c\u601d\u308f\u3057\u304f\u306a\u3044\u306e\u3067\u3001Zoom\u3067\u8a71\u8005\u5225\u306b\u8a18\u9332\u3055\u308c\u305f\u8907\u6570\u30d5\u30a1\u30a4\u30eb\u3092\u305d\u308c\u305e\u308c\u8a8d\u8b58\u3055\u305b\u3066\u30de\u30fc\u30b8\u3059\u308b\u3053\u3068\u306b\u3057\u305f\u3002<br \/>\n\u30d5\u30a1\u30a4\u30eb\u540d\u304caudioLTY-SAC41347073001.m4a\u306e\u3088\u3046\u306a\u5f62\u5f0f\u3067Audio Record\/\u306b\u8a18\u9332\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u305d\u308c\u305e\u308c\u3092\u8a8d\u8b58\u3055\u305b\u3066LYT.json\u3068\u3044\u3063\u305f\u540d\u79f0\u3067\u4fdd\u5b58\u3057\u305f\u3002<br \/>\n\u8a71\u8005\u304c\u8907\u6570\u306a\u306e\u3067\u4f8b\u3048\u3070\u3001Asd.json Zxc.json\u3068\u3044\u3063\u305f\u5f62\u3067\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u4fdd\u5b58\u3057\u3001\u6b21\u306e\u3088\u3046\u306b\u6307\u5b9a\u3057\u3066\u5b9f\u884c\u3059\u308b\u3068transcribe.txt\u30d5\u30a1\u30a4\u30eb\u3092\u51fa\u529b\u3057\u307e\u3059\u3002<\/p>\n<p> <span class=\"lang:default decode:true  crayon-inline \" >transcriptChannel.py 2022\/05-12\/Leo.json+2022\/05-12\/LTY.json+2022\/05-12\/Nobu.json+2022\/05-12\/Frans.jso<\/span> <\/p>\n<pre class=\"height-set:true width-set:true lang:python decode:true   \" >#!\/usr\/bin\/env python3\r\n# \r\n# Modified by SAMBUICHI, Nobuyuki \r\n# 2022-05-18\r\n# \r\n# original program transcript.py by AWS\r\n# \r\ndef main():\r\n\timport sys\r\n\timport json\r\n\timport datetime\r\n\timport codecs\r\n\r\n\tfilenames=sys.argv[1]\r\n\tfilenames= filenames.split('+')\r\n\tlines=[]\t\r\n\tfor filename in filenames:\r\n\t\tspeaker=filename.split('\/')[-1].split('.')[0]\r\n\t\tprint (\"Filename: \", filename)\r\n\t\twith codecs.open(filename, 'r', 'utf-8') as f:\r\n\t\t\tdata=json.loads(f.read())\r\n\t\t\titems = data['results']['items']\r\n\t\t\tline=''\r\n\t\t\ttime=0\r\n\t\t\ti=0\r\n\t\t\tfor item in items:\r\n\t\t\t\ti=i+1\r\n\t\t\t\tcontent = item['alternatives'][0]['content']\r\n\t\t\t\tif item.get('start_time'):\r\n\t\t\t\t\tcurrent_time=float(item['start_time'])\r\n\t\t\t\telif item['type'] == 'punctuation':\r\n\t\t\t\t\tline = line+content\r\n\t\t\t\tif current_time &gt; time+120:\r\n\t\t\t\t\tif speaker:\r\n\t\t\t\t\t\tlines.append({'speaker':speaker,'line':line, 'time':time})\r\n\t\t\t\t\tline=content\r\n\t\t\t\t\ttime=current_time\r\n\t\t\t\telif item['type'] != 'punctuation':\r\n\t\t\t\t\tline = line + ' ' + content\r\n\t\t\tlines.append({'speaker':speaker,'line':line,'time':time})\r\n\tsorted_lines = sorted(lines,key=lambda k: float(k['time']))\r\n\twith codecs.open('\/'.join(filename.split('\/')[:-1])+'\/transcribe.txt', 'w', 'utf-8') as w:\r\n\t\tfor line_data in sorted_lines:\r\n\t\t\tline='[' + str(datetime.timedelta(seconds=int(round(float(line_data['time']))))) + '] ' + line_data['speaker'] + ': ' + line_data.get('line')\r\n\t\t\tw.write(line + '\\n\\n')\r\n\r\n\r\nif __name__ == '__main__':\r\n\tmain()\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Views: 65\u524d\u56de\u306e\u8a18\u4e8b\u3067\u7d39\u4ecb\u3057\u305fAudio identification\u3067\u306e\u8a71\u8005\u8b58\u5225\u5206\u96e2\u304c\u601d\u308f\u3057\u304f\u306a\u3044\u306e\u3067\u3001Zoom\u3067\u8a71\u8005\u5225\u306b\u8a18\u9332\u3055\u308c\u305f\u8907\u6570\u30d5\u30a1\u30a4\u30eb\u3092\u305d\u308c\u305e\u308c\u8a8d\u8b58\u3055\u305b\u3066\u30de\u30fc\u30b8\u3059\u308b\u3053\u3068\u306b\u3057\u305f\u3002 \u30d5\u30a1\u30a4\u30eb\u540d\u304caudio [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":6268,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[20,50,11],"tags":[],"_links":{"self":[{"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=\/wp\/v2\/posts\/6267"}],"collection":[{"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6267"}],"version-history":[{"count":3,"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=\/wp\/v2\/posts\/6267\/revisions"}],"predecessor-version":[{"id":6272,"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=\/wp\/v2\/posts\/6267\/revisions\/6272"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=\/wp\/v2\/media\/6268"}],"wp:attachment":[{"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6267"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6267"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6267"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}