Skip to content

Commit 9c75805

Browse files
committed
Add package.json and ESLint
1 parent 283a5c1 commit 9c75805

7 files changed

+877
-8
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.eslintrc

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"parserOptions": {
3+
"ecmaVersion": 7
4+
},
5+
"rules": {
6+
"no-var": ["error"],
7+
"indent": ["error", 4],
8+
"max-len": ["error", 80],
9+
"prefer-const": ["error"],
10+
"semi": ["error", "always"],
11+
"eqeqeq": ["error", "smart"],
12+
"quotes": ["error", "double"]
13+
}
14+
}

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
# Editor files
55
.idea
66
*.iml
7+
8+
# JS files
9+
node_modules

basic-tts.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const tts = (() => {
66

77
const rejectWithMsg = (reject, msg) => {
88
reject({ msg });
9-
}
9+
};
1010

1111
const checkVoices = () => {
1212
return new Promise((resolve, reject) => {
@@ -25,7 +25,7 @@ const tts = (() => {
2525
});
2626
}
2727
}, 100);
28-
})
28+
});
2929
};
3030

3131
class Speaker {
@@ -64,7 +64,7 @@ const tts = (() => {
6464
utterance.voice = speakerVoice;
6565
}
6666

67-
return utterance
67+
return utterance;
6868
}
6969

7070
speak(text) {
@@ -75,18 +75,20 @@ const tts = (() => {
7575
const utterance = self.getUtterance(text);
7676

7777
if (!utterance) {
78-
rejectWithMsg(reject, "Speech could not be initialized due to invalid voice");
78+
rejectWithMsg(reject, "Speech could not be " +
79+
"initialized due to invalid voice");
7980
}
8081

8182
utterance["onend"] = resolve;
8283
utterance["onerror"] = () => {
83-
rejectWithMsg(reject, "Unable to speak the provided text");
84+
rejectWithMsg(reject, "Unable to speak " +
85+
"the provided text");
8486
};
8587

8688
self._speaker.speak(utterance);
8789
}).catch((err) => {
8890
rejectWithMsg(reject, err.msg);
89-
})
91+
});
9092
});
9193
}
9294
}
@@ -99,7 +101,7 @@ const tts = (() => {
99101
checkVoices,
100102
isSupported,
101103
createSpeaker,
102-
}
104+
};
103105
})();
104106

105107
if (typeof(module) !== "undefined") {

demo.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<!DOCTYPE html>
2-
<html>
2+
<html lang="en">
33
<head>
4+
<title>Basic-TTS Demo</title>
45
<script src="basic-tts.js"></script>
56
<script>
67
window.speechSynthesis.onvoiceschanged = () => {

0 commit comments

Comments
 (0)