1 Voice broadcast script, also can be used to read English
Just a simple two-line program saved as a. vbs, click Open to read the poem:
Set Objtts = CreateObject ("Sapi.spvoice") objtts.speak ("Ask to ask questions too young too simple,sometimes naive")
Using JS can call Baidu's API:
<!DOCTYPE HTML><HTML> <Head> <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"> <title>Voice test</title> <Scripttype= "Text/javascript"> functionDotts () {varTtsdiv=document.getElementById ('bdtts_div_id'); varTtsaudio=document.getElementById ('tts_autio_id'); varTtstext=document.getElementById ('Ttstext'). Value; Ttsdiv.removechild (Ttsaudio); varAU1= '<audio id= "tts_autio_id" autoplay= "AutoPlay" >'; varSSS= '<source id= "tts_source_id" src= "http://tts.baidu.com/text2audio?lan=zh&ie=UTF-8&spd=3&text= '+Ttstext+'"type=" > "Audio/mpeg "'; varEee= '<embed id= "tts_embed_id" height= "0" width= "0" src= "" >'; varAU2= '</audio>'; Ttsdiv.innerhtml=AU1+SSS+Eee+AU2; Ttsaudio=document.getElementById ('tts_autio_id'); Ttsaudio.play (); } </Script> </Head> <Body> <Div> <inputtype= "text"ID= "Ttstext"> <inputtype= "button"ID= "Tts_btn"onclick= "Dotts ()"value= "Play"> </Div> <DivID= "bdtts_div_id"> <AudioID= "tts_autio_id"AutoPlay= "AutoPlay"> <SourceID= "tts_source_id"src= "http://tts.baidu.com/text2audio?lan=zh&ie=UTF-8&spd=1&text= Broadcast content"type= "Audio/mpeg"> <EmbedID= "tts_embed_id"Height= "0"width= "0"src=""> </Audio> </Div> </Body></HTML>
A few simple and interesting VBS scripts and their JS implementations