convertvoicetotext 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.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in convertvoicetotext.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) Axenic Technologies
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.
@@ -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) Axenic Technologies
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.
@@ -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,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'convertvoicetotext/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "convertvoicetotext"
8
+ spec.version = Convertvoicetotext::VERSION
9
+ spec.date = %q{2014-12-31}
10
+ spec.authors = ["Axenic Technologies"]
11
+ spec.email = ["connect@axenictech.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/DeveshChau/convertvoicetotext"
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
@@ -0,0 +1,5 @@
1
+ require 'convertvoicetotext/version'
2
+ require 'convertvoicetotext/engine'
3
+
4
+ module Convertvoicetotext
5
+ end
@@ -0,0 +1,4 @@
1
+ module Convertvoicetotext
2
+ class Engine < Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module Convertvoicetotext
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: convertvoicetotext
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Axenic Technologies
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-12-31 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.7'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.7'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '10.0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '10.0'
46
+ description: Convert voice into text with high interpretation
47
+ email:
48
+ - connect@axenictech.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - Gemfile
54
+ - LICENSE.txt
55
+ - README.md
56
+ - Rakefile
57
+ - app/assets/javascripts/autotrack.js
58
+ - app/assets/javascripts/voice_to_text.js
59
+ - app/assets/javascripts/voicetotext.js
60
+ - convertvoicetotext.gemspec
61
+ - lib/convertvoicetotext.rb
62
+ - lib/convertvoicetotext/engine.rb
63
+ - lib/convertvoicetotext/version.rb
64
+ homepage: https://github.com/DeveshChau/convertvoicetotext
65
+ licenses:
66
+ - MIT
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubyforge_project:
85
+ rubygems_version: 1.8.23
86
+ signing_key:
87
+ specification_version: 3
88
+ summary: Convert voice into text
89
+ test_files: []
90
+ has_rdoc: