2017-05-24 46 views
0

我有一個非常簡單的問題要問。我想說其他語言,然後只是默認的en-US。我檢查官方頁面https://ionicframework.com/docs/native/text-to-speech/#TTSOptions,但我真的不知道如何將其應用於使用代碼中。離子本地插件文本到語音

用法:

import { TextToSpeech } from '@ionic-native/text-to-speech'; 

constructor(private tts: TextToSpeech) { } 

... 

this.tts.speak('Hello World') 
    .then(() => console.log('Success')) 
    .catch((reason: any) => console.log(reason)); 

這是我想在添加到使用代碼的選項。 enter image description here

回答

1

只需通過TTSOptions到說話()函數:

this.tts.speak({ 
    text: "Hello world", 
    locale: "en-US" // Pass any locale you want here. 
}).then(() => console.log('Success')) 
    .catch((reason: any) => console.log(reason));