voicetotext 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e03f2ede17f76b3891c592d1510d619d1ee9e085
4
+ data.tar.gz: dd9048b2dc009838df4c79daef2977e745894f71
5
+ SHA512:
6
+ metadata.gz: 02558a2372cc8ca13ffdda389308f50c9bb3396317988b8eb25facc81910210527e3b9d86dc21f5a1c6cb56917cd905c7a0edc2261b14337245e9b474233bcbd
7
+ data.tar.gz: 9e4ab45a5feb06b4d43cdcf2591021297ce0b962e873227bf2c158ab1a2b369f4e31932d336176e5bb21995999d6bbc41fd4d7e50f59ee0081af3abb39b062d8
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in voicetotext.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Sudarshan Dhokale
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # VoiceToText
2
+
3
+ Convert voice into text!
4
+
5
+ The new gem 'voicetotext' makes it easy to add voice recognition to your web pages. This gem allows fine control and flexibility over the voice recognition capabilities in Chrome version 25 and later.
6
+
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'voicetotext'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install voicetotext
23
+
24
+ ## Usage
25
+
26
+ Add this line to app/assets/javascripts/application.js
27
+
28
+ //= require voicetotext
29
+
30
+
31
+ Add this code on your desired html.erb pages of your application
32
+
33
+ <h3>Convert Voice into Text</h3>
34
+ <p id="info"></p>
35
+ <p><%= button_tag 'Start',id: "start_button", onclick: "startButton(event)"%></p>
36
+ <p><%= text_area_tag :final_span, nil, rows: 10, cols: 50 %></p>
37
+
38
+
39
+ ## Contributing
40
+
41
+ 1. Fork it
42
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
43
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
44
+ 4. Push to the branch (`git push origin my-new-feature`)
45
+ 5. Create a new Pull Request
46
+
47
+
48
+ ## License
49
+
50
+ Copyright (c) 2014 Sudarshan Dhokale
51
+
52
+ MIT License
53
+
54
+ Permission is hereby granted, free of charge, to any person obtaining
55
+ a copy of this software and associated documentation files (the
56
+ "Software"), to deal in the Software without restriction, including
57
+ without limitation the rights to use, copy, modify, merge, publish,
58
+ distribute, sublicense, and/or sell copies of the Software, and to
59
+ permit persons to whom the Software is furnished to do so, subject to
60
+ the following conditions:
61
+
62
+ The above copyright notice and this permission notice shall be
63
+ included in all copies or substantial portions of the Software.
64
+
65
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
66
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
67
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
68
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
69
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
70
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
71
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,15 @@
1
+ (function(){
2
+ var f=this;function g(a,c){var b=a.split("."),d=f;b[0]in d||!d.execScript||d.execScript("var "+b[0]);for(var e;b.length&&(e=b.shift());)b.length||void 0===c?d=d[e]?d[e]:d[e]={}:d[e]=c}function h(a,c,b){return a.call.apply(a.bind,arguments)}
3
+ function l(a,c,b){if(!a)throw Error();if(2<arguments.length){var d=Array.prototype.slice.call(arguments,2);return function(){var b=Array.prototype.slice.call(arguments);Array.prototype.unshift.apply(b,d);return a.apply(c,b)}}return function(){return a.apply(c,arguments)}}function m(a,c,b){m=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?h:l;return m.apply(null,arguments)}
4
+ Function.prototype.bind=Function.prototype.bind||function(a,c){if(1<arguments.length){var b=Array.prototype.slice.call(arguments,1);b.unshift(this,a);return m.apply(null,b)}return m(this,a)};function n(a){this.a=a||{};this.pathname=window.location.pathname;window._gaq=window._gaq||[];this.h=!0;if(!1===this.a.tracklinks||!1===this.a.trackClicks)this.h=!1;this.a.trackQueryParams&&(this.n=!0);this.m=void 0===this.a.adsDbCompatible?!0:this.a.adsDbCompatible;this.c=this.a.tracker?this.a.tracker+".":"";this.g=this.a.cookiePath||/^([^;,]*\/)/.exec(this.pathname)[0];this.e=this.a.cookiePathCopy||[];this.prefix=this.a.prefix||"";this.j=this.a.defaultEventName;this.i=this.a.defaultAction;this.k=
5
+ this.a.defaultLabel;this.b([this.c+"_setAccount",this.a.profile]);this.b([this.c+"_setCookiePath",this.g]);this.a.domainName&&this.b([this.c+"_setDomainName",this.a.domainName]);this.b([this.c+"_setAllowAnchor",!0]);this.m&&(window.location.hash||window.location.search)&&(a=window.location.href,this.b([this.c+"_setCampIdKey","cid"]),-1==a.indexOf("utm_campaign=")&&this.b([this.c+"_setCampNameKey","sourceid"]),-1==a.indexOf("utm_medium=")&&this.b([this.c+"_setCampMediumKey","medium"]),-1==a.indexOf("utm_source=")&&
6
+ this.b([this.c+"_setCampSourceKey","subid"]),-1==a.indexOf("utm_term=")&&this.b([this.c+"_setCampTermKey","term"]),-1==a.indexOf("utm_content=")&&this.b([this.c+"_setCampContentKey","content"]));var c=this.a.commands;if(c){a=0;for(var b;b=c[a];a++)b[0]=b[0]&&this.c+b[0],this.b(b)}if(this.e)for(a=0,c=this.e.length;a<c;a++)0>this.g.indexOf(this.e[a])&&this.b([this.c+"_cookiePathCopy",this.e[a]]);this.a.disableTrackPageview||(a=this.a.pageviewPath,a||(a=this.prefix+this.pathname,this.n&&(a+=window.location.search)),
7
+ this.b([this.c+"_trackPageview",a]));window._gat||(a=document.createElement("script"),a.type="text/javascript",a.async=!0,a.src=("https:"==document.location.protocol?"https://ssl":"http://www")+".google-analytics.com/ga.js",c=document.getElementsByTagName("script")[0],c.parentNode.insertBefore(a,c));p(this,this.l,this);this.a.trackUnload&&q(window,"unload",this.o,this);(this.d=this.a.trackEventCallback)&&"function"!==typeof this.d&&(this.d=void 0);r=!0}var r=!1;
8
+ n.prototype.l=function(){this.h&&s(this);this.a.heatMapper&&t(this)};n.prototype.o=function(){this.f("AutoTrack: Navigation","Unload",window.location.href)};
9
+ function s(a){q(document.body,"click",function(a){a=a||window.event;a=a.target||a.srcElement;a=3==a.nodeType?a.parentNode:a;do{var b=a;if(Boolean("a"==b.nodeName.toLowerCase()||b.getAttribute("data-g-event")||b.getAttribute("data-g-action")||b.getAttribute("data-g-label"))){var b=u(this,"eventname",a),d=u(this,"action",a),e=u(this,"label",a);this.f(b,d,e)}a.parentNode&&(a=a.parentNode)}while(a.parentNode)},a)}
10
+ function t(a){q(document.body,"click",function(a){this.f("AutoTrack: Heatmap","Click",a.clientX+","+a.clientY)},a)}n.prototype.f=function(a,c,b){this.prefix&&(b=this.prefix+b);this.b([this.c+"_trackEvent",a,c,b]);this.d&&this.d(a,c,b)};
11
+ function u(a,c,b){function d(a){return"string"==typeof a?a:"function"==typeof a?a(b):""}return"eventname"==c?b.getAttribute("data-g-event")||d(a.j)||("a"==b.tagName.toLowerCase()?b.hostname==window.location.hostname?"AutoTrack: Link Click":"AutoTrack: Outbound Click":"AutoTrack: Element Click"):"action"==c?b.getAttribute("data-g-action")||d(a.i)||b.getAttribute("href")||"AutoTrack: Element Click":"label"==c?b.getAttribute("data-g-label")||d(a.k)||a.pathname:""}
12
+ function q(a,c,b,d){d&&(b=m(b,d));a.addEventListener?a.addEventListener(c,b,!1):a.attachEvent&&a.attachEvent("on"+c,b)}
13
+ function p(a,c,b){b&&(c=m(c,b));if(document.addEventListener)try{q(document,"DOMContentLoaded",c,a)}catch(d){q(window,"load",c,a)}else if(!document.uniqueID&&document.expando)var e=document.createElement("tempnode"),k=window.setInterval(function(){try{e.doScroll("left")}catch(a){return}window.clearInterval(k);k=e=null;b&&(c=m(c,b));c()},50);else"readyState"in document?k=window.setInterval(function(){/loaded|complete/.test(document.readyState)&&(window.clearInterval(k),k=null,b&&(c=m(c,b)),c())},50):
14
+ q(window,"load",c,a)}n.prototype.b=function(a){a instanceof Array&&window._gaq.push(a)};g("gweb.analytics.AutoTrack",n);n.prototype.trackEvent=n.prototype.f;n.prototype.pushCommand=n.prototype.b;g("gweb.analytics.AutoTrack.hasInstance",function(){return r});
15
+ })()
@@ -0,0 +1,119 @@
1
+ var final_transcript = '';
2
+ var recognizing = false;
3
+ var ignore_onend;
4
+ var start_timestamp;
5
+ var info_start = 'Click on the start button and begin speaking for as long as you like.';
6
+ var info_speak_now = 'Speak now.';
7
+ var info_no_speech = 'No speech was detected. You may need to adjust your microphone settings.';
8
+ var info_no_microphone = 'No microphone was found. Ensure that a microphone is installed and that microphone settings are configured correctly.';
9
+ var info_allow = 'Click the "Allow" button above to enable your microphone.';
10
+ var info_denied = 'Permission to use microphone was denied.';
11
+ var info_blocked = 'Permission to use microphone is blocked. To change, go to chrome://settings/contentExceptions#media-stream';
12
+ var info_upgrade = 'Not supported by this browser. Upgrade to Chrome version 25 or later.';
13
+
14
+ if (!('webkitSpeechRecognition' in window)) {
15
+ upgrade();
16
+ } else {
17
+ supported();
18
+ var recognition = new webkitSpeechRecognition();
19
+ recognition.continuous = true;
20
+ recognition.interimResults = true;
21
+
22
+ recognition.onstart = function() {
23
+ start_button.innerHTML = 'Stop';
24
+ recognizing = true;
25
+ info.innerHTML = info_speak_now;
26
+ };
27
+
28
+ recognition.onerror = function(event) {
29
+ if (event.error == 'no-speech') {
30
+ info.innerHTML = info_no_speech;
31
+ ignore_onend = true;
32
+ }
33
+ if (event.error == 'audio-capture') {
34
+ info.innerHTML = info_no_microphone;
35
+ ignore_onend = true;
36
+ }
37
+ if (event.error == 'not-allowed') {
38
+ if (event.timeStamp - start_timestamp < 100) {
39
+ info.innerHTML = info_blocked;
40
+ } else {
41
+ info.innerHTML = info_denied;
42
+ }
43
+ ignore_onend = true;
44
+ }
45
+ };
46
+
47
+ recognition.onend = function() {
48
+ start_button.innerHTML = 'Start';
49
+ info.innerHTML = info_start;
50
+ recognizing = false;
51
+ if (ignore_onend) {
52
+ return;
53
+ }
54
+ if (!final_transcript) {
55
+ info.innerHTML = info_start;
56
+ return;
57
+ }
58
+ if (window.getSelection) {
59
+ window.getSelection().removeAllRanges();
60
+ var range = document.createRange();
61
+ range.selectNode(document.getElementById('final_span'));
62
+ window.getSelection().addRange(range);
63
+ }
64
+ };
65
+
66
+ recognition.onresult = function(event) {
67
+ if (typeof(event.results) == 'undefined') {
68
+ recognition.onend = null;
69
+ recognition.stop();
70
+ upgrade();
71
+ return;
72
+ }
73
+ for (var i = event.resultIndex; i < event.results.length; ++i) {
74
+ if (event.results[i].isFinal) {
75
+ final_transcript += event.results[i][0].transcript;
76
+ }
77
+ }
78
+ final_transcript = capitalize(final_transcript);
79
+ final_span.innerHTML = linebreak(final_transcript);
80
+ };
81
+ }
82
+
83
+ function supported(){
84
+ $(document).ready(function(){
85
+ info.innerHTML = info_start;
86
+ });
87
+ }
88
+
89
+ function upgrade() {
90
+ $(document).ready(function(){
91
+ start_button.style.visibility = 'hidden'
92
+ info.innerHTML = info_upgrade;
93
+ });
94
+ }
95
+
96
+ var two_line = /\n\n/g;
97
+ var one_line = /\n/g;
98
+ function linebreak(s) {
99
+ return s.replace(two_line, '<p></p>').replace(one_line, '<br>');
100
+ }
101
+
102
+ var first_char = /\S/;
103
+ function capitalize(s) {
104
+ return s.replace(first_char, function(m) { return m.toUpperCase(); });
105
+ }
106
+
107
+ function startButton(event) {
108
+ if (recognizing) {
109
+ recognition.stop();
110
+ return;
111
+ }
112
+ final_transcript = '';
113
+ recognition.lang = 'en';
114
+ recognition.start();
115
+ ignore_onend = false;
116
+ final_span.innerHTML = '';
117
+ info.innerHTML = info_allow;
118
+ start_timestamp = event.timeStamp;
119
+ }
@@ -0,0 +1 @@
1
+ //= require_tree .
@@ -0,0 +1,5 @@
1
+ require 'voicetotext/version'
2
+ require 'voicetotext/engine'
3
+
4
+ module Voicetotext
5
+ end
@@ -0,0 +1,4 @@
1
+ module Voicetotext
2
+ class Engine < Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module Voicetotext
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'voicetotext/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "voicetotext"
8
+ spec.version = Voicetotext::VERSION
9
+ spec.date = %q{2014-12-31}
10
+ spec.authors = ["Sudarshan Dhokale"]
11
+ spec.email = ["sudarshandhokale09@gmail.com"]
12
+ spec.summary = %q{Convert voice into text}
13
+ spec.description = %q{Convert voice into text with high interpretation}
14
+ spec.homepage = "https://github.com/sudarshandhokale/voicetotext"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.7"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: voicetotext
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sudarshan Dhokale
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Convert voice into text with high interpretation
42
+ email:
43
+ - sudarshandhokale09@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - app/assets/javascripts/autotrack.js
54
+ - app/assets/javascripts/voice_to_text.js
55
+ - app/assets/javascripts/voicetotext.js
56
+ - lib/voicetotext.rb
57
+ - lib/voicetotext/engine.rb
58
+ - lib/voicetotext/version.rb
59
+ - voicetotext.gemspec
60
+ homepage: https://github.com/sudarshandhokale/voicetotext
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.4.5
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Convert voice into text
84
+ test_files: []