voice elements

voice-elements

Web Component wrapper to the Web Speech API, that allows you to do voice recognition (speech to text) and speech synthesis (text to speech) using Polymer.

Really nifty! Thanks to Polymer you’ll be provided with two extra elements you can use: <voice-player> for text to speech and <voice-recognition> for speech to text

<-- text to speech -->
<voice-player autoplay text="Welcome to the jungle! hahaha just kidding!"></voice-player>
<-- speech to text -->
<form id="recognition-form" class="pure-form">
	<fieldset>
		<textarea id="recognition-input" readonly=""></textarea>
	</fieldset>
	<fieldset>
		<button id="recognition-submit" class="pure-button pure-button-primary">Start!</button>
	</fieldset>
</form>

<voice-recognition id="recognition-element"></voice-recognition>

<script>
var form = document.querySelector('#recognition-form'),
    input = document.querySelector('#recognition-input'),
    element = document.querySelector('#recognition-element');

form.addEventListener('submit', function(e) {
    e.preventDefault();
    element.start();
});

element.addEventListener('result', function(e) {
    input.textContent = e.detail.result;
});
</script>

<voice-elements> Demo →
<voice-elements> Source (GitHub) →

Published by Bramus!

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.