嗯,我有一个程序,它使用来自Ionic的speechRecognition插件,它接受侦听并将结果放在警报中,可以将结果信息放入输入或文本区域,这是我的代码
import { Component } from '@angular/core';
import { SpeechRecognition } from '@ionic-native/speech-recognition/ngx'
@Component({
selector: 'app-voicetext',
templateUrl: './voicetext.page.html',
styleUrls: ['./voicetext.page.scss'],
})
export class VoicetextPage {
constructor( private speechRecognition: SpeechRecognition) {}
startListening() {
this.speechRecognition.startListening().subscribe((speeches)=>{
alert(speeches[0]);
},(err)=>{
alert(JSON.stringify(err));
})
}
}
Este es mi HTML
<ion-header
<ion-title color="light">Voz a Texto</ion-title>
</ion-header>
<ion-content>
<ion-button
(click)="startListening()">
</ion-button>
<ion-card class="ion-padding-horizontal">
<ion-textarea
rows="15" cols="20"
></ion-textarea>
</ion-card>
</ion-content>
发布于 2021-01-16 01:21:49
const myInput = document.querySelector(".myInput");
const myTextarea = document.querySelector(".myTextarea");
myInput.value = "I'm an input value";
myTextarea.innerHTML = "I'm an textarea innerHTML";<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<input type="text" class="myInput">
<textarea cols="20" rows="5" class="myTextarea"></textarea>
</body>
</html>
https://stackoverflow.com/questions/65740554
复制相似问题