forked from atsneves/react-native-text-to-speech-edge
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
41 lines (31 loc) · 888 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import {
NativeModules,
NativeEventEmitter,
} from "react-native";
const { AzureSpeechText } = NativeModules;
const AzureSpeechTextEmitter = new NativeEventEmitter(AzureSpeechText);
export default class RNAzureSpeechText {
static config(params) {
AzureSpeechText.config(params);
}
static async speechToText() {
let text = await AzureSpeechText.speechToText();
if (text) {
text = text.replace(".", "");
text = text.toLowerCase();
}
return text;
}
static async textToSpeech(text, voiceName = "en-US-AriaNeural") {
await AzureSpeechText.textToSpeech(text, voiceName);
}
static addListener(eventName, callback) {
AzureSpeechTextEmitter.addListener(eventName, callback);
}
static stopSpeechToText() {
AzureSpeechText.stopSpeechToText();
}
static stopTextToSpeech() {
AzureSpeechText.stopTextToSpeech();
}
}