cordova-plugin-tts
cordova-plugin-tts copied to clipboard
Ionic text to speech not works
Hi All, I am in middle of the application for the text to speech, I used Ionic cordova native text to speech plugin, It works fine when I pass option local:'en-US', In same scenario when I pass local:'ru_RU' for russian, not working. Here i s the code snippet. src/pages/home/home.html
<ion-header>
<ion-navbar>
<ion-title>
Ionic Text To Speech
</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<ion-list>
<!--Text-->
<ion-item>
<ion-label>Text</ion-label>
<ion-input [(ngModel)]="text"></ion-input>
</ion-item>
<!--Rate-->
<ion-item>
<ion-range min="1" max="30" step="1" [(ngModel)]="rate">
<ion-icon small range-left name="remove"></ion-icon>
<ion-icon small range-right name="add"></ion-icon>
</ion-range>
</ion-item>
<!--Language-->
<ion-item>
<ion-label>Language</ion-label>
<ion-select [(ngModel)]="locale">
<ion-option value="ru_RU">Russian</ion-option>
<ion-option value="en-US">English</ion-option>
</ion-select>
</ion-item>
<!--Play text-->
<button ion-button full (click)="playText()">Play Text</button>
</ion-list>
</ion-content>
src/pages/home/home.ts
import {Component} from '@angular/core';
import {TextToSpeech} from '@ionic-native/text-to-speech';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
text: string;
rate: number;
locale: string;
constructor(private tts: TextToSpeech) {
this.text = 'Initial text';
this.rate = 1;
this.locale = 'en-US';
}
playText() {
this.tts.speak({
text: this.text,
rate: this.rate / 10,
locale: this.locale
})
.then(() => console.log('Success'))
.catch((reason: any) => console.log(reason));
}
}
Please look into it. I want multiple language text to speech.
Thanks.
You have to change from ru_RU to ru-RU