{"id":2555,"date":"2022-10-06T23:46:45","date_gmt":"2022-10-06T14:46:45","guid":{"rendered":"https:\/\/uda2.com\/blog\/?p=2555"},"modified":"2023-07-07T16:22:40","modified_gmt":"2023-07-07T07:22:40","slug":"speechme","status":"publish","type":"post","link":"https:\/\/uda2.com\/blog\/speechme\/","title":{"rendered":"WEB\u3067\u97f3\u58f0\u64cd\u4f5c"},"content":{"rendered":"\n<p>\u6614\u3001\u300c\u3057\u3083\u3079\u308b\uff01DS\u304a\u6599\u7406\u30ca\u30d3\u300d\u3068\u3044\u3046\u30b2\u30fc\u30e0\u304c\u3042\u3063\u3066\u8abf\u7406\u4e2d\u3067\u3082\u97f3\u58f0\u3067\u30ec\u30b7\u30d4\u306e\u624b\u9806\u3092\u9032\u3081\u308b\u4e8b\u304c\u51fa\u6765\u305f\u3002<br>\u4eca\u3084DS\u306f\u4f7f\u308f\u306a\u3044\u3051\u3069iPad\u3068\u304b\u3067\u97f3\u58f0\u64cd\u4f5c\u3067\u304d\u308b\u30d6\u30e9\u30a6\u30b6\u304c\u3042\u3063\u305f\u3089\u4fbf\u5229\u304b\u3082\u3068\u691c\u7d22\u3057\u305f\u3089\u300c<a href=\"https:\/\/developer.mozilla.org\/ja\/docs\/Web\/API\/SpeechRecognition\" target=\"_blank\" rel=\"noopener\">Speech Recognition API<\/a>\u300d\u3068\u3044\u3046JavaScript\u306eAPI\u304c\u898b\u3064\u304b\u3063\u305f\u306e\u3067\u8a66\u3057\u3066\u898b\u308b\u3053\u3068\u306b\u3057\u305f\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>\u300cSpeech Recognition API\u300d\u306f\u6614\u306f\u9650\u3089\u308c\u305f\u74b0\u5883\u3067\u3057\u304b\u5229\u7528\u3067\u304d\u306a\u304b\u3063\u305f\u3088\u3046\u3067\u3059\u304c\u6700\u8fd1\u306fiOS\u3067\u3082\u4f7f\u3048\u308b\u307f\u305f\u3044\u306a\u306e\u3067\u8a66\u3057\u3066\u898b\u307e\u3057\u305f\u3002<br><a href=\"https:\/\/uda2.com\/speechme\/\">https:\/\/uda2.com\/speechme\/<\/a><br>\u53f3\u4e0a\u306e\u30de\u30a4\u30af\u30dc\u30bf\u30f3\uff08\u97f3\u58f0\u64cd\u4f5cSTART\uff09\u3092\u62bc\u3059\u3068\u97f3\u58f0\u64cd\u4f5c\u304c\u958b\u59cb\u3057\u307e\u3059\u3002\uff08\u975e\u5bfe\u5fdc\u306a\u30d6\u30e9\u30a6\u30b6\u3067\u306f\u30dc\u30bf\u30f3\u304c\u73fe\u308c\u307e\u305b\u3093\u3002\uff09<br>\u300c\u6b21\u3078\u300d\u3067\u6b21\u306e\u30b9\u30c6\u30c3\u30d7\u306b\u9032\u3093\u3067\u300c\u623b\u308b\u300d\u3067\u524d\u306e\u30b9\u30c6\u30c3\u30d7\u306b\u623b\u3063\u3066\u300c\u7d42\u4e86\u300d\u3067\u97f3\u58f0\u8a8d\u8b58\u3092\u7d42\u4e86\u3057\u307e\u3059\u3002<br>recognition.interimResults\u3092true\u306b\u3059\u308b\u4e8b\u3067\u805e\u304d\u306a\u304c\u3089\u97f3\u58f0\u89e3\u8aad\u3059\u308b\u306e\u3067\u53cd\u5fdc\u304c\u65e9\u304f\u306a\u308a\u307e\u3059\u3002<br>result\u30a4\u30d9\u30f3\u30c8\uff08\u97f3\u58f0\u304c\u78ba\u8a8d\u3067\u304d\u305f\u3089\uff09\u306e\u6700\u5f8c\u306b\u6bce\u5ea6\u505c\u6b62\u518d\u958b\u3092\u3057\u3066\u308b\u306e\u306f\u30b3\u30de\u30f3\u30c9\u304c\u77ed\u3044\u306e\u306b\u300c\u307e\u3060\u4f55\u304b\u8a00\u3046\u304b\u3082\u300d\u3068\u5f85\u6a5f\u3059\u308b\u306e\u3092\u6291\u6b62\u3059\u308b\u70ba\u3067\u3059\u3002<br>\u4e0a\u306e\u65b9\u6cd5\u3067\u6c38\u7d9a\u5316\u306f\u3055\u308c\u3066\u308b\u306e\u3067\u3059\u304c\u30b9\u30bf\u30fc\u30c8\u3057\u3066\u304b\u30895\u5206\u9593\u3068\u4efb\u610f\u3067\u30b9\u30c8\u30c3\u30d7\u3059\u308b\u307e\u3067\u6c38\u7d9a\u5316\u3057\u305f\u304b\u3063\u305f\u306e\u3067\u30bf\u30a4\u30de\u30fc\u3092\u4ed5\u639b\u3051\u3066\u72b6\u614b\u3092\u7dad\u6301\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<br>\u4ed6\u306b\u8aa4\u8a8d\u8b58\u3092\u8003\u616e\u3057\u3066\u30ef\u30fc\u30c9\u3092\u30bb\u30ec\u30af\u30c8\u3057\u3066\u3044\u307e\u3059\u3002<br>\u300c\u623b\u308b\u300d\u306f\u4f55\u5ea6\u304b\u300c\u672c\u300d\u300c\u5a46\u300d\u300c\u4fdd\u5b58\u300d\u3068\u8b0e\u306a\u8aa4\u8a8d\u8b58\u3092\u3055\u308c\u305f\u306e\u3067\u5165\u308c\u3066\u307e\u3059\u3002<\/p>\n\n\n\n<pre><code>var speechme = () => {\n  const recbtnObj = document.getElementById('recbtn');\n  const recognition = new webkitSpeechRecognition() || new SpeechRecognition();\n  if (typeof recognition === 'undefined') return;\n  recbtnObj.style.display = \"block\";\n  var recognizing = false;\n  var rectime = 0;\n  recognition.interimResults = true;\n  recognition.maxAlternatives = 10;\n  recognition.addEventListener('result', function(event) {\n    const results = event.results;\n    let strs = [];\n    let command = \"\";\n    paragraph: for (let i = event.resultIndex; i < results.length; i++) {\/\/\u6587\u7bc0\uff08\u4eca\u56de\u306f0\u3060\u3051\uff09\n      for (let j = 0; j < results[i].length; j++){\/\/\u5019\u88dc\n        const result = results[i][j].transcript;\n        if (results[i].isFinal) {\n          recognition.stop();\n          recognizing = false;\n        }\n        strs.push({c: results[i][j].confidence, s: result});\n        if (result == \"\u30b9\u30c8\u30c3\u30d7\" || result == \"\u6b62\u3081\u3066\" || result == \"\u505c\u6b62\" || result == \"\u7d42\u4e86\") command = \"stop\";\n        if (result == \"\u6b21\u3078\" || result == \"\u6b21\" || result == \"\u6708\" || result == \"\u9032\u3080\" || result == \"\u9032\u3093\u3067\" || result == \"\u305d\u3093\u3067\" || result == \"\u305d\u3057\u3066\" || result == \"\u305d\u308c\u304b\u3089\" || result == \"\u30aa\u30c3\u30b1\u30fc\") command = \"next\";\n        if (result == \"\u623b\u308b\" || result == \"\u672c\" || result == \"\u5a46\" || result == \"\u4fdd\u5b58\" || result == \"\u623b\u3063\u3066\" || result == \"\u30d0\u30c3\u30af\") command = \"back\";\n        if (command != \"\") break paragraph;\n      }\n    }\n    if (command == \"stop\") return recStop();\n    if (command == \"next\") stepxstep(1);\n    if (command == \"back\") stepxstep(-1);\n    \/\/console.log(JSON.stringify(strs));\n    document.getElementById('debug').innerText = JSON.stringify(strs);\n    recognition.stop();\n    recognition.start();\n  });\n  recbtnObj.addEventListener('click', () => {\n    if (recbtn.textContent == 'START') {\n      rectime = Date.now(); \n      recStart();\n    } else {\n      recStop();\n    }\n  });\n  recognition.addEventListener('start', () => {\n    recbtnObj.className = \"online\";\n  });\n  recognition.addEventListener('end', () => {\n    recbtnObj.className = \"offline\";\n    recognizing = false;\n  });\n  function recStop() {\n    recognition.stop();\n    recognizing = false;\n    recbtn.textContent = 'START';\n  }\n  function recStart() {\n    recognition.start();\n    recognizing = true;\n    recbtn.textContent = 'STOP';\n  }\n  setInterval(() => {\n    if (recbtn.textContent == 'STOP' && recognizing === false) {\/\/\u9332\u97f3\u72b6\u614b\u306a\u306e\u306bAPI\u505c\u6b62\n      const mysec = Math.floor((Date.now() - rectime) \/ 1000);\n      if (mysec < 60*5) {\n        recognition.start();\n        recognizing = true;\n      } else {\n        recStop();\n      }\n    }\n  }, 1000);\n};\nspeechme();\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6614\u3001\u300c\u3057\u3083\u3079\u308b\uff01DS\u304a\u6599\u7406\u30ca\u30d3\u300d\u3068\u3044\u3046\u30b2\u30fc\u30e0\u304c\u3042\u3063\u3066\u8abf\u7406\u4e2d\u3067\u3082\u97f3\u58f0\u3067\u30ec\u30b7\u30d4\u306e\u624b\u9806\u3092\u9032\u3081\u308b\u4e8b\u304c\u51fa\u6765\u305f\u3002\u4eca\u3084DS\u306f\u4f7f\u308f\u306a\u3044\u3051\u3069iPad\u3068\u304b\u3067\u97f3\u58f0\u64cd\u4f5c\u3067\u304d\u308b\u30d6\u30e9\u30a6\u30b6\u304c\u3042\u3063\u305f\u3089\u4fbf\u5229\u304b\u3082\u3068\u691c\u7d22\u3057\u305f\u3089\u300cSpeech Recognit<\/p>\n","protected":false},"author":2,"featured_media":2557,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[205],"tags":[66,366],"class_list":["post-2555","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-creatorsdiary","tag-javascript","tag-speech-recognition-api"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/uda2.com\/blog\/wp-json\/wp\/v2\/posts\/2555","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/uda2.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/uda2.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/uda2.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/uda2.com\/blog\/wp-json\/wp\/v2\/comments?post=2555"}],"version-history":[{"count":8,"href":"https:\/\/uda2.com\/blog\/wp-json\/wp\/v2\/posts\/2555\/revisions"}],"predecessor-version":[{"id":2565,"href":"https:\/\/uda2.com\/blog\/wp-json\/wp\/v2\/posts\/2555\/revisions\/2565"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/uda2.com\/blog\/wp-json\/wp\/v2\/media\/2557"}],"wp:attachment":[{"href":"https:\/\/uda2.com\/blog\/wp-json\/wp\/v2\/media?parent=2555"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/uda2.com\/blog\/wp-json\/wp\/v2\/categories?post=2555"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/uda2.com\/blog\/wp-json\/wp\/v2\/tags?post=2555"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}