h2g_ajaxchat-plugin-voicerecognition 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/h2g_ajaxchat-plugin-voicerecognition.rb +78 -0
- metadata +70 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7a6aa423ade323551eb4e34f00517b50cd464ba0514cd6a29d045359ba639ec1
|
4
|
+
data.tar.gz: 3cc106098653a7c2a3bf9e952ffb15f553dd3163957d7a0cc79ae33710f8e581
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cb0ffd83df17944526f60e35bb886d09e7a4f203ce5bf193296a31872d9fa223747ac93ae3448f3e472cba2dd82829e50fd9d55069ae0ccb861bf69e29c2fdaa
|
7
|
+
data.tar.gz: cbfb7163e55e6921e5d82005b0d23ed41aeaeef51578d2263b8b575b4bdd6cf35d29e49027bcc12d91b1dccafec1fe3c3d5cd80ec13457c77f96734e285bebf9
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
ADDED
Binary file
|
@@ -0,0 +1,78 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: h2g_ajaxchat-plugin-voicerecognition.rb
|
4
|
+
|
5
|
+
# description: Used with the h2g_ajaxchat gem to facilitate voice input to text.
|
6
|
+
|
7
|
+
|
8
|
+
class AjaxChatPluginVoiceRecognition
|
9
|
+
|
10
|
+
def initialize(settings)
|
11
|
+
@lang = settings[:lang] || 'en-GB'
|
12
|
+
end
|
13
|
+
|
14
|
+
def apply(ac)
|
15
|
+
|
16
|
+
html = ac.views[:index].html
|
17
|
+
|
18
|
+
a = html.lines
|
19
|
+
r = a.grep /<input name="usermsg"/
|
20
|
+
i = a.index(r.first)
|
21
|
+
a2 = a.insert i+1, "<button id='start-button'>Start Listening</button>\n"
|
22
|
+
ac.views[:index].html = a2.join
|
23
|
+
|
24
|
+
ac.views[:index].js = ac.views[:index].js + js()
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def js()
|
31
|
+
<<EOF
|
32
|
+
// voice recognition
|
33
|
+
|
34
|
+
function startListening() {
|
35
|
+
var recognition = new (webkitSpeechRecognition || SpeechRecognition)();
|
36
|
+
recognition.lang = '#{@lang}';
|
37
|
+
recognition.interimResults = false;
|
38
|
+
recognition.maxAlternatives = 1;
|
39
|
+
recognition.start();
|
40
|
+
|
41
|
+
[
|
42
|
+
'onaudiostart',
|
43
|
+
'onaudioend',
|
44
|
+
'onend',
|
45
|
+
'onerror',
|
46
|
+
'onnomatch',
|
47
|
+
'onresult',
|
48
|
+
'onsoundstart',
|
49
|
+
'onsoundend',
|
50
|
+
'onspeechend',
|
51
|
+
'onstart'
|
52
|
+
].forEach(function(eventName) {
|
53
|
+
recognition[eventName] = function(e) {
|
54
|
+
console.log(eventName, e);
|
55
|
+
};
|
56
|
+
});
|
57
|
+
|
58
|
+
document.querySelector('#start-button').innerHTML = 'Listening...';
|
59
|
+
|
60
|
+
recognition.onend = function() {
|
61
|
+
document.querySelector('#start-button').innerHTML = 'Start Listening';
|
62
|
+
};
|
63
|
+
recognition.onresult = function() {
|
64
|
+
e = document.querySelector('#usermsg');
|
65
|
+
e.value = event.results[0][0].transcript;
|
66
|
+
ajaxRequest('chatter?msg=' + e.value, ajaxResponse1)
|
67
|
+
e.value = '';
|
68
|
+
};
|
69
|
+
};
|
70
|
+
|
71
|
+
(function() {
|
72
|
+
document.querySelector('#start-button').addEventListener('click', startListening);
|
73
|
+
})();
|
74
|
+
|
75
|
+
EOF
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: h2g_ajaxchat-plugin-voicerecognition
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.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NVHQ4EFgQUaS6MI08t
|
26
|
+
st4Jj4zDTUz9gVLDVKEwJgYDVR0RBB8wHYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0
|
27
|
+
c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1hc3RlckBqYW1lc3JvYmVydHNvbi5ldTAN
|
28
|
+
BgkqhkiG9w0BAQsFAAOCAYEAE/6CcWjlDr2bwipSK9ep4N2zos+ja7HtqdVdDUjj
|
29
|
+
jjipfPJZwBTYtZV1Qgm5Y7ddNvMuCPzL9qnj3UlcgKLPjE3AhZkf5xfmH5e5WHS/
|
30
|
+
SaGNxuuFA1xrJiZ+rTWnuVlYe0bH2TNonXxsUhObc3JrSuRkl6tb/nJxbKWPBjhc
|
31
|
+
eCqddMlFiHuihC1V+nc5l6Iasn99z+zgZ5Uu6F5tL69obB5My8fU6Z7aFoRKk2Mx
|
32
|
+
CiG/xDt0bg5YrSY/lKeSWrszK+9UuvcF7PsFWIbUy4T3bL9qO5AAbQ8jGloHdbgB
|
33
|
+
kMZL3x8ob2n/Dycrphl3ALlz5ovTypQ+E4f/SjYYvULCp9hVaUhInbyoFbTFjUsm
|
34
|
+
+wwBIdFixG98xyKTTxA9hG/G+3HbMuxdEvx0BYFiRr0J4eZUJOnP/WeFoxTTynQZ
|
35
|
+
/WSnWC6mt27COxzkBzTYtRm/xQNCAoitCy6qKOug1jh1mFKK4X2ZIBNDJA90IUtO
|
36
|
+
qRuTqqKFZWY5IT0ROK52pCXQ
|
37
|
+
-----END CERTIFICATE-----
|
38
|
+
date: 2020-07-05 00:00:00.000000000 Z
|
39
|
+
dependencies: []
|
40
|
+
description:
|
41
|
+
email: james@jamesrobertson.eu
|
42
|
+
executables: []
|
43
|
+
extensions: []
|
44
|
+
extra_rdoc_files: []
|
45
|
+
files:
|
46
|
+
- lib/h2g_ajaxchat-plugin-voicerecognition.rb
|
47
|
+
homepage: https://github.com/jrobertson/h2g_ajaxchat-plugin-voicerecognition
|
48
|
+
licenses:
|
49
|
+
- MIT
|
50
|
+
metadata: {}
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options: []
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
requirements: []
|
66
|
+
rubygems_version: 3.0.3
|
67
|
+
signing_key:
|
68
|
+
specification_version: 4
|
69
|
+
summary: Used with the h2g_ajaxchat gem to facilitate voice input to text.
|
70
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|