i have a problem with https://ionicframework.com/docs/native/text-to-speech
because this say me TypeError: this.TTS.speak is not a function.
help me !!
import { TextToSpeech } from '@ionic-native/text-to-speech/ngx';
import { Storage } from '@ionic/storage';
@IonicPage()
@Component({
selector: 'page-ubications',
templateUrl: 'ubications.html',
})
export class UbicationsPage {
text: string;
rate: number;
locale: string;
datos: any;
inicio: any;
fin: any;
ref: any;
tipo: any;
bandera: any;
myForm: FormGroup;
@ViewChild('sku') inputToFocus;
constructor(
public tts: TextToSpeech,
private alertCtrl: AlertController,
public pservice: PedidosServicesProvider,
public loadingCtrl: LoadingController,
public formBuilder: FormBuilder,
public navCtrl: NavController,
public navParams: NavParams
) {
this.myForm = this.createMyForm();
this.bandera = 0;
this.text = 'Initial text';
this.rate = 1;
this.locale = 'en-US';
}
private createMyForm() {
return this.formBuilder.group({
refere: ['', Validators.required],
});
}
ionViewDidLoad() {
console.log('ionViewDidLoad UBICACIONES');
this.playText('hello');
setTimeout(() => {
this.inputToFocus.setFocus();
}, 300);
}
playText(t) {
this.tts
.speak({
text: 'hello',
rate: this.rate / 10,
locale: this.locale,
})
.then(() => console.log('Success'))
.catch((reason: any) => console.log(reason));
}
}