Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
AngularJS Speech Recognition
<!doctype html>
<script src=""></script>
<script src=""></script>
<script src=""></script>
<link rel="stylesheet" href="//" />
<link rel="stylesheet" href="" />
<div class="container" ng-app="PubNubAngularApp" ng-controller="MySpeechCtrl">
<pre>NOTE: Requires Chrome Desktop or Android Browser</pre>
<h3>MySpeech to Text</h3>
<textarea ng-model="theText" rows="10" cols="40"></textarea>
<input type="button" ng-click="dictateIt()" value="Dictate it!" />
angular.module('PubNubAngularApp', ["pubnub.angular.service"])
.controller('MySpeechCtrl', function($rootScope, $scope, Pubnub) {
$scope.theText = "Don't just stand there, say something!";
$scope.dictateIt = function () {
$scope.theText = "";
var recognition = new webkitSpeechRecognition();
recognition.onresult = function (event) {
$scope.$apply(function() {
for (var i = event.resultIndex; i < event.results.length; i++) {
if (event.results[i].isFinal) {
$scope.theText += event.results[i][0].transcript;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment