- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想让我的语音识别 JavaScript 连续录制一段固定的时间,比如 5 分钟。
我的js有如下代码
try {
var SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
var recognition = new SpeechRecognition();
}
catch(e) {
// console.error(e);
$('.no-browser-support').show();
//$('.app').hide();
}
var noteTextarea = $('#note-textarea');
var instructions = $('#recording-instructions');
var notesList = $('ul#notes');
var noteContent = '';
// Get all notes from previous sessions and display them.
var notes = getAllNotes();
renderNotes(notes);
$( document ).ready(function() {
// Handler for .ready() called.
if (noteContent.length) {
noteContent += ' ';
}
recognition.start();
});
最佳答案
SpeechRecognition
接口(interface)的 onend
属性表示一个事件处理程序,它将在语音识别服务断开连接时(结束事件触发时)运行。因此,当此事件发生时,您可以使用 start()
SpeechRecognition
所以,最后你应该有类似的东西
var recognition = new SpeechRecognition();
...
recognition.onend = function() {
recognition.start();
}
要让它持续五分钟,你可以使用计时器等,比如 setInterval
并在 onend
回调中添加一个检查以检查开始 recognition
是否再次。有点像
var counter = 0;
var interval = setInterval(function(){
counter++;
},1000)
recognition.onend = function() {
if(counter <= 5 * 60)
recognition.start();
else
clearInterval(interval)
}
请注意,识别
会在 5 分钟后停止,但至少会持续 5 分钟
关于javascript - 如何让语音识别连续固定时间段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51080738/
如果我使用以下方法计算 java.time 中 2 个 LocalDate 之间的差异: Period p = Period.between(testDate, today); 然后我得到一个包含年、
我正在开发一个有多种不同费率的预订平台。这些费率由一天中的时间、星期几和一年中的一天决定。以下是所涉及的间隔类型的一些示例: 周一至周五,上午 9 点至下午 5 点 周六和周日,中午 12 点到早上
我有大量数据,包括开始时间、停止时间和值。开始和停止时间因行而异,以 5 分钟为增量。我正在尝试创建一个新的数据框,该数据框具有 5 分钟的间隔以及该间隔在行的开始和停止范围内的所有行的总和。 我有一
我有一个这样的表: --------------------------------------------- |Id | Step | StartedAt
我有一个网络应用程序,用户将在其中输入 2 个日期。一个 StartDate 和一个 EndDate。现在我想编写它,以便在选择 StartDate 和 EndDate 时确定有多少周,然后显示这些周
这看起来并不直截了当。 我正在尝试: @Override public int compare(Period o1, Period o2) { return o1.toStandardDays
我必须为团队发送 session 邀请,这是我的邮件 $ical = 'BEGIN:VCALENDAR PRODID:-//Microsoft Corporation//Outlook 11.0
我有这个 ISO 8601 时间段字符串: P0Y0M0DT3H5M0.000S 并且 PHP7.4 无法用它构造 DateInterval。 format('%h Hours %m Minutes
我想要获取包含一段时间(格式为 HH:MM:SS)的多个单元格的总和。在 LibreOffice Calc 4.0.3.3 中,我复制粘贴了 G14:G21 范围内的时间段,并将单元格格式设置为时间
我有一个表(MySQL),每n秒捕获一次样本。该表有很多列,但重要的是两列:时间戳(TIMESTAMP 类型)和计数(INT 类型)。 我想做的是获取一定时间范围内计数列的总和和平均值。例如,我每 2
我有一个表(MySQL),每n秒捕获一次样本。该表有很多列,但重要的是两列:时间戳(TIMESTAMP 类型)和计数(INT 类型)。 我想做的是获取一定时间范围内计数列的总和和平均值。例如,我每 2
我在一个项目上使用 joda-time (1.6.2),我正在做的其中一件事就是计算预测时间和实际时间之间的差异。这种差异有时是积极的,有时是消极的。虽然适当的方法可能是使用 Duration 而不是
我有一个表 (MySQL),它每 n 秒捕获一次样本。该表有很多列,但最重要的是两列:一个时间戳(TIMESTAMP 类型)和一个计数(INT 类型)。 我想做的是获取计数列在一段时间内的总和和平均值
我想让我的折线图显示过去 3 个月的数据。 GDS 有一个“最后一个季度”的日期范围,但这显示的是 Q1、Q2、Q3 或 Q4。我需要的是过去3个整月(不算当月)的数据。我尝试创建一个计算字段,但事实
我想让我的折线图显示过去 3 个月的数据。 GDS 有一个“最后一个季度”的日期范围,但这显示的是 Q1、Q2、Q3 或 Q4。我需要的是过去3个整月(不算当月)的数据。我尝试创建一个计算字段,但事实
我是一名优秀的程序员,十分优秀!