From e985b7d6662c1f168bf504d799cd773ba5e5d8b3 Mon Sep 17 00:00:00 2001 From: dessant Date: Wed, 29 Jan 2020 20:50:05 +0200 Subject: [PATCH] fix: rotate Wit.ai API keys for English challenges Closes #130. --- src/background/main.js | 7 ++++++- src/utils/config.js | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/background/main.js b/src/background/main.js index c11c45c..3da5e4c 100644 --- a/src/background/main.js +++ b/src/background/main.js @@ -15,6 +15,7 @@ import { functionInContext, getBrowser, getPlatform, + getRandomInt, arrayBufferToBase64 } from 'utils/common'; import { @@ -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', diff --git a/src/utils/config.js b/src/utils/config.js index e56de3b..02ac323 100644 --- a/src/utils/config.js +++ b/src/utils/config.js @@ -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',