typescript - 有没有办法将语音中的“文本”保存为文本离子语音识别
问题描述
我已经能够使用离子框架文档在我的项目中实现离子语音识别(语音到文本)现在我希望能够使用任何表单输入、ngmodel 或 formcontrol 保存文本或音频
我尝试使用将匹配变量绑定到分配给新变量的 ng 模型但没有用
startListening() {
let options = {
language: 'en-US',
matches: 2,
prompt: 'Say Something!'
}
this.speechRecognition.startListening(options).subscribe(matches => {
this.matches = matches;
this.cd.detectChanges();
});
this.isRecording = true;
}
<ion-grid>
<ion-row>
<ion-col *ngIf="matches">
<h3 *ngFor="let match of matches">
{{ match }}
</h3>
<ion-item>
<ion-input type="text" [(ngModel)]="matches">
</ion-input>
</ion-item>
</ion-col>
</ion-row>
</ion-grid>
我希望能够看到输入中的文本,以便在保存到数据库之前可以选择进行编辑
解决方案
我解决了终于用Angular trackBy解决了
<ion-grid>
<ion-row>
<ion-col *ngIf="matches">
<h3 *ngFor="let match of matches; let i = index; trackBy:trackByInstance"">
{{ match }}
</h3>
<ion-item>
<ion-input type="text" [(ngModel)]="matches[i]">
</ion-input>
</ion-item>
</ion-col>
</ion-row>
</ion-grid>
trackByInstance(index: any) {
return index;
推荐阅读
- database-design - 在 SQLAlchemy 中使用数组的替代方法
- python - 如何提取表格中的特定年份范围?
- netcdf - 对不包含时间维度的文件使用 xarray open_mfdataset
- sql - 如何将 Bigquery 中的 Cross Join 和 String Agg 与日期时间差结合起来
- python - 将自由文本用户回复转换为日期时间
- java - 单击按钮时未加载新的 FXML 场景
- wpf - 如何签署窗体应用程序,因为它不是我的选择
- c++ - 获取结构成员的指针后无法正确访问
- javascript - 如何从 fetch REACT.js 中显示地图功能
- android - 如何使用 QT 在 Android 设备上显示图像?