S. Andy S. Andy - 1 month ago 7
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


You can use speechSynthesis,

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

Working Demo