Skip to content

Commit

Permalink
fix: trim Wit Speech API result only when it exists
Browse files Browse the repository at this point in the history
  • Loading branch information
dessant committed May 28, 2020
1 parent 1e71a66 commit 8a54f1f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/background/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,11 @@ async function getWitSpeechApiResult(apiKey, audioContent) {
throw new Error(`API response: ${rsp.status}, ${await rsp.text()}`);
}

return (await rsp.json()).text.trim();
const result = (await rsp.json()).text;

if (result) {
return result.trim();
}
}

async function getIbmSpeechApiResult(apiUrl, apiKey, audioContent, language) {
Expand Down

0 comments on commit 8a54f1f

Please sign in to comment.