js android tts,JS调用微软TTS DEMO朗读

这篇博客展示了如何使用JavaScript与ActiveXObject交互,通过Sapi.SpVoice对象实现文本到语音(TTS)的功能。包括选择语音、设置音频输出、调整语速和音量,以及播放和停止语音朗读的函数实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

// Create the Sapi SpVoice object

var VoiceObj = new ActiveXObject("Sapi.SpVoice");

// ChangeVoice() function:

// This function sets the newly selected voice choice from the Voice

// Select box on the Voice object.

function ChangeVoice() {

var i = parseInt(idsVoices.value);

VoiceObj.Voice = VoiceObj.GetVoices().Item(i);

}

// ChangeAudioOutput() function:

// This function sets the newly selected audio output choice from the

// Audio Output Select box on the Voice object.

function ChangeAudioOutput() {

var i = parseInt(idsAudioOutputs.value);

VoiceObj.AudioOutput = VoiceObj.GetAudioOutputs().Item(i);

}

// IncRate() function:

// This function increases the speaking rate by 1 up to a maximum

// of 10.

function IncRate() {

if(Vo

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值