S. Andy S. Andy - 1 year ago 185
AngularJS Question

Angular JS trying add a text to speech function

<ion-view view-title="Call Center" >
<ion-content = "padding">

<div ng-controller="CallCtrl1" class ="callPosition">
<!--button >Broken Lamp</button-->

<p class = "callMessage"> {{jalantol}} </p>
<a href="tel:{{telpon}}" ng-click = "panggil()" class= "button button-positive callButton" >

<p class = "callText"> Call </p>


function play(){
var text = "Keos bat skjadnsakjdnkasjndkjsand"
var url = 'http://translate.google.com/translate_tts?ie=UTF-8&total=1&idx=0&textlen=32&client=tw-ob&tl=id&q='+text;
var a = new Audio(url);
<button onclick="play();"> Speak it </button>


I'm newbie in ionic and web programming.
I have an ionic project using angular js, when I'm try to add text to speech function, it give an error "ReferenceError: play is not defined[Learn More]".
Anyone have any suggestion?
Thank's before

Answer Source

You can use speechSynthesis,

 var msg = new SpeechSynthesisUtterance("this is a test");

Working Demo

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download