Skip to content

Commit

Permalink
fix: rotate Wit.ai API keys for English challenges
Browse files Browse the repository at this point in the history
Closes #130.
  • Loading branch information
dessant committed Jan 29, 2020
1 parent 182a0aa commit e985b7d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/background/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
functionInContext,
getBrowser,
getPlatform,
getRandomInt,
arrayBufferToBase64
} from 'utils/common';
import {
Expand Down Expand Up @@ -220,7 +221,11 @@ async function prepareAudio(audio) {

async function getWitSpeechApiKey(speechService, language) {
if (speechService === 'witSpeechApiDemo') {
return witApiKeys[language];
if (language === 'english') {
return witApiKeys[language][getRandomInt(1, 4) - 1];
} else {
return witApiKeys[language];
}
} else {
const {witSpeechApiKeys: apiKeys} = await storage.get(
'witSpeechApiKeys',
Expand Down
7 changes: 6 additions & 1 deletion src/utils/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ const witApiKeys = {
catalan: 'YBAZZV6ITGFD3C2QX7CANYQPMGUOI7RK',
chinese: 'KBBALJMRKYDJJDMC4NJ32VWCBKFJFIIU',
dutch: 'T43TEUNW4HDQFNUTIA3EYTTD4A22AS4H',
english: 'NVYD6ZUJMC26US5XS2ZJJ32EDZZ654TD',
english: [
'BQE4QJJNYC6JVTDULHYIZHQOQFWUVDCQ',
'EQAXGAJVZIMI3YMILN2XQZY7IWGUPKGL',
'AA3LFNYPDNXX4MUDQQJNLT74YFRQ3M6F',
'DRTXENV66YE44PRYOJGWPX2BPGZNPYTQ'
],
finnish: '3GOWLMYD7DUY72XTPJW6QTVZSK2QEAPT',
french: 'JLNITTO2D4KMEOGQ6MTSN634ADK62VZ7',
german: 'LPVVXWRBFTVBOOHZAEJC3QRM6E3UMD7I',
Expand Down

0 comments on commit e985b7d

Please sign in to comment.